Skip to content

Commit d0eb34d

Browse files
authored
Disable new swiftformat rule (#936)
Motivation: - SwiftFormat added a new rule but was pinned to an older version; this makes it harder for contributors to resolve issues. Modifications: - Disable the new rule - Build the most recent formatter version; emit the version when running the script - Run the lint check verbosely Result: - Less pain when new rules are added
1 parent d3f039d commit d0eb34d

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

.swiftformat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@
2424
# treated as a trailing closure. This is relevant because the service provider
2525
# API for client streaming RPCs has this exact shape.
2626
--disable trailingClosures
27+
28+
# Don't wrap the opening brace of multiline statements.
29+
--disable wrapMultilineStatementBraces

.travis-install.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ PROTOBUF_VERSION=3.9.1
3737
# We need this to build gRPC C++ for the interop test server(s).
3838
BAZEL_VERSION=0.28.1
3939
GRPC_VERSION=1.23.0
40-
SWIFTFORMAT_VERSION=0.44.13
4140

4241
info() {
4342
printf '\033[0;34m%s\033[0m\n' "$1"
@@ -183,20 +182,21 @@ function install_swiftformat() {
183182
echo -en 'travis_fold:start:install.swiftformat\\r'
184183
info "Installing swiftformat"
185184

186-
if [ ! -f "$BIN_CACHE/swiftformat-$SWIFTFORMAT_VERSION" ]; then
187-
git clone -b "$SWIFTFORMAT_VERSION" --depth 1 "https://github.com/nicklockwood/SwiftFormat"
185+
git clone --depth 1 "https://github.com/nicklockwood/SwiftFormat"
186+
cd SwiftFormat
187+
version=$(git rev-parse HEAD)
188188

189+
if [ ! -f "$BIN_CACHE/swiftformat-$version" ]; then
189190
info "Building swiftformat"
190-
cd SwiftFormat
191191
swift build --product swiftformat
192192

193-
cp "$(swift build --show-bin-path)/swiftformat" "$BIN_CACHE/swiftformat-$SWIFTFORMAT_VERSION"
193+
cp "$(swift build --show-bin-path)/swiftformat" "$BIN_CACHE/swiftformat-$version"
194194
else
195-
info "Skipping download and build of SwiftFormat, using cached binaries"
195+
info "Skipping build of SwiftFormat, using cached binaries"
196196
fi
197197

198198
# We should have cached swiftformat now, copy it to $HOME/local/bin
199-
cp "$BIN_CACHE/swiftformat-$SWIFTFORMAT_VERSION" "$HOME"/local/bin/swiftformat
199+
cp "$BIN_CACHE/swiftformat-$version" "$HOME"/local/bin/swiftformat
200200

201201
success "Installed swiftformat"
202202
echo -en 'travis_fold:end:install.swiftformat\\r'

Tests/GRPCTests/FakeResponseStreamTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class FakeResponseStreamTests: GRPCTestCase {
201201

202202
private extension EmbeddedChannel {
203203
func verifyInbound<Inbound>(as: Inbound.Type = Inbound.self, _ verify: (Inbound) -> Void = { _ in
204-
}) {
204+
}) {
205205
do {
206206
if let inbound = try self.readInbound(as: Inbound.self) {
207207
verify(inbound)

scripts/sanity.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function check_license_headers() {
4343

4444
function check_formatting() {
4545
hash swiftformat 2> /dev/null || { printf "\033[0;31mERROR\033[0m swiftformat must be installed (see: https://github.com/nicklockwood/SwiftFormat)\n"; exit 1; }
46-
run_logged "Checking formatting" "swiftformat --lint $HERE/.."
46+
run_logged "Checking formatting (swiftformat $(swiftformat --version))" "swiftformat --lint --verbose $HERE/.."
4747
}
4848

4949
errors=0

0 commit comments

Comments
 (0)