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 — [java] ConstructorCallsOverridableMethod should consider method calls… by adangel · Pull Request #4101 · pmd/pmd

Conversation

@adangel

@adangel adangel commented Aug 24, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

… with var access

  • Fixes [java] ConstructorCallsOverridableMethod should consider method calls with var access #4099
  • Fixes [java] ConstructorCallsOverridableMethod false positive when calling super method #1718
  • Fixes [java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined #2348

The rule ConstructorCallsOverridableMethod now:

  • finds method calls with parameters more reliably -> this adds new violations (fixes the false negative in [java] ConstructorCallsOverridableMethod should consider method calls with var access #4099)
  • reports for indirect calls (method chains) the found call stack - allowing to understand the message better
  • ignores method calls on super - there the problem that an unknown subclass would override the method isn't given. At the time you write the code, your superclass is known. The rule previously noticed some super method calls, but not all. Now all super method calls are ignored. (fixes [java] ConstructorCallsOverridableMethod false positive when calling super method #1718)

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
@adangel
[java] ConstructorCallsOverridableMethod should consider method calls…
292ec89
… with var access

Fixes pmd#4099
@adangel adangel added this to the 6.49.0 milestone Aug 24, 2022
@ghost

ghost commented Aug 24, 2022 •
edited by ghost
Loading

Uh oh!

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

Copy link
Copy Markdown
1 Message
📖 Compared to master:
This changeset changes 25 violations,
introduces 82 new violations, 0 new errors and 0 new configuration errors,
removes 16 violations, 0 errors and 0 configuration errors.
Full report
✅ Compared to master:
This changeset changes 25 violations,
introduces 82 new violations, 0 new errors and 0 new configuration errors,
removes 16 violations, 0 errors and 0 configuration errors.
Full report
✅ Compared to master:
This changeset changes 25 violations,
introduces 82 new violations, 0 new errors and 0 new configuration errors,
removes 16 violations, 0 errors and 0 configuration errors.
Full report
✅ Compared to master:
This changeset changes 6 violations,
introduces 82 new violations, 0 new errors and 0 new configuration errors,
removes 16 violations, 0 errors and 0 configuration errors.
Full report
✅ Compared to master:
This changeset changes 6 violations,
introduces 78 new violations, 0 new errors and 0 new configuration errors,
removes 21 violations, 2 errors and 6 configuration errors.
Full report
✅ Compared to master:
This changeset changes 5 violations,
introduces 60 new violations, 0 new errors and 0 new configuration errors,
removes 38 violations, 2 errors and 6 configuration errors.
Full report
✅ Compared to master:
This changeset changes 2 violations,
introduces 28 new violations, 0 new errors and 0 new configuration errors,
removes 48 violations, 2 errors and 6 configuration errors.
Full report
✅ Compared to master:
This changeset changes 0 violations,
introduces 20 new violations, 0 new errors and 0 new configuration errors,
removes 204 violations, 2 errors and 6 configuration errors.
Full report

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

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

@adangel

This comment was marked as outdated.

Sign in to view
adangel added 7 commits August 24, 2022 12:18
@adangel
Fix handling of reference types
bc21be4
@adangel
Fix False positive with public method call on new instance
596f129
@adangel
Fix handling of array types
64675dc
@adangel
Fix handling of varargs
a4afb59
@adangel
Support subtyping
5f0cb7d
@adangel
Fix NPE
f58719f
@adangel
Fix PMD - unused local variables
e3145b0
@adangel

adangel commented Aug 30, 2022

Copy link
Copy Markdown
Member Author

We should maybe not merge this in this state yet: It introduces some false negatives now, e.g. https://github.com/spring-projects/spring-framework/blob/v5.3.13/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java#L230 is not detected anymore now...

All reactions

Sorry, something went wrong.

Uh oh!

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

@adangel adangel removed this from the 6.49.0 milestone Aug 30, 2022
@adangel
Merge branch 'master' into issue-4099-constructorcallsoverridable
adec817
@adangel adangel self-assigned this Sep 27, 2022
@adangel adangel added this to the 6.50.0 milestone Sep 27, 2022
adangel added 4 commits September 27, 2022 20:55
@adangel
[java] ConstructorCallsOverridableMethod - fix false negatives
b59ceb6
- Use type of the method call result
- Do not consider super method calls,
  but this references
@adangel
[java] ConstructorCallsOverridableMethod - fix false negatives
d94a943
- Identify method calls of generic methods
@adangel
[java] ConstructorCallsOverridableMethod - improve message for call c…
5840afe
…hains
@adangel
[java] ConstructorCallsOverridableMethod - fix message for call chains
d21a562
First method in the chain was missing
@adangel

adangel commented Sep 29, 2022

Copy link
Copy Markdown
Member Author

Ok, this is finally ready.

The rule now:

  • finds method calls with parameters more reliably -> this adds new violations (fixes the false negative in [java] ConstructorCallsOverridableMethod should consider method calls with var access #4099)
  • reports for indirect calls (method chains) the found call stack - allowing to understand the message better
  • ignores method calls on super - there the problem that an unknown subclass would override the method isn't given. At the time you write the code, your superclass is known. The rule previously noticed some super method calls, but not all. Now all super method calls are ignored.
All reactions

Sorry, something went wrong.

Uh oh!

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

@adangel
[doc] Update release notes (pmd#1718, pmd#2348)
defb0cd
@adangel
adangel merged commit 7d58fc8 into pmd:master Sep 30, 2022
@adangel
adangel deleted the issue-4099-constructorcallsoverridable branch September 30, 2022 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

@adangel adangel

Labels

None yet

Projects

None yet

Milestone

6.50.0

Development

Successfully merging this pull request may close these issues.

[java] ConstructorCallsOverridableMethod should consider method calls with var access [java] ConstructorCallsOverridableMethod occurs when unused overloaded method is defined [java] ConstructorCallsOverridableMethod false positive when calling super method

Uh oh!

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

1 participant

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