Browse Source

Merge pull request #18864 from makc/lgtm-fixes

Another round of lgtm fixes
Mr.doob 5 years ago
parent
commit
70b81dd4f0

+ 1 - 1
editor/js/LoaderUtils.js

@@ -54,7 +54,7 @@ var LoaderUtils = {
 
 					}
 
-					onEntryHandled( entry );
+					onEntryHandled();
 
 				} );
 

+ 5 - 5
editor/js/libs/codemirror/codemirror.js

@@ -1525,7 +1525,7 @@
 
         // Try to detect the user choosing select-all
         if (te.selectionStart != null) {
-          if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
+          if (!ie || (ie_version < 9)) prepareSelectAllHack();
           var i = 0, poll = function() {
             if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
                 te.selectionEnd > 0 && input.prevInput == "\u200b")
@@ -2222,7 +2222,7 @@
   // Verify that the selection does not partially select any atomic
   // marked ranges.
   function reCheckSelection(doc) {
-    setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
+    setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));
   }
 
   // Return a selection that does not partially select any atomic
@@ -4040,7 +4040,7 @@
       // actually possible. Otherwise, it causes vertical scroll
       // jitter on OSX trackpads when deltaX is small and deltaY
       // is large (issue #3579)
-      if (!dy || (dy && canScrollY))
+      if (!dy || canScrollY)
         e_preventDefault(e);
       display.wheelStartX = null; // Abort measurement, if in progress
       return;
@@ -8771,8 +8771,8 @@
     return function(str) {
       if (!bidiRE.test(str)) return false;
       var len = str.length, types = [];
-      for (var i = 0, type; i < len; ++i)
-        types.push(type = charType(str.charCodeAt(i)));
+      for (var i = 0; i < len; ++i)
+        types.push(charType(str.charCodeAt(i)));
 
       // W1. Examine each non-spacing mark (NSM) in the level run, and
       // change the type of the NSM to the type of the previous

+ 0 - 12
editor/js/libs/codemirror/mode/glsl.js

@@ -221,18 +221,6 @@
   }
 
   ;(function() {
-    // C#-style strings where "" escapes a quote.
-    function tokenAtString(stream, state) {
-      var next;
-      while ((next = stream.next()) != null) {
-        if (next == '"' && !stream.eat('"')) {
-          state.tokenize = null;
-          break;
-        }
-      }
-      return "string";
-    }
-
     CodeMirror.defineMIME("text/x-glsl", {
       name: "glsl",
       keywords: words(glslKeywords),

+ 4 - 5
editor/js/libs/esprima.js

@@ -1132,8 +1132,7 @@
     }
 
     function testRegExp(pattern, flags) {
-        var tmp = pattern,
-            value;
+        var tmp = pattern;
 
         if (flags.indexOf('u') >= 0) {
             // Replace each astral symbol and every Unicode code point
@@ -1156,7 +1155,7 @@
 
         // First, detect invalid regular expressions.
         try {
-            value = new RegExp(tmp);
+            new RegExp(tmp);
         } catch (e) {
             throwError(Messages.InvalidRegExp);
         }
@@ -3567,7 +3566,7 @@
         if (type === Token.Punctuator) {
             switch (lookahead.value) {
             case ';':
-                return parseEmptyStatement(node);
+                return parseEmptyStatement();
             case '(':
                 return parseExpressionStatement(node);
             default:
@@ -3586,7 +3585,7 @@
             case 'for':
                 return parseForStatement(node);
             case 'function':
-                return parseFunctionDeclaration(node);
+                return parseFunctionDeclaration();
             case 'if':
                 return parseIfStatement(node);
             case 'return':

+ 2 - 4
editor/js/libs/jsonlint.js

@@ -120,7 +120,7 @@ parse: function parse(input) {
         return token;
     }
 
-    var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
+    var symbol, preErrorSymbol, state, action, r, yyval={},p,len,newState, expected;
     while (true) {
         // retreive state number from top of stack
         state = stack[stack.length-1];
@@ -329,7 +329,6 @@ next:function () {
             match,
             tempMatch,
             index,
-            col,
             lines;
         if (!this._more) {
             this.yytext = '';
@@ -393,9 +392,8 @@ pushState:function begin(condition) {
         this.begin(condition);
     }});
 lexer.options = {};
-lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
+lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions) {
 
-var YYSTATE=YY_START
 switch($avoiding_name_collisions) {
 case 0:/* skip whitespace */
 break;

+ 1 - 1
editor/js/libs/ternjs/infer.js

@@ -215,7 +215,7 @@
 
   function similarType(a, b, depth) {
     if (!a || depth >= 5) return b;
-    if (!a || a == b) return a;
+    if (a == b) return a;
     if (!b) return a;
     if (a.constructor != b.constructor) return false;
     if (a.constructor == Arr) {

+ 2 - 3
editor/js/libs/ternjs/tern.js

@@ -374,8 +374,7 @@
     // This is a partial file
 
     var realFile = file.backing = srv.findFile(file.name);
-    var offset = file.offset;
-    if (file.offsetLines) offset = {line: file.offsetLines, ch: 0};
+    var offset;
     file.offset = offset = resolvePos(realFile, file.offsetLines == null ? file.offset : {line: file.offsetLines, ch: 0}, true);
     var line = firstLine(file.text);
     var foundPos = findMatchingPosition(line, realFile.text, offset);
@@ -950,7 +949,7 @@
 
   function findRefs(srv, query, file) {
     var expr = findExprOrThrow(file, query, true);
-    if (expr && expr.node.type == "Identifier") {
+    if (expr.node.type == "Identifier") {
       return findRefsToVariable(srv, query, file, expr);
     } else if (expr && expr.node.type == "MemberExpression" && !expr.node.computed) {
       var p = expr.node.property;

+ 0 - 4
examples/js/loaders/LDrawLoader.js

@@ -1174,8 +1174,6 @@ THREE.LDrawLoader = ( function () {
 
 									type = lp.getToken();
 
-									if ( ! parsingEmbeddedFiles ) {
-
 										currentParseScope.triangles = [];
 										currentParseScope.lineSegments = [];
 										currentParseScope.conditionalSegments = [];
@@ -1207,8 +1205,6 @@ THREE.LDrawLoader = ( function () {
 										lineSegments = currentParseScope.lineSegments;
 										conditionalSegments = currentParseScope.conditionalSegments;
 
-									}
-
 									break;
 
 								case '!COLOUR':

+ 0 - 4
examples/jsm/loaders/LDrawLoader.js

@@ -1192,8 +1192,6 @@ var LDrawLoader = ( function () {
 
 									type = lp.getToken();
 
-									if ( ! parsingEmbeddedFiles ) {
-
 										currentParseScope.triangles = [];
 										currentParseScope.lineSegments = [];
 										currentParseScope.conditionalSegments = [];
@@ -1225,8 +1223,6 @@ var LDrawLoader = ( function () {
 										lineSegments = currentParseScope.lineSegments;
 										conditionalSegments = currentParseScope.conditionalSegments;
 
-									}
-
 									break;
 
 								case '!COLOUR':

+ 1 - 2
examples/jsm/loaders/OBJLoader2.js

@@ -265,8 +265,7 @@ OBJLoader2.prototype = Object.assign( Object.create( Loader.prototype ), {
 		if ( urlParts.length > 2 ) {
 
 			filename = urlParts[ urlParts.length - 1 ];
-			let urlPartsPath = urlParts.slice( 0, urlParts.length - 1 ).join( '/' ) + '/';
-			if ( urlPartsPath !== undefined && urlPartsPath !== null ) this.path = urlPartsPath;
+			this.path = urlParts.slice( 0, urlParts.length - 1 ).join( '/' ) + '/';
 
 		}
 		if ( onFileLoadProgress === null || onFileLoadProgress === undefined || ! ( onFileLoadProgress instanceof Function ) ) {

+ 2 - 2
examples/jsm/utils/GeometryCompressionUtils.js

@@ -446,8 +446,8 @@ var GeometryCompressionUtils = {
 
 				if ( z < 0 ) {
 
-					var tempx = tempx = ( 1 - Math.abs( y ) ) * ( x >= 0 ? 1 : - 1 );
-					var tempy = tempy = ( 1 - Math.abs( x ) ) * ( y >= 0 ? 1 : - 1 );
+					var tempx = ( 1 - Math.abs( y ) ) * ( x >= 0 ? 1 : - 1 );
+					var tempy = ( 1 - Math.abs( x ) ) * ( y >= 0 ? 1 : - 1 );
 
 					x = tempx;
 					y = tempy;