Closed calda closed 2 months ago
Attention: Patch coverage is 84.61538%
with 2 lines
in your changes are missing coverage. Please review.
Project coverage is 95.17%. Comparing base (
906a222
) to head (3c4adb3
).
Files | Patch % | Lines |
---|---|---|
Sources/CommandLine.swift | 84.61% | 2 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR adds a new
--strict
option that causes SwiftFormat to emit a non-zero exit code if it applies any formatting changes.Within Airbnb we want our tooling to be able to detect when running SwiftFormat applies formatting changes. Historically we've done this by running SwiftFormat twice: once with
--lint
to determine whether or not there are changes needing formatting, and then again without--lint
. This isn't very efficient since it requires running SwiftFormat twice, so instead we'd like to just run SwiftFormat a single time. A--strict
option is really helpful for this.I experimented with adding a test for this in
CommandLineTests
, but after some tinkering didn't find an easy way to set up the test case. I see there's no test case for the--lenient
flag for example. Happy to revist this if you'd like.I have confirmed that this functionality works in an executable build, and validated that it unlocks the workflow that we're interested in using within Airbnb.