Skip to content

Commit 493be99

Browse files
committed
Remove unconditional else blocks around return statements
1 parent ab1bc9b commit 493be99

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
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 & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +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
}
555+
return node;
557556
case TOK_NOT:
558557
right = this.expression(bindingPower.Not);
559558
return {type: "NotExpression", children: [right]};
@@ -587,9 +586,8 @@
587586
right = this._parseProjectionRHS(bindingPower.Star);
588587
return {type: "Projection",
589588
children: [{type: "Identity"}, right]};
590-
} else {
591-
return this._parseMultiselectList();
592589
}
590+
return this._parseMultiselectList();
593591
case TOK_CURRENT:
594592
return {type: TOK_CURRENT};
595593
case TOK_EXPREF:
@@ -621,12 +619,11 @@
621619
if (this._lookahead(0) !== TOK_STAR) {
622620
right = this._parseDotRHS(rbp);
623621
return {type: "Subexpression", children: [left, right]};
624-
} else {
625-
// Creating a projection.
626-
this._advance();
627-
right = this._parseProjectionRHS(rbp);
628-
return {type: "ValueProjection", children: [left, right]};
629622
}
623+
// Creating a projection.
624+
this._advance();
625+
right = this._parseProjectionRHS(rbp);
626+
return {type: "ValueProjection", children: [left, right]};
630627
case TOK_PIPE:
631628
right = this.expression(bindingPower.Pipe);
632629
return {type: TOK_PIPE, children: [left, right]};
@@ -680,12 +677,11 @@
680677
if (token.type === TOK_NUMBER || token.type === TOK_COLON) {
681678
right = this._parseIndexExpression();
682679
return this._projectIfSlice(left, right);
683-
} else {
684-
this._match(TOK_STAR);
685-
this._match(TOK_RBRACKET);
686-
right = this._parseProjectionRHS(bindingPower.Star);
687-
return {type: "Projection", children: [left, right]};
688680
}
681+
this._match(TOK_STAR);
682+
this._match(TOK_RBRACKET);
683+
right = this._parseProjectionRHS(bindingPower.Star);
684+
return {type: "Projection", children: [left, right]};
689685
default:
690686
this._errorToken(this._lookaheadToken(0));
691687
}
@@ -862,18 +858,15 @@
862858
var matched, current, result, first, second, field, left, right, collected, i;
863859
switch (node.type) {
864860
case "Field":
865-
if (value === null ) {
866-
return null;
867-
} else if (isObject(value)) {
861+
if (value !== null && isObject(value)) {
868862
field = value[node.name];
869863
if (field === undefined) {
870864
return null;
871865
} else {
872866
return field;
873867
}
874-
} else {
875-
return null;
876868
}
869+
return null;
877870
case "Subexpression":
878871
result = this.visit(node.children[0], value);
879872
for (i = 1; i < node.children.length; i++) {

0 commit comments

Comments
 (0)