Affects PMD Version: 6.54.0 and 7.0.0-rc1
Description:
When using the CognitiveComplexity rule for Java in PMD 6.54.0, the RuleViolation returns the line range covering the entire method, from the start to the end (e.g., 3-7 in the provided example). However, when using PMD 7.0.0-rc1, it only returns the line number of the method signature (e.g., 3-3 in the provided example).
Code Sample demonstrating the issue:
public class Example {
public void sampleMethod() { // Line 3
if (true) {
System.out.println("Hello, world!");
}
} // Line 7
}
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
- Run PMD 6.54.0 with the CognitiveComplexity rule on the provided code sample.
- Observe the RuleViolation line range covering the entire method (3-7).
- Run PMD 7.0.0-rc1 with the CognitiveComplexity rule on the same code sample.
- Observe the RuleViolation line range only covering the method signature (3-3).
Affects PMD Version: 6.54.0 and 7.0.0-rc1
Description:
When using the CognitiveComplexity rule for Java in PMD 6.54.0, the RuleViolation returns the line range covering the entire method, from the start to the end (e.g., 3-7 in the provided example). However, when using PMD 7.0.0-rc1, it only returns the line number of the method signature (e.g., 3-3 in the provided example).
Code Sample demonstrating the issue:
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.