Skip to content

Commit

Permalink
feat(EC-515): Solve cognitive complexity sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ExalTomiche committed May 30, 2024
1 parent e188254 commit d75fbe9
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,27 @@ public void apply(ParseTree tree) {
}

if (importExist) {
if (tree instanceof Swift5Parser.ExpressionContext && tree.getText().contains("record()")) {
id = (Swift5Parser.ExpressionContext) tree;
audioRecorderStarted = true;
}
findStartedButNotStoppedAudioRecord(tree);
}
}

if (tree instanceof Swift5Parser.ExpressionContext
&& (tree.getText().contains("stop()"))) {
audioRecorderStopped = true;
}
private void findStartedButNotStoppedAudioRecord(ParseTree tree) {
if (tree instanceof Swift5Parser.ExpressionContext && tree.getText().contains("record()")) {
id = (Swift5Parser.ExpressionContext) tree;
audioRecorderStarted = true;
}

if (tree instanceof TerminalNodeImpl && tree.getText().equals("<EOF>")) {
if (audioRecorderStarted && !audioRecorderStopped) {
this.recordIssue(id.getStart().getStartIndex(), DEFAULT_ISSUE_MESSAGE);
}
audioRecorderStarted = false;
audioRecorderStopped = false;
importExist = false;
if (tree instanceof Swift5Parser.ExpressionContext && (tree.getText().contains("stop()"))) {
audioRecorderStopped = true;
}

if (tree instanceof TerminalNodeImpl && tree.getText().equals("<EOF>")) {
if (audioRecorderStarted && !audioRecorderStopped) {
this.recordIssue(id.getStart().getStartIndex(), DEFAULT_ISSUE_MESSAGE);
}
audioRecorderStarted = false;
audioRecorderStopped = false;
importExist = false;
}
}
}


}

0 comments on commit d75fbe9

Please sign in to comment.