Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MS_EXPOSE_REP cannot detect nested class #2042

Closed
ghost opened this issue May 6, 2022 · 3 comments · Fixed by #3174
Closed

MS_EXPOSE_REP cannot detect nested class #2042

ghost opened this issue May 6, 2022 · 3 comments · Fixed by #3174

Comments

@ghost
Copy link

ghost commented May 6, 2022

Hi, I found a false negative about the rule MS_EXPOSE_REP. Please read the following case, SpotBugs should have reported a warning in line 5,but it doesn't. I think this is caused by the nest class. Thanks for your consideration.

public class C1 {
  private static String[] s2;
  public class C2 {
    public String[] getS2() {
      return s2;  // should report a warning here
    }
  }
}

Version: Latest

@ThrawnCA
Copy link
Contributor

ThrawnCA commented May 8, 2022

PMD should have reported

I think you mean SpotBugs?

@ghost
Copy link
Author

ghost commented May 9, 2022

@ThrawnCA Hi, sorry for the mistake. I have fixed it 😸

@baloghadamsoftware
Copy link
Contributor

Thank you for reporting this. I am just checking what I can do here.

baloghadamsoftware pushed a commit to baloghadamsoftware/spotbugs that referenced this issue May 18, 2022
…d buffers in nested and inner classes

Tihs patch fixes issue spotbugs#2042
baloghadamsoftware pushed a commit to baloghadamsoftware/spotbugs that referenced this issue May 18, 2022
…d buffers in nested and inner classes

Tihs patch fixes issue spotbugs#2042
baloghadamsoftware pushed a commit to baloghadamsoftware/spotbugs that referenced this issue May 18, 2022
…d buffers in nested and inner classes

Tihs patch fixes issue spotbugs#2042
hazendaz pushed a commit that referenced this issue Oct 31, 2024
…om Java 11 (#3174)

* Extend detector `FindReturnRef` to detect exposition of references and buffers in nested and inner classes

Tihs patch fixes issue #2042

* switch back the guard clause

* Rewrite the tests to the newer type

* Rename parameter

* Fix merge

* Remove unnecessary imports from tests

* Rename field to not match a restricted identifier

* Spotless apply

* fix changelog merge

* fix changelog after merge

* spelling fix

* small refactor

* revert changes to FindReturnRef detector

* fix EI_EXPOSE_REP2 FNs

* fix FNs and tests

* add testcase with multilevel nested classes

* move FindReturnRef code examples to exposemutable package

* fix issue

* rename FindReturnRef example classes

* fix unconnected issues in FindReturnRef examples + spotlessApply

---------

Co-authored-by: Ádám Balogh <[email protected]>
Co-authored-by: Balogh, Ádám <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants