GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@judepereira judepereira commented Aug 2, 2025 •
edited by adangel
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

  • Fix #

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.

All reactions
judepereira added 2 commits August 2, 2025 16:59
@judepereira
Add begin and end for line and columns (default off).
6d25599
@judepereira
Remove wildcard import.
4f425c4
@adangel 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
adangel
adangel reviewed Aug 7, 2025
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

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.

All reactions
@judepereira

judepereira commented Aug 15, 2025

Copy link
Copy Markdown
Contributor Author

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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel

adangel commented Aug 15, 2025

Copy link
Copy Markdown
Member

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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

judepereira added 4 commits August 20, 2025 09:49
@judepereira
Refactor CSVRenderer to use an enum for optional columns and add tests.
48fac35
@judepereira
Document new optional columns for CSV.
c81a25c
@judepereira
Fix formatting.
13e1fe2
@judepereira
Reuse existing enum.
7afe3ed
@judepereira
judepereira requested a review from adangel August 20, 2025 08:08
@adangel adangel added the an:enhancement An improvement on existing features / rules label Sep 9, 2025
@adangel
Merge branch 'main' into pr-5958
7576c3f
@adangel adangel added this to the 7.17.0 milestone Sep 9, 2025
@adangel
[core] Simplify CSVRenderer
62c2f47
adangel
adangel approved these changes Sep 9, 2025
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

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.

All reactions
Comment thread pmd-core/src/main/java/net/sourceforge/pmd/renderers/ColumnDescriptor.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pmd-actions-helper

pmd-actions-helper Bot commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

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)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adangel added a commit that referenced this pull request Sep 9, 2025
@adangel
[doc] Update release notes (#5958)
c022ee0
adangel added a commit that referenced this pull request Sep 9, 2025
@adangel
[core] CSVRenderer: Add begin and end for line and columns (default o…
17becf5
…ff) (#5958)

Merge pull request #5958 from judepereira:main
@adangel
adangel merged commit 62c2f47 into pmd:main Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adangel adangel adangel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

an:enhancement An improvement on existing features / rules

Projects

None yet

Milestone

7.17.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@judepereira @adangel
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.