I'm coding a custom rule for a Java. There are two Tree.KIND instances (STRING_LITERAL and ASSIGNMENT) to be captured. There is a particular line where both the logic of String Literal and Assignment throws an issue. But sonar test throws error saying
Unexpected at [Line number]
That particular line has the comment // Noncompliant to denote issue. But still the test case failed since the same error is caught by two different logic.
There are two options how to solve this
Noncompliant@+[offset]syntax, where[offset]is replaced by integer. This way you can indicate that line has two issues by using one// Noncompliantcomment and one comment with offset notation.// Noncompliant@+1 int x = "Hello".length(); // Noncompliant