Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
yassin-kammoun-sonarsource committed Feb 8, 2024
1 parent c50c6b2 commit 4c3ba34
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/rules/cognitive-complexity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ const rule: TSESLint.RuleModule<string, (number | 'metric' | 'sonar-runtime')[]>
context.report({
node,
messageId: 'fileComplexity',
data: { complexityAmount: programComplexity.complexityPoints.reduce((acc, cur) => acc + cur.complexity, 0) },
data: {
complexityAmount: programComplexity.complexityPoints.reduce(
(acc, cur) => acc + cur.complexity,
0,
),
},
});
}
},
Expand Down Expand Up @@ -163,12 +168,15 @@ const rule: TSESLint.RuleModule<string, (number | 'metric' | 'sonar-runtime')[]>
};

function onEnterFunction(node: TSESTree.FunctionLike) {
scopes.push({ node, nestingLevel: 0, nestingNodes: new Set(), complexityPoints: []});
scopes.push({ node, nestingLevel: 0, nestingNodes: new Set(), complexityPoints: [] });
}

function onLeaveFunction(node: TSESTree.FunctionLike) {
const functionComplexity = scopes.pop()!;
checkFunction(functionComplexity.complexityPoints, getMainFunctionTokenLocation(node, node.parent, context));
checkFunction(
functionComplexity.complexityPoints,
getMainFunctionTokenLocation(node, node.parent, context),
);
}

function visitIfStatement(ifStatement: TSESTree.IfStatement) {
Expand Down

0 comments on commit 4c3ba34

Please sign in to comment.