You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,6 @@ Here's a checklist for creating a new step for Spotless:
93
93
-[ ] Class name ends in Step, `SomeNewStep`.
94
94
-[ ] Class has a public static method named `create` that returns a `FormatterStep`.
95
95
-[ ] Has a test class named `SomeNewStepTest` that uses `StepHarness` or `StepHarnessWithFile` to test the step.
96
-
-[ ] Start with `StepHarness.forStep(myStep).supportsRoundTrip(false)`, and then add round trip support as described in the next section.
97
96
-[ ] Test class has test methods to verify behavior.
98
97
-[ ] Test class has a test method `equality()` which tests equality using `StepEqualityTester` (see existing methods for examples).
99
98
@@ -137,6 +136,15 @@ There are many great formatters (prettier, clang-format, black, etc.) which live
137
136
138
137
Because of Spotless' up-to-date checking and [git ratcheting](https://github.com/diffplug/spotless/tree/main/plugin-gradle#ratchet), Spotless actually doesn't have to call formatters very often, so even an expensive shell call for every single invocation isn't that bad. Anything that works is better than nothing, and we can always speed things up later if it feels too slow (but it probably won't).
139
138
139
+
## Lints
140
+
141
+
Spotless is primarily a formatter, not a linter. But, if something goes wrong during formatting, it's better to model that as a lint with line numbers rather than just a naked exception. There are two ways to go about this:
142
+
143
+
- at any point during the formatting process, you can throw a `Lint.atLine(int line, ...)` exception. This will be caught and turned into a lint.
144
+
- or you can override the `default List<Lint> lint(String content, File file)` method. This method will only run if the step did not already throw an exception.
145
+
146
+
Don't go lint crazy! By default, all lints are build failures. Users have to suppress them explicitly if they want to continue.
0 commit comments