Skip to content

Commit 54478af

Browse files
authored
Merge pull request #31 from jeskew/basarat-patch-1
Remove unreachable code
2 parents a09644d + 493be99 commit 54478af

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
/yarn.lock

jmespath.js

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,8 @@
551551
var node = {type: "Field", name: token.value};
552552
if (this._lookahead(0) === TOK_LPAREN) {
553553
throw new Error("Quoted identifier not allowed for function names.");
554-
} else {
555-
return node;
556554
}
557-
break;
555+
return node;
558556
case TOK_NOT:
559557
right = this.expression(bindingPower.Not);
560558
return {type: "NotExpression", children: [right]};
@@ -588,10 +586,8 @@
588586
right = this._parseProjectionRHS(bindingPower.Star);
589587
return {type: "Projection",
590588
children: [{type: "Identity"}, right]};
591-
} else {
592-
return this._parseMultiselectList();
593589
}
594-
break;
590+
return this._parseMultiselectList();
595591
case TOK_CURRENT:
596592
return {type: TOK_CURRENT};
597593
case TOK_EXPREF:
@@ -623,13 +619,11 @@
623619
if (this._lookahead(0) !== TOK_STAR) {
624620
right = this._parseDotRHS(rbp);
625621
return {type: "Subexpression", children: [left, right]};
626-
} else {
627-
// Creating a projection.
628-
this._advance();
629-
right = this._parseProjectionRHS(rbp);
630-
return {type: "ValueProjection", children: [left, right]};
631622
}
632-
break;
623+
// Creating a projection.
624+
this._advance();
625+
right = this._parseProjectionRHS(rbp);
626+
return {type: "ValueProjection", children: [left, right]};
633627
case TOK_PIPE:
634628
right = this.expression(bindingPower.Pipe);
635629
return {type: TOK_PIPE, children: [left, right]};
@@ -683,13 +677,11 @@
683677
if (token.type === TOK_NUMBER || token.type === TOK_COLON) {
684678
right = this._parseIndexExpression();
685679
return this._projectIfSlice(left, right);
686-
} else {
687-
this._match(TOK_STAR);
688-
this._match(TOK_RBRACKET);
689-
right = this._parseProjectionRHS(bindingPower.Star);
690-
return {type: "Projection", children: [left, right]};
691680
}
692-
break;
681+
this._match(TOK_STAR);
682+
this._match(TOK_RBRACKET);
683+
right = this._parseProjectionRHS(bindingPower.Star);
684+
return {type: "Projection", children: [left, right]};
693685
default:
694686
this._errorToken(this._lookaheadToken(0));
695687
}
@@ -866,19 +858,15 @@
866858
var matched, current, result, first, second, field, left, right, collected, i;
867859
switch (node.type) {
868860
case "Field":
869-
if (value === null ) {
870-
return null;
871-
} else if (isObject(value)) {
861+
if (value !== null && isObject(value)) {
872862
field = value[node.name];
873863
if (field === undefined) {
874864
return null;
875865
} else {
876866
return field;
877867
}
878-
} else {
879-
return null;
880868
}
881-
break;
869+
return null;
882870
case "Subexpression":
883871
result = this.visit(node.children[0], value);
884872
for (i = 1; i < node.children.length; i++) {

0 commit comments

Comments
 (0)