Browse Source

fix(eslint): Add no-loop-func rule

dev1
hristoterezov 8 years ago
parent
commit
774ee4b2b0

+ 1
- 0
.eslintrc.js View File

@@ -97,6 +97,7 @@ module.exports = {
97 97
         'no-iterator': 2,
98 98
         'no-labels': 2,
99 99
         'no-lone-blocks': 2,
100
+        'no-loop-func': 2,
100 101
         'no-magic-numbers': 0,
101 102
         'no-multi-spaces': 2,
102 103
         'no-multi-str': 2,

+ 3
- 1
modules/connectivity/ConnectionQuality.js View File

@@ -89,8 +89,10 @@ function getTarget(simulcast, resolution, millisSinceStart) {
89 89
             // Sum the target fields from all simulcast layers for the given
90 90
             // resolution (e.g. 720p + 360p + 180p).
91 91
             for (height = simulcastFormat.height; height >= 180; height /= 2) {
92
+                const targetHeight = height;
93
+
92 94
                 simulcastFormat
93
-                    = kSimulcastFormats.find(f => f.height == height);
95
+                    = kSimulcastFormats.find(f => f.height == targetHeight);
94 96
                 if (simulcastFormat) {
95 97
                     target += simulcastFormat.target;
96 98
                 } else {

+ 14
- 11
modules/transcription/transcriber.js View File

@@ -191,13 +191,10 @@ transcriber.prototype.merge = function() {
191 191
     arrays.forEach(array => pushWordToSortedArray(potentialWords, array));
192 192
 
193 193
     // keep adding words to transcription until all arrays are exhausted
194
-    let lowestWordArray;
195
-    let wordToAdd;
196
-    let foundSmaller;
197
-
198 194
     while (hasPopulatedArrays(arrays)) {
199 195
         // first select the lowest array;
200
-        lowestWordArray = arrays[0];
196
+        let lowestWordArray = arrays[0];
197
+
201 198
         arrays.forEach(wordArray => {
202 199
             if (wordArray[0].begin < lowestWordArray[0].begin) {
203 200
                 lowestWordArray = wordArray;
@@ -205,23 +202,29 @@ transcriber.prototype.merge = function() {
205 202
         });
206 203
 
207 204
         // put the word in the transcription
208
-        wordToAdd = lowestWordArray.shift();
205
+        let wordToAdd = lowestWordArray.shift();
206
+
209 207
         this.updateTranscription(wordToAdd, lowestWordArray.name);
210 208
 
211 209
         // keep going until a word in another array has a smaller time
212 210
         // or the array is empty
213
-        while (!foundSmaller && lowestWordArray.length > 0) {
211
+        while (lowestWordArray.length > 0) {
212
+            let foundSmaller = false;
213
+            const wordToCompare = lowestWordArray[0].begin;
214
+
214 215
             arrays.forEach(wordArray => {
215
-                if (wordArray[0].begin < lowestWordArray[0].begin) {
216
+                if (wordArray[0].begin < wordToCompare) {
216 217
                     foundSmaller = true;
217 218
                 }
218 219
             });
219 220
 
220 221
             // add next word if no smaller time has been found
221
-            if (!foundSmaller) {
222
-                wordToAdd = lowestWordArray.shift();
223
-                this.updateTranscription(wordToAdd, null);
222
+            if (foundSmaller) {
223
+                break;
224 224
             }
225
+
226
+            wordToAdd = lowestWordArray.shift();
227
+            this.updateTranscription(wordToAdd, null);
225 228
         }
226 229
 
227 230
     }

+ 1
- 0
modules/xmpp/SDP.js View File

@@ -270,6 +270,7 @@ SDP.prototype.toJingle = function(elem, thecreator) {
270 270
                 const ssrclines = SDPUtil.find_lines(this.media[i], 'a=ssrc:');
271 271
 
272 272
                 if (ssrclines.length > 0) {
273
+                    // eslint-disable-next-line no-loop-func
273 274
                     ssrclines.forEach(line => {
274 275
                         const idx = line.indexOf(' ');
275 276
                         const linessrc = line.substr(0, idx).substr(7);

Loading…
Cancel
Save