Skip to content

Commit 212129f

Browse files
committed
square brackets pause a sequence
1 parent 51c8df6 commit 212129f

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/cognitive-complexity/node-inspection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export function breaksASequenceOfBinaryOperators(node: ts.Node) {
160160
export function pausesASequenceOfBinaryOperators(node: ts.Node) {
161161
return ts.isCallLikeExpression(node)
162162
|| ts.isPrefixUnaryExpression(node)
163+
|| ts.isElementAccessExpression(node)
163164
}
164165

165166
/**

test/cases/03-logical-operators.expected.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"03-logical-operators.ts": {
3-
"score": 30,
3+
"score": 32,
44
"inner": [
55
{
66
"name": "allAnd",
@@ -119,6 +119,12 @@
119119
"column": 9
120120
}]
121121
}]
122+
},
123+
{
124+
"name": "squareBrackets",
125+
"score": 2,
126+
"column": 1,
127+
"line": 82
122128
}
123129
]
124130
}

test/cases/03-logical-operators.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ function allOtherBreaksInSequenceOfOperators(param = true && true) {
7878
}
7979
}
8080
}
81+
82+
function squareBrackets() {
83+
Math.random() && {}[Math.random() && Math.random()] && Math.random()
84+
}

0 commit comments

Comments
 (0)