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

Any exception should break the build #72

Merged
merged 12 commits into from
Jan 20, 2017

Conversation

nedtwigg
Copy link
Member

Right now, if any exception is thrown by a FormatterStep, it will silently print a warning and that's it. This is a problem for two reasons:

  1. Before Spotless 3.x, the eclipse formatter would intermittently fail to due to classpath conflicts. It made sense to let these slip by so that Spotless would still be usable, but now with 3.x classloader isolation spotless is much more reliable - there's no longer any reason to let these slip by.

  2. With up-to-date checking, it's hard to get a second chance to see an error. This is especially troublesome for rules like FreshMark.

This PR makes any exceptions fail the build, along with a mechanism to allow a specific failure to sneak by. In order to implement this functionality, it also found and fixed some bugs to make Formatter fully support equals/hashCode/Serializable, and improved the tests.

…t about exceptions in its formatters. Default behavior matches the existing behavior.
…and equals/hashCode with the same constraints as SerializableFileFilter. Refactored the `toBytes()` method into the interface `NoLambda`, and moved `SerializableFileFilter.EqualityBasedOnSerialization` to `NoLambda.EqualityBasedOnSerialization`. Technically a breaking change, but will affect exactly zero real-world client code.
… issues we had in the non-GIT_ATTRIBUTES policies. Since GitAttributesLineEndings.Policy uses LazyForwardingEquality, it required LazyForwardingEquality to implement NoLambda.
…hCode(), which required some serialization tricks because Charset and Path are not serializable.
…ization. Turns out that it wasn't for FreshMarkStep, which has now been fixed.
…ForPath`, but by default any exceptions will kill the build.
Copy link
Member

@jbduncan jbduncan left a comment

Choose a reason for hiding this comment

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

Might it be worth bumping the version number for spotless-lib anyway, even if we only bump it from 1 to 1.1 instead of 2?

Edit: Ah sorry, I'm talking about the breaking change to spotless-lib's behaviour which you introduced in e36ddab .

@nedtwigg
Copy link
Member Author

We already shipped 1.0, and we've added some features (ktlint and scalafmt), so the next release will definitely be 1.1.

@nedtwigg nedtwigg force-pushed the feature/strictExceptions branch from 67ea815 to e279153 Compare January 18, 2017 17:18
@nedtwigg nedtwigg merged commit 23de01a into diffplug:master Jan 20, 2017
@nedtwigg nedtwigg deleted the feature/strictExceptions branch March 14, 2017 05:59
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