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 — [apex] Fix for #3568 - Added new configuration properties reportEmptyPrivateNoArgConstructor and reportEmptyVirtualMethod to EmptyStatementBlock by SCWells72 · Pull Request #3573 · pmd/pmd

Conversation

@SCWells72

@SCWells72 SCWells72 commented Oct 20, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Describe the PR

Added two new configuration properties to the Apex EmptyStatementBlock rule:

  • reportEmptyPrivateNoArgConstructor that when set to false ignores empty private no-arg constructors that are commonly used in singleton pattern implementations and utility classes in support of prescribed best practices.
  • reportEmptyVirtualMethod that when set to false ignores empty virtual methods that are commonly used in abstract base classes as default no-op implementations when derived classes typically only override a subset of virtual methods.

Note that I had to add ASTModifierNode#isVirtual to expose usage of the virtual modifier for use in XPath-based rules, and I had to update the SafeNavigationOperator.txt snapshot to include @Virtual = false in all ModifierNode tree nodes.

Related issues

  • Fixes [apex] EmptyStatementBlock: should provide options to ignore empty private constructors and empty virtual methods #3568

Ready?

  • 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
SCWells72 added 2 commits October 20, 2021 13:15
@SCWells72
Issue 3568 - Added a new configuration property, 'reportEmptyPrivateN…
ff6c178
…oArgConstructor', that if set to false (default is true if unspecified) doesn't report an issue for empty private no-arg constructors that are commonly used in singleton and utility class implementations according to respective best practices.
@SCWells72
Issue 3568 - Added a new configuration property, 'reportEmptyVirtualM…
ddd310e
…ethod', that if set to false (default is true if unspecified) doesn't report an issue for empty virtual methods that are commonly used in abstract base classes as default no-op implementations when partial override/specialization is typical in derived classes.
@SCWells72 SCWells72 changed the title [apex] Fix for #3558 - Added new configuration properties reportEmptyPrivateNoArgConstructor and reportEmptyVirtualMethod to EmptyStatementBlock [apex] Fix for #3568 - Added new configuration properties reportEmptyPrivateNoArgConstructor and reportEmptyVirtualMethod to EmptyStatementBlock Oct 20, 2021
rsoesemann
rsoesemann reviewed Oct 21, 2021
View reviewed changes

@rsoesemann rsoesemann 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.

You rock @SCWells72. Thanks for adding all those pragmatic, less-effort, and backward-compatible changes to PMD Apex. I looked at all of them and can wholeheartedly approve them BUT as approving is merging and kicking of a few processes I want to wait for feedback from @oowekyala / @adangel.

  1. How should we proceed here and the other PRs by Scott?
  2. Merge and plan in for the next Minor?
  3. Should @SCWells72 add a PR to describe the changes in the Documentation repo as well?
  4. Or 7.0 as we add params to existing rules? I would hope to get all those changes out sooner than 7.0.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rsoesemann rsoesemann assigned oowekyala and unassigned oowekyala Oct 21, 2021
@rsoesemann rsoesemann added a:false-positive PMD flags a piece of code that is not problematic an:enhancement An improvement on existing features / rules labels Oct 21, 2021
@rsoesemann rsoesemann added this to the 6.40.0 milestone Oct 21, 2021
rsoesemann
rsoesemann reviewed Oct 21, 2021
View reviewed changes

@rsoesemann rsoesemann left a comment •
edited
Loading

Uh oh!

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

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.

.

Sorry, something went wrong.

Uh oh!

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

All reactions
adangel
adangel approved these changes Oct 22, 2021
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, looks good!

Sorry, something went wrong.

Uh oh!

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

All reactions
@ghost

ghost commented Oct 22, 2021

Copy link
Copy Markdown
1 Message
📖 No java rules are changed!

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

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

@adangel adangel self-assigned this Oct 22, 2021
rsoesemann
rsoesemann approved these changes Oct 22, 2021
View reviewed changes
rsoesemann
rsoesemann requested changes Oct 22, 2021
View reviewed changes

@rsoesemann rsoesemann 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.

@SCWells72 can you also add documentation changes to the same PR?

Sorry, something went wrong.

Uh oh!

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

All reactions
@SCWells72

SCWells72 commented Oct 22, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

@rsoesemann Based on the discussions in other PRs, it seems like this one is already whole as it contains the following in the actual rule definition XML:

<property name="reportEmptyPrivateNoArgConstructor" type="Boolean" value="true" description="If false, empty private no-arg constructors are not flagged. This supports a common idiom used by singleton pattern implementations, utility classes, etc."/>
<property name="reportEmptyVirtualMethod" type="Boolean" value="true" description="If false, empty virtual methods are not flagged. This supports abstract base classes with default no-op implementations."/>

That should be used in the auto-generated documentation, correct? Or is there something else I need to add for documentation?

rsoesemann 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.

@rsoesemann
rsoesemann merged commit 142b857 into pmd:master Oct 22, 2021
adangel added a commit that referenced this pull request Oct 23, 2021
@adangel
[doc] Update release notes (#3568, #3573)
38d60e2
@SCWells72
SCWells72 deleted the pmd-3568 branch October 23, 2021 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rsoesemann rsoesemann rsoesemann requested changes
@adangel adangel adangel approved these changes

Uh oh!

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

Assignees

@adangel adangel

Labels

a:false-positive PMD flags a piece of code that is not problematic an:enhancement An improvement on existing features / rules

Projects

None yet

Milestone

6.40.0

Development

Successfully merging this pull request may close these issues.

[apex] EmptyStatementBlock: should provide options to ignore empty private constructors and empty virtual methods

Uh oh!

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

4 participants

@SCWells72 @adangel @rsoesemann @oowekyala
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.