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

up-to-date checking on npm-based steps is too generous #2140

Open
2 tasks done
nedtwigg opened this issue May 25, 2024 · 2 comments
Open
2 tasks done

up-to-date checking on npm-based steps is too generous #2140

nedtwigg opened this issue May 25, 2024 · 2 comments
Assignees
Labels

Comments

@nedtwigg
Copy link
Member

If you are submitting a bug, please include the following:

  • summary of problem

The npm-based steps don't capture their settings files in their state, which makes them too generous in claiming to be up-to-date. This applies to:

  • ESLintFormatterStep
  • PrettierFormatterStep
  • TsFmtFormatterStep.

This bug was introduced in #2135 as part of the effort to make all steps roundtrip-serializable for Gradle.

  • spotless version
    plugin-gradle 7.0, plugin-maven 3.0
@simschla
Copy link
Contributor

@nedtwigg Do you have a plan / an idea / an example on how to approach this so that it fits the "greater plan"?

@nedtwigg
Copy link
Member Author

If there's a settings file that you want to capture for up-to-date checks, the mechanism for that has been, and still is, FileSignature.

The problem is that FileSignature does not support roundtrip serialization. The fix for this is the new FileSignature.Promised. The .Promised class supports roundtrip serialization, but it does not support equality. So now a step has two states: RoundtripState and EqualityState.

They look like this overall:

class SomeRoundtripState implements Serializable {
  FileSignature.Promised settingsFile

  public SomeEqualityState toEquality() {
    return new SomeEqualityState(this)
  }
}

class SomeEqualityState implements Serializable {
  FileSignature settingsFile
}

That is super annoying, but roundtrip serialization means that all our transient tricks for ignoring something for equality don't work anymore.

Another option is to just implement FormatterStep directly. Implement Serializable and equals/hashCode on your own, instead of relying on the equality-based-on-serialization hack that we have used in the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants