Skip to content

Conversation

@gsilvasimoesPT
Copy link

@gsilvasimoesPT gsilvasimoesPT commented Sep 5, 2025

This check enforces that default methods in immutable interfaces are
annotated with @Value.Default to ensure they are included as fields in
the generated immutable classes.

  • Detects default methods in @Value.Immutable interfaces
  • Handles @Value.Style(defaultAsDefault = true) configurations
  • Supports meta-annotations with @Value.Style
  • Provides automatic fixes to add missing @Value.Default annotations
  • Can be suppressed when methods are auxiliary and not meant as fields

This check enforces that default methods in immutable interfaces are
annotated with @Value.Default to ensure they are included as fields in
the generated immutable classes.

Key features:
- Detects default methods in @Value.Immutable interfaces
- Handles @value.Style(defaultAsDefault = true) configurations
- Supports meta-annotations with @value.Style
- Provides automatic fixes to add missing @Value.Default annotations
- Can be suppressed when methods are auxiliary and not meant as fields
- Add README.md entry documenting the new check
- Add link and linkType to BugPattern annotation
The documentation now explicitly mentions that the check is disabled when
@value.Style(defaultAsDefault = true) is present either directly on the
interface or via meta-annotations, making it clear to users that they
can use this approach to avoid the check.
@changelog-app
Copy link

changelog-app bot commented Sep 5, 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

Add ImmutablesDefaultValue error-prone check

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app
Copy link

changelog-app bot commented Sep 5, 2025

Successfully generated changelog entry!

What happened?

Your changelog entries have been stored in the database as part of our migration to ChangelogV3.

Need to regenerate?

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

@gsilvasimoesPT gsilvasimoesPT marked this pull request as ready for review September 5, 2025 16:33
Copy link
Member

@pkoenig10 pkoenig10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are legitimate reason to want a default method that is not @Value.Default. It may be a cheap computation for which we do not want to create a field that eagerly computes the value.

@stale
Copy link

stale bot commented Oct 18, 2025

This PR has been automatically marked as stale because it has not been touched in the last 14 days. If you'd like to keep it open, please leave a comment or add the 'long-lived' label, otherwise it'll be closed in 7 days.

@stale stale bot added the stale label Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants