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

StrictUnusedVariable stuck on field that's assigned to but never read #2345

Closed
j-baker opened this issue Aug 3, 2022 · 1 comment
Closed

Comments

@j-baker
Copy link
Contributor

j-baker commented Aug 3, 2022

What happened?

I have some code which I'm trying to keep as identical as possible to some third party code (rewrite of an algorithm in Java).

So, I have a class like (simplified):

public final class ReFairSchedulableBuilder implements ReSchedulableBuilder {
    private final RePool rootPool;
    private final SparkContext sc;

    public ReFairSchedulableBuilder(RePool rootPool, SparkContext sc) {
        this.rootPool = rootPool;
        this.sc = sc;
    }

    @Override
    public void addTaskSetManager(ReTaskSetManager manager, Properties _properties) {
        rootPool.addSchedulable(manager);
    }
}

Here, I get caught by sc being unused. It recommends I should rename it to _sc.

 error: [StrictUnusedVariable] The field 'sc' is never read. Intentional occurrences are acknowledged by renaming the unused variable with a leading underscore. '_sc', for example.

If I apply that fix, I get:

error: [StrictUnusedVariable] The field '_sc' is read but has 'StrictUnusedVariable' suppressed because of its name.
    private final SparkContext _sc;

What did you want to happen?

I cannot see a read of this field (I assume it relates only to a write?). I expected one of the compilations to actually compile! I suppressed the check, but it feels like a bug/edge case/something.

@j-baker
Copy link
Contributor Author

j-baker commented Aug 29, 2022

Duplicate of #2361

@j-baker j-baker marked this as a duplicate of #2361 Aug 29, 2022
@j-baker j-baker closed this as completed Aug 29, 2022
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

No branches or pull requests

1 participant