[javascriptlint-commit] SF.net SVN: javascriptlint:[384] trunk
Status: Beta
Brought to you by:
matthiasmiller
|
From: <mat...@us...> - 2018-06-10 20:27:00
|
Revision: 384
http://sourceforge.net/p/javascriptlint/code/384
Author: matthiasmiller
Date: 2018-06-10 20:26:59 +0000 (Sun, 10 Jun 2018)
Log Message:
-----------
Fix the useless assignment warning.
Modified Paths:
--------------
trunk/javascriptlint/lintwarnings.py
trunk/tests/warnings/useless_assign.js
Modified: trunk/javascriptlint/lintwarnings.py
===================================================================
--- trunk/javascriptlint/lintwarnings.py 2018-06-10 20:17:00 UTC (rev 383)
+++ trunk/javascriptlint/lintwarnings.py 2018-06-10 20:26:59 UTC (rev 384)
@@ -473,11 +473,14 @@
@lookfor((tok.NAME, op.SETNAME))
def useless_assign(node):
- if node.parent.kind == tok.ASSIGN:
+ if node.parent.kind == tok.ASSIGN and node.parent.opcode not in (op.MUL, op.ADD, op.LSH,
+ op.RSH, op.URSH):
assert node.node_index == 0
value = node.parent.kids[1]
elif node.parent.kind == tok.VAR:
value = node.kids[0]
+ else:
+ value = None
if value and value.kind == tok.NAME and node.atom == value.atom:
raise LintWarning(node)
Modified: trunk/tests/warnings/useless_assign.js
===================================================================
--- trunk/tests/warnings/useless_assign.js 2018-06-10 20:17:00 UTC (rev 383)
+++ trunk/tests/warnings/useless_assign.js 2018-06-10 20:26:59 UTC (rev 384)
@@ -17,4 +17,19 @@
for (; ; i = i) { /*warning:useless_assign*/
i++;
}
+
+ // These could conceivably be meaningful.
+ i *= i;
+ i += i;
+ i >>= i;
+ i <<= i;
+ i >>>= i;
+
+ // These make no sense.
+ i /= i; /*warning:useless_assign*/
+ i -= i; /*warning:useless_assign*/
+ i %= i; /*warning:useless_assign*/
+ i &= i; /*warning:useless_assign*/
+ i |= i; /*warning:useless_assign*/
+ i ^= i; /*warning:useless_assign*/
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|