While testing pmd-github-action I've seen that GitHub adds the code annotations obviously at the reported end line.
This shows has some surprising result, e.g. for AvoidCatchingThrowable:

The "Throwable" that is caught is on line 13, the catch block is lines 13-15. It seems that this rule reports begin line 13 and end line 15 and GitHub annotates line 15.
There are other rules with similar problems (list is incomplete!)
Describe the solution you'd like
The test framework currently can check the begin line (expected-linenumbers). It should be enhanced, so that end line can also be verified.
Then all rules should be reviewed, test cases should be updated and the rules should be corrected.
Describe alternatives you've considered
I thought about changing pmd-github-action to pass only begin-line or pass begin-line as end-line, so that the annotations appear on the "correct" line. However, I think, GitHub made a sensible decision to use the end-line and display the annotation at the end. This makes sense, if the violation actually applies to a whole block. So, I'd rather fix the rules than workaround how GitHub works.
While testing pmd-github-action I've seen that GitHub adds the code annotations obviously at the reported end line.
This shows has some surprising result, e.g. for AvoidCatchingThrowable:
The "Throwable" that is caught is on line 13, the catch block is lines 13-15. It seems that this rule reports begin line 13 and end line 15 and GitHub annotates line 15.
There are other rules with similar problems (list is incomplete!)
Describe the solution you'd like
The test framework currently can check the begin line (
expected-linenumbers). It should be enhanced, so that end line can also be verified.Then all rules should be reviewed, test cases should be updated and the rules should be corrected.
Describe alternatives you've considered
I thought about changing pmd-github-action to pass only begin-line or pass begin-line as end-line, so that the annotations appear on the "correct" line. However, I think, GitHub made a sensible decision to use the end-line and display the annotation at the end. This makes sense, if the violation actually applies to a whole block. So, I'd rather fix the rules than workaround how GitHub works.