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

Let StrictUnusedVariable ignore record fields #1602

Merged
merged 5 commits into from
Jan 7, 2021

Conversation

fawind
Copy link
Contributor

@fawind fawind commented Jan 6, 2021

Before this PR

Record fields were flagged as unused and had to be manually suppressed.

class Test {
  // without @SuppressWarnings("StrictUnusedVariable")	
  record Foo(int bar) {}

  static void method() {
    new Foo(1).bar()
  }
}

throws: error: [StrictUnusedVariable] The field 'bar' is never read.

After this PR

Flup on #1412 and #1414 now that error prone has better support for records.

Ignore record fields when checking for unused variables as only the record's getter-methods might be used.

Note that checking for the actual unused record class is done with the UnusedNestedClass check.

==COMMIT_MSG==
Let StrictUnusedVariable ignore record fields
==COMMIT_MSG==

@changelog-app
Copy link

changelog-app bot commented Jan 6, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Let StrictUnusedVariable ignore record fields

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from iamdanfox January 6, 2021 20:01
@fawind fawind requested a review from ferozco January 6, 2021 20:01
@fawind fawind changed the title Ignore unused record fields Let StrictUnusedVariable ignore record fields Jan 6, 2021
@fawind fawind merged commit 903308d into develop Jan 7, 2021
@fawind fawind deleted the fw/ignore-unused-record-field branch July 15, 2021 10:41
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 this pull request may close these issues.

2 participants