Skip to content

Conversation

@shamith09
Copy link

@shamith09 shamith09 commented Dec 9, 2025

Copied from palantir/gradle-baseline#3270

Before this PR

This check doesn't ignore static fields, so it emits a warning even in cases like these:

public record SomeRecord(String foo) {
    public static final String[] SOME_CONSTANT = new String[] { "foo", "bar" };
}

Static fields are not compared in .equals, so this code is safe and does not exhibit any weird behavior unless there is also a non-static array field in the record. In this example, we should expect instances of SomeRecord to be equal if their foo fields are equal.

After this PR

Static fields are ignored in this check. The presence of non-static array fields still triggers the warning.

==COMMIT_MSG==
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Dec 9, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Ignore static variables in record array field check

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app
Copy link

changelog-app bot commented Dec 9, 2025

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

🐛 Fixes

  • Ignore static variables in record array field check (#24)

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