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 // Noncompliant
comment and one comment with offset notation. // Noncompliant@+1 int x = "Hello".length(); // Noncompliant
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.