Skip to content

Conversation

@jmongeluzzi
Copy link

@jmongeluzzi jmongeluzzi commented May 5, 2025

There were several breaking changes between error-prone 2.31.0 and 2.38.0. This change should fix compatibility without affecting functionality.

Because this repo applies the gradle-baseline plugin to itself, error-prone fails on this change because of the same issue it is intended to fix. To work around this, I have disabled the affected error-prone checks temporarily and will re-enable them in a subsequent PR that bumps gradle-baseline to the latest version.

Also, a change in error-prone (google/error-prone#4699) means that patches are no longer applied to disabled checks, so I have commented out the test for this behavior. Restoring this behavior could be possible in the future via argument manipulation in https://github.com/palantir/suppressible-error-prone, but that is beyond the scope of this change.

==COMMIT_MSG==
Fix compatibility with error-prone 2.38.0.
==COMMIT_MSG==

@changelog-app
Copy link

changelog-app bot commented May 5, 2025

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

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

Description

Fix compatibility with errorprone 2.38.0.

Check the box to generate changelog(s)

  • Generate changelog entry

Comment on lines +86 to +90
return switch (tree.getKind()) {
case IDENTIFIER -> ((IdentifierTree) tree).getName().contentEquals("this");
case MEMBER_SELECT -> ((MemberSelectTree) tree).getIdentifier().contentEquals("this");
default -> false;
};
Copy link
Member

Choose a reason for hiding this comment

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

Can we please save unrelated refactors for a separate PR? It makes it hard to review this PR.

Copy link
Author

Choose a reason for hiding this comment

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

This was required by error prone checks on the repo. Would you prefer I suppress in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

Which check?

Copy link
Member

Choose a reason for hiding this comment

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

Oh this is a new one introduced in Error Prone.

https://errorprone.info/bugpattern/StatementSwitchToExpressionSwitch

Copy link
Contributor

Choose a reason for hiding this comment

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

We should work out if this (and any other introduced check) is something we want to disable, or are comfortable will a load of automated suppressions for them. Perhaps it has autofixes?

Copy link
Member

@pkoenig10 pkoenig10 May 7, 2025

Choose a reason for hiding this comment

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

Perhaps it has autofixes?

This check only reports a match if it has an auto-fix. So I think it should be fine to roll this out.

Copy link
Member

Choose a reason for hiding this comment

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

StringConcatToTextBlock also feels a bit 🌶️, but there are automated fixes for that too. And given that text blocks seem objectively better than string concatenation, I'm inclined to leave that one also.

@jmongeluzzi jmongeluzzi changed the title Fix compatibility with errorprone 2.38.0 Fix compatibility with error-prone 2.38.0 May 7, 2025
'''.stripIndent()
}
// As of https://github.com/google/error-prone/pull/4699, error prone no longer applies patches to disabled checks.
// Disabling this test since it is no longer valid and will require significant changes to restore the prior behavior.
Copy link
Member

Choose a reason for hiding this comment

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

Can you elaborate on this? Why do we need to disable this test?

Copy link
Author

Choose a reason for hiding this comment

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

Quoting from google/error-prone#4699 (comment)

❗ That said, my changes impact semantics ❗. Before the changes in this PR, Error Prone would ignore the -Xep:AssignmentUpdater:OFF flag and apply any suggestions by AssignmentUpdater. After my changes, AssignmentUpdater is ignored altogether.

Disabling a check results in it being set to OFF, so suggestions do not get applied.

Copy link
Member

Choose a reason for hiding this comment

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

This feels like something we need to address before merging this PR. A lot of our internal automation is built on Error Prone and applying suggested fixes.

@jmongeluzzi
Copy link
Author

Closing this as the scope of what is needed to merge this has expanded to include changes to other gradle plugins (see
#3101 (comment)). The workaround to exclude the affected checks is sufficient for my purposes.

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.

3 participants