summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/code-path-analysis/code-path-state.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-08-13 15:06:43 -0700
committerRich Trott <rtrott@gmail.com>2016-08-16 15:16:10 -0700
commit05b566a5ef7c41f6f578fd36af0b5d91cbe1a2e4 (patch)
tree740a3e544a158e100ff7f4c65e6e913d6239e584 /tools/eslint/lib/code-path-analysis/code-path-state.js
parent88650aaa70768755524e7ad1a7aa8074ac9b1983 (diff)
downloadnode-new-05b566a5ef7c41f6f578fd36af0b5d91cbe1a2e4.tar.gz
tools: update ESLint to 3.3.0 and enable rules
Update ESLint 3.3.0 and update .eslintrc: * replace deprecated no-negated-in-lhs rule with no-unsafe-negation * http://eslint.org/docs/rules/no-negated-in-lhs * http://eslint.org/docs/rules/no-unsafe-negation * enable no-template-curly-in-string * http://eslint.org/docs/rules/no-template-curly-in-string * enable no-global-assign * http://eslint.org/docs/rules/no-global-assign * enable func-call-spacing * http://eslint.org/docs/rules/func-call-spacing PR-URL: https://github.com/nodejs/node/pull/8097 Reviewed-By: targos - Michaƫl Zasso <mic.besace@gmail.com> Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'tools/eslint/lib/code-path-analysis/code-path-state.js')
-rw-r--r--tools/eslint/lib/code-path-analysis/code-path-state.js200
1 files changed, 100 insertions, 100 deletions
diff --git a/tools/eslint/lib/code-path-analysis/code-path-state.js b/tools/eslint/lib/code-path-analysis/code-path-state.js
index 7c3d4a35e6..bfa93ac607 100644
--- a/tools/eslint/lib/code-path-analysis/code-path-state.js
+++ b/tools/eslint/lib/code-path-analysis/code-path-state.js
@@ -9,7 +9,7 @@
// Requirements
//------------------------------------------------------------------------------
-let CodePathSegment = require("./code-path-segment"),
+const CodePathSegment = require("./code-path-segment"),
ForkContext = require("./fork-context");
//------------------------------------------------------------------------------
@@ -31,7 +31,7 @@ let CodePathSegment = require("./code-path-segment"),
*/
function addToReturnedOrThrown(dest, others, all, segments) {
for (let i = 0; i < segments.length; ++i) {
- let segment = segments[i];
+ const segment = segments[i];
dest.push(segment);
if (others.indexOf(segment) === -1) {
@@ -150,8 +150,8 @@ function remove(xs, x) {
*/
function removeConnection(prevSegments, nextSegments) {
for (let i = 0; i < prevSegments.length; ++i) {
- let prevSegment = prevSegments[i];
- let nextSegment = nextSegments[i];
+ const prevSegment = prevSegments[i];
+ const nextSegment = nextSegments[i];
remove(prevSegment.nextSegments, nextSegment);
remove(prevSegment.allNextSegments, nextSegment);
@@ -169,11 +169,11 @@ function removeConnection(prevSegments, nextSegments) {
* @returns {void}
*/
function makeLooped(state, fromSegments, toSegments) {
- let end = Math.min(fromSegments.length, toSegments.length);
+ const end = Math.min(fromSegments.length, toSegments.length);
for (let i = 0; i < end; ++i) {
- let fromSegment = fromSegments[i];
- let toSegment = toSegments[i];
+ const fromSegment = fromSegments[i];
+ const toSegment = toSegments[i];
if (toSegment.reachable) {
fromSegment.nextSegments.push(toSegment);
@@ -241,9 +241,9 @@ function CodePathState(idGenerator, onLooped) {
this.initialSegment = this.forkContext.head[0];
// returnedSegments and thrownSegments push elements into finalSegments also.
- let final = this.finalSegments = [];
- let returned = this.returnedForkContext = [];
- let thrown = this.thrownForkContext = [];
+ const final = this.finalSegments = [];
+ const returned = this.returnedForkContext = [];
+ const thrown = this.thrownForkContext = [];
returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final);
thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final);
@@ -266,7 +266,7 @@ CodePathState.prototype = {
* @type {ForkContext}
*/
get parentForkContext() {
- let current = this.forkContext;
+ const current = this.forkContext;
return current && current.upper;
},
@@ -292,7 +292,7 @@ CodePathState.prototype = {
* @returns {ForkContext} The last context.
*/
popForkContext: function() {
- let lastContext = this.forkContext;
+ const lastContext = this.forkContext;
this.forkContext = lastContext.upper;
this.forkContext.replaceHead(lastContext.makeNext(0, -1));
@@ -370,12 +370,12 @@ CodePathState.prototype = {
* @returns {ChoiceContext} The popped context.
*/
popChoiceContext: function() {
- let context = this.choiceContext;
+ const context = this.choiceContext;
this.choiceContext = context.upper;
- let forkContext = this.forkContext;
- let headSegments = forkContext.head;
+ const forkContext = this.forkContext;
+ const headSegments = forkContext.head;
switch (context.kind) {
case "&&":
@@ -396,7 +396,7 @@ CodePathState.prototype = {
* test chunk.
*/
if (context.isForkingAsResult) {
- let parentContext = this.choiceContext;
+ const parentContext = this.choiceContext;
parentContext.trueForkContext.addAll(context.trueForkContext);
parentContext.falseForkContext.addAll(context.falseForkContext);
@@ -443,7 +443,7 @@ CodePathState.prototype = {
}
// Merges all paths.
- let prevForkContext = context.trueForkContext;
+ const prevForkContext = context.trueForkContext;
prevForkContext.addAll(context.falseForkContext);
forkContext.replaceHead(prevForkContext.makeNext(0, -1));
@@ -458,8 +458,8 @@ CodePathState.prototype = {
* @returns {void}
*/
makeLogicalRight: function() {
- let context = this.choiceContext;
- let forkContext = this.forkContext;
+ const context = this.choiceContext;
+ const forkContext = this.forkContext;
if (context.processed) {
@@ -467,7 +467,7 @@ CodePathState.prototype = {
* This got segments already from the child choice context.
* Creates the next path from own true/false fork context.
*/
- let prevForkContext =
+ const prevForkContext =
context.kind === "&&" ? context.trueForkContext :
/* kind === "||" */ context.falseForkContext;
@@ -502,8 +502,8 @@ CodePathState.prototype = {
* @returns {void}
*/
makeIfConsequent: function() {
- let context = this.choiceContext;
- let forkContext = this.forkContext;
+ const context = this.choiceContext;
+ const forkContext = this.forkContext;
/*
* If any result were not transferred from child contexts,
@@ -529,8 +529,8 @@ CodePathState.prototype = {
* @returns {void}
*/
makeIfAlternate: function() {
- let context = this.choiceContext;
- let forkContext = this.forkContext;
+ const context = this.choiceContext;
+ const forkContext = this.forkContext;
/*
* The head segments are the path of the `if` block.
@@ -583,12 +583,12 @@ CodePathState.prototype = {
* @returns {void}
*/
popSwitchContext: function() {
- let context = this.switchContext;
+ const context = this.switchContext;
this.switchContext = context.upper;
- let forkContext = this.forkContext;
- let brokenForkContext = this.popBreakContext().brokenForkContext;
+ const forkContext = this.forkContext;
+ const brokenForkContext = this.popBreakContext().brokenForkContext;
if (context.countForks === 0) {
@@ -605,10 +605,10 @@ CodePathState.prototype = {
return;
}
- let lastSegments = forkContext.head;
+ const lastSegments = forkContext.head;
this.forkBypassPath();
- let lastCaseSegments = forkContext.head;
+ const lastCaseSegments = forkContext.head;
/*
* `brokenForkContext` is used to make the next segment.
@@ -659,7 +659,7 @@ CodePathState.prototype = {
* @returns {void}
*/
makeSwitchCaseBody: function(isEmpty, isDefault) {
- let context = this.switchContext;
+ const context = this.switchContext;
if (!context.hasCase) {
return;
@@ -670,8 +670,8 @@ CodePathState.prototype = {
* The parent fork context has two segments.
* Those are from the current case and the body of the previous case.
*/
- let parentForkContext = this.forkContext;
- let forkContext = this.pushForkContext();
+ const parentForkContext = this.forkContext;
+ const forkContext = this.pushForkContext();
forkContext.add(parentForkContext.makeNext(0, -1));
@@ -731,7 +731,7 @@ CodePathState.prototype = {
* @returns {void}
*/
popTryContext: function() {
- let context = this.tryContext;
+ const context = this.tryContext;
this.tryContext = context.upper;
@@ -747,19 +747,19 @@ CodePathState.prototype = {
* block.
*/
- let returned = context.returnedForkContext;
- let thrown = context.thrownForkContext;
+ const returned = context.returnedForkContext;
+ const thrown = context.thrownForkContext;
if (returned.empty && thrown.empty) {
return;
}
// Separate head to normal paths and leaving paths.
- let headSegments = this.forkContext.head;
+ const headSegments = this.forkContext.head;
this.forkContext = this.forkContext.upper;
- let normalSegments = headSegments.slice(0, headSegments.length / 2 | 0);
- let leavingSegments = headSegments.slice(headSegments.length / 2 | 0);
+ const normalSegments = headSegments.slice(0, headSegments.length / 2 | 0);
+ const leavingSegments = headSegments.slice(headSegments.length / 2 | 0);
// Forwards the leaving path to upper contexts.
if (!returned.empty) {
@@ -785,9 +785,9 @@ CodePathState.prototype = {
* @returns {void}
*/
makeCatchBlock: function() {
- let context = this.tryContext;
- let forkContext = this.forkContext;
- let thrown = context.thrownForkContext;
+ const context = this.tryContext;
+ const forkContext = this.forkContext;
+ const thrown = context.thrownForkContext;
// Update state.
context.position = "catch";
@@ -796,7 +796,7 @@ CodePathState.prototype = {
// Merge thrown paths.
thrown.add(forkContext.head);
- let thrownSegments = thrown.makeNext(0, -1);
+ const thrownSegments = thrown.makeNext(0, -1);
// Fork to a bypass and the merged thrown path.
this.pushForkContext();
@@ -814,11 +814,11 @@ CodePathState.prototype = {
* @returns {void}
*/
makeFinallyBlock: function() {
- let context = this.tryContext;
+ const context = this.tryContext;
let forkContext = this.forkContext;
- let returned = context.returnedForkContext;
- let thrown = context.thrownForkContext;
- let headOfLeavingSegments = forkContext.head;
+ const returned = context.returnedForkContext;
+ const thrown = context.thrownForkContext;
+ const headOfLeavingSegments = forkContext.head;
// Update state.
if (context.position === "catch") {
@@ -843,11 +843,11 @@ CodePathState.prototype = {
* Create a parallel segment from merging returned and thrown.
* This segment will leave at the end of this finally block.
*/
- let segments = forkContext.makeNext(-1, -1);
+ const segments = forkContext.makeNext(-1, -1);
let j;
for (let i = 0; i < forkContext.count; ++i) {
- let prevSegsOfLeavingSegment = [headOfLeavingSegments[i]];
+ const prevSegsOfLeavingSegment = [headOfLeavingSegments[i]];
for (j = 0; j < returned.segmentsList.length; ++j) {
prevSegsOfLeavingSegment.push(returned.segmentsList[j][i]);
@@ -872,13 +872,13 @@ CodePathState.prototype = {
* @returns {void}
*/
makeFirstThrowablePathInTryBlock: function() {
- let forkContext = this.forkContext;
+ const forkContext = this.forkContext;
if (!forkContext.reachable) {
return;
}
- let context = getThrowContext(this);
+ const context = getThrowContext(this);
if (context === this ||
context.position !== "try" ||
@@ -905,8 +905,8 @@ CodePathState.prototype = {
* @returns {void}
*/
pushLoopContext: function(type, label) {
- let forkContext = this.forkContext;
- let breakContext = this.pushBreakContext(true, label);
+ const forkContext = this.forkContext;
+ const breakContext = this.pushBreakContext(true, label);
switch (type) {
case "WhileStatement":
@@ -977,12 +977,12 @@ CodePathState.prototype = {
* @returns {void}
*/
popLoopContext: function() {
- let context = this.loopContext;
+ const context = this.loopContext;
this.loopContext = context.upper;
- let forkContext = this.forkContext;
- let brokenForkContext = this.popBreakContext().brokenForkContext;
+ const forkContext = this.forkContext;
+ const brokenForkContext = this.popBreakContext().brokenForkContext;
let choiceContext;
// Creates a looped path.
@@ -1048,9 +1048,9 @@ CodePathState.prototype = {
* @returns {void}
*/
makeWhileTest: function(test) {
- let context = this.loopContext;
- let forkContext = this.forkContext;
- let testSegments = forkContext.makeNext(0, -1);
+ const context = this.loopContext;
+ const forkContext = this.forkContext;
+ const testSegments = forkContext.makeNext(0, -1);
// Update state.
context.test = test;
@@ -1064,9 +1064,9 @@ CodePathState.prototype = {
* @returns {void}
*/
makeWhileBody: function() {
- let context = this.loopContext;
- let choiceContext = this.choiceContext;
- let forkContext = this.forkContext;
+ const context = this.loopContext;
+ const choiceContext = this.choiceContext;
+ const forkContext = this.forkContext;
if (!choiceContext.processed) {
choiceContext.trueForkContext.add(forkContext.head);
@@ -1086,9 +1086,9 @@ CodePathState.prototype = {
* @returns {void}
*/
makeDoWhileBody: function() {
- let context = this.loopContext;
- let forkContext = this.forkContext;
- let bodySegments = forkContext.makeNext(-1, -1);
+ const context = this.loopContext;
+ const forkContext = this.forkContext;
+ const bodySegments = forkContext.makeNext(-1, -1);
// Update state.
context.entrySegments = bodySegments;
@@ -1102,15 +1102,15 @@ CodePathState.prototype = {
* @returns {void}
*/
makeDoWhileTest: function(test) {
- let context = this.loopContext;
- let forkContext = this.forkContext;
+ const context = this.loopContext;
+ const forkContext = this.forkContext;
context.test = test;
// Creates paths of `continue` statements.
if (!context.continueForkContext.empty) {
context.continueForkContext.add(forkContext.head);
- let testSegments = context.continueForkContext.makeNext(0, -1);
+ const testSegments = context.continueForkContext.makeNext(0, -1);
forkContext.replaceHead(testSegments);
}
@@ -1123,10 +1123,10 @@ CodePathState.prototype = {
* @returns {void}
*/
makeForTest: function(test) {
- let context = this.loopContext;
- let forkContext = this.forkContext;
- let endOfInitSegments = forkContext.head;
- let testSegments = forkContext.makeNext(-1, -1);
+ const context = this.loopContext;
+ const forkContext = this.forkContext;
+ const endOfInitSegments = forkContext.head;
+ const testSegments = forkContext.makeNext(-1, -1);
// Update state.
context.test = test;
@@ -1141,9 +1141,9 @@ CodePathState.prototype = {
* @returns {void}
*/
makeForUpdate: function() {
- let context = this.loopContext;
- let choiceContext = this.choiceContext;
- let forkContext = this.forkContext;
+ const context = this.loopContext;
+ const choiceContext = this.choiceContext;
+ const forkContext = this.forkContext;
// Make the next paths of the test.
if (context.testSegments) {
@@ -1156,7 +1156,7 @@ CodePathState.prototype = {
}
// Update state.
- let updateSegments = forkContext.makeDisconnected(-1, -1);
+ const updateSegments = forkContext.makeDisconnected(-1, -1);
context.continueDestSegments = context.updateSegments = updateSegments;
forkContext.replaceHead(updateSegments);
@@ -1168,9 +1168,9 @@ CodePathState.prototype = {
* @returns {void}
*/
makeForBody: function() {
- let context = this.loopContext;
- let choiceContext = this.choiceContext;
- let forkContext = this.forkContext;
+ const context = this.loopContext;
+ const choiceContext = this.choiceContext;
+ const forkContext = this.forkContext;
// Update state.
if (context.updateSegments) {
@@ -1200,7 +1200,7 @@ CodePathState.prototype = {
* If there is not the `test` part, the `body` path comes from the
* `init` part and the `update` part.
*/
- let prevForkContext = ForkContext.newEmpty(forkContext);
+ const prevForkContext = ForkContext.newEmpty(forkContext);
prevForkContext.add(context.endOfInitSegments);
if (context.endOfUpdateSegments) {
@@ -1220,9 +1220,9 @@ CodePathState.prototype = {
* @returns {void}
*/
makeForInOfLeft: function() {
- let context = this.loopContext;
- let forkContext = this.forkContext;
- let leftSegments = forkContext.makeDisconnected(-1, -1);
+ const context = this.loopContext;
+ const forkContext = this.forkContext;
+ const leftSegments = forkContext.makeDisconnected(-1, -1);
// Update state.
context.prevSegments = forkContext.head;
@@ -1237,12 +1237,12 @@ CodePathState.prototype = {
* @returns {void}
*/
makeForInOfRight: function() {
- let context = this.loopContext;
- let forkContext = this.forkContext;
- let temp = ForkContext.newEmpty(forkContext);
+ const context = this.loopContext;
+ const forkContext = this.forkContext;
+ const temp = ForkContext.newEmpty(forkContext);
temp.add(context.prevSegments);
- let rightSegments = temp.makeNext(-1, -1);
+ const rightSegments = temp.makeNext(-1, -1);
// Update state.
context.endOfLeftSegments = forkContext.head;
@@ -1256,12 +1256,12 @@ CodePathState.prototype = {
* @returns {void}
*/
makeForInOfBody: function() {
- let context = this.loopContext;
- let forkContext = this.forkContext;
- let temp = ForkContext.newEmpty(forkContext);
+ const context = this.loopContext;
+ const forkContext = this.forkContext;
+ const temp = ForkContext.newEmpty(forkContext);
temp.add(context.endOfLeftSegments);
- let bodySegments = temp.makeNext(-1, -1);
+ const bodySegments = temp.makeNext(-1, -1);
// Make a path: `right` -> `left`.
makeLooped(this, forkContext.head, context.leftSegments);
@@ -1299,14 +1299,14 @@ CodePathState.prototype = {
* @returns {Object} The removed context.
*/
popBreakContext: function() {
- let context = this.breakContext;
- let forkContext = this.forkContext;
+ const context = this.breakContext;
+ const forkContext = this.forkContext;
this.breakContext = context.upper;
// Process this context here for other than switches and loops.
if (!context.breakable) {
- let brokenForkContext = context.brokenForkContext;
+ const brokenForkContext = context.brokenForkContext;
if (!brokenForkContext.empty) {
brokenForkContext.add(forkContext.head);
@@ -1327,13 +1327,13 @@ CodePathState.prototype = {
* @returns {void}
*/
makeBreak: function(label) {
- let forkContext = this.forkContext;
+ const forkContext = this.forkContext;
if (!forkContext.reachable) {
return;
}
- let context = getBreakContext(this, label);
+ const context = getBreakContext(this, label);
/* istanbul ignore else: foolproof (syntax error) */
if (context) {
@@ -1353,13 +1353,13 @@ CodePathState.prototype = {
* @returns {void}
*/
makeContinue: function(label) {
- let forkContext = this.forkContext;
+ const forkContext = this.forkContext;
if (!forkContext.reachable) {
return;
}
- let context = getContinueContext(this, label);
+ const context = getContinueContext(this, label);
/* istanbul ignore else: foolproof (syntax error) */
if (context) {
@@ -1388,7 +1388,7 @@ CodePathState.prototype = {
* @returns {void}
*/
makeReturn: function() {
- let forkContext = this.forkContext;
+ const forkContext = this.forkContext;
if (forkContext.reachable) {
getReturnContext(this).returnedForkContext.add(forkContext.head);
@@ -1405,7 +1405,7 @@ CodePathState.prototype = {
* @returns {void}
*/
makeThrow: function() {
- let forkContext = this.forkContext;
+ const forkContext = this.forkContext;
if (forkContext.reachable) {
getThrowContext(this).thrownForkContext.add(forkContext.head);
@@ -1418,7 +1418,7 @@ CodePathState.prototype = {
* @returns {void}
*/
makeFinal: function() {
- let segments = this.currentSegments;
+ const segments = this.currentSegments;
if (segments.length > 0 && segments[0].reachable) {
this.returnedForkContext.add(segments);