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

EI_EXPOSE_REP2: Inconsistent reporting #603

Closed
sco0ter opened this issue Mar 30, 2018 · 3 comments
Closed

EI_EXPOSE_REP2: Inconsistent reporting #603

sco0ter opened this issue Mar 30, 2018 · 3 comments
Labels

Comments

@sco0ter
Copy link

sco0ter commented Mar 30, 2018

EI_EXPOSE_REP2 is correctly reported when using this:

public Foo(byte[] bytes) {
    this.bytes = bytes;
}

but it's not reported when using this:

public Foo(byte[] bytes) {
    this.bytes = Objects.requireNonNull(bytes);
}

Expected behavior: EI_EXPOSE_REP2 is reported in both cases, because it's essentially the same.

Spotbugs Version: 3.1.3

@KengoTODA
Copy link
Member

Spotbugs Version: 3.1.3

Do you mean 3.1.2? For now 3.1.3 is not released yet.

@KengoTODA KengoTODA added the bug label Apr 2, 2018
@sco0ter
Copy link
Author

sco0ter commented Apr 2, 2018

I mean the Maven plugin:
https://mvnrepository.com/artifact/com.github.spotbugs/spotbugs-maven-plugin/3.1.3

I assumed the versioning of the Maven plugin is consistent with the versioning of SpotBugs.

@KengoTODA
Copy link
Member

This is because OpcodeStack.Item#isInitialParameter() returns false for Objects.requireNonNull(bytes). See FindReturnRef#isPotentialCapture() for detail.

I think we can fix not FindReturnRef but OpcodeStack#sawOpcode().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants