Skip to content

Commit

Permalink
Add info to CONTRIBUTING
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Oct 17, 2024
1 parent a9bd0a6 commit 6c480d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Here's a checklist for creating a new step for Spotless:
- [ ] Class name ends in Step, `SomeNewStep`.
- [ ] Class has a public static method named `create` that returns a `FormatterStep`.
- [ ] Has a test class named `SomeNewStepTest` that uses `StepHarness` or `StepHarnessWithFile` to test the step.
- [ ] Start with `StepHarness.forStep(myStep).supportsRoundTrip(false)`, and then add round trip support as described in the next section.
- [ ] Test class has test methods to verify behavior.
- [ ] Test class has a test method `equality()` which tests equality using `StepEqualityTester` (see existing methods for examples).

Expand Down Expand Up @@ -137,6 +136,15 @@ There are many great formatters (prettier, clang-format, black, etc.) which live

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).

## Lints

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:

- 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.
- 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.

Don't go lint crazy! By default, all lints are build failures. Users have to suppress them explicitly if they want to continue.

## How to add a new plugin for a build system

The gist of it is that you will have to:
Expand Down

0 comments on commit 6c480d8

Please sign in to comment.