GeezerVison is showing github.com — [core] CSVRenderer: Add begin and end for line and columns (default off) by judepereira · Pull Request #5958 · pmd/pmd
Conversation
judepereira
commented
Aug 2, 2025
•
edited by adangel
Loading
Uh oh!
There was an error while loading. Please reload this page.
Describe the PR
This PR exposes begin column, end column, begin line, and end line. For the sake of consistency and backwards compatibility, these new columns are off by default. Begin Line is a duplicate of Line, but with a different title, and therefore, it's exposed as a different property.
Note: This is about PMD Report format, not CPD.
Related issues
Ready?
Help required: Is there a framework to test these optional properties? I checked out CSVRendererTest, but couldn't find anything useful.
- Added unit tests for fixed bug/feature
- Passing all unit tests
- Complete build
./mvnw clean verify passes (checked automatically by github actions)
- Added (in-code) documentation (if needed)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
adangel
changed the title
Add begin and end for line and columns (default off).
[core] CSVRenderer: Add begin and end for line and columns (default off)
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Three questions:
- There is already the column "line", which is the begin line. Would it make sense to reuse this and only add "endLine", "beginCol", "endCol"?
- I would use the full name for the column names: beginCol -> beginColumn and endCol -> endColumn
- Could you please also update the documentation example with the new properties? -> https://docs.pmd-code.org/latest/pmd_userdocs_report_formats.html#csv
Help required: Is there a framework to test these optional properties? I checked out CSVRendererTest, but couldn't find anything useful.
There is no real framework, so it looks a bit ugly, but that's how you can unit test it (in CSVRendererTest):
@Test
void withColumnsBeginLine() throws Exception {
CSVRenderer renderer = new CSVRenderer();
renderer.setProperty((PropertyDescriptor<Boolean>) renderer.getPropertyDescriptor("endLine"), true);
String actual = renderReport(renderer, reportOneViolation(), Charset.defaultCharset());
String expected = "\"Problem\",\"Package\",\"File\",\"Priority\",\"Line\",\"Description\",\"Rule set\",\"Rule\",\"End Line\"" + EOL
+ "\"1\",\"\",\"" + getSourceCodeFilename() + "\",\"5\",\"1\",\"blah\",\"RuleSet\",\"Foo\",1" + EOL;
assertEquals(filter(expected), filter(actual));
}
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
hey @adangel, thanks for the review! let's clarify one open item:
There is already the column "line", which is the begin line. Would it make sense to reuse this and only add "endLine", "beginCol", "endCol"?
I thought of that too, but then the symmetry of "Line", "Begin Line", "End Line" is lost. Since I'm OK with either, I'll remove the new Begin Line.
I would use the full name for the column names: beginCol -> beginColumn and endCol -> endColumn
Will update shortly.
Could you please also update the documentation example with the new properties? -> https://docs.pmd-code.org/latest/pmd_userdocs_report_formats.html#csv
For sure!
|
adangel reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I thought of that too, but then the symmetry of "Line", "Begin Line", "End Line" is lost. Since I'm OK with either, I'll remove the new Begin Line.
You can sort the new columns directly after the existing "Line" column, so that the positional columns are together. Since they are disabled by default, this wouldn't break the format - and if you enable the columns, you anyway need to change the code to take the new columns into account.
|
judepereira reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updated PR and the test.
I'll fix the small things myself and merge it afterwards for 7.17.0.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Documentation Preview
Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Regression Tester Report
(comment created at 2025-09-09 18:20:36+00:00 for 62c2f47)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
adangel
adangel approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|