Reformat code idents and introduce the SwiftFormat linter (#339)

* Package.swift: add SwiftFormat

Can be invoked with "swift package plugin swiftformat".

* $ swift package plugin swiftformat

* .cirrus.yml: run SwiftFormat

* SwiftFormat: exclude Sources/tart/OCI/Reference/Generated
This commit is contained in:
Nikolay Edigaryev 2022-11-29 19:56:13 +04:00 committed by GitHub
parent c27d4a089c
commit ad9c3c661e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 685 additions and 657 deletions

View File

@ -22,6 +22,18 @@ task:
path: "integration-tests/pytest-junit.xml" path: "integration-tests/pytest-junit.xml"
format: junit format: junit
task:
name: Lint
alias: lint
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-xcode:latest
lint_script:
- swift package plugin --allow-writing-to-package-directory swiftformat --cache ignore --lint --report swiftformat.json .
always:
swiftformat_report_artifacts:
path: swiftformat.json
format: swiftformat
task: task:
name: Build name: Build
alias: build alias: build
@ -37,6 +49,7 @@ task:
name: Release name: Release
only_if: $CIRRUS_TAG != '' only_if: $CIRRUS_TAG != ''
depends_on: depends_on:
- lint
- test - test
- build - build
macos_instance: macos_instance:

5
.swiftformat Normal file
View File

@ -0,0 +1,5 @@
--disable all
--enable indent
--indent 2
--exclude Sources/tart/OCI/Reference/Generated
--swiftversion 5.7

View File

@ -98,6 +98,15 @@
"revision" : "6190d0cefff3013e77ed567e6b074f324e5c5bf5", "revision" : "6190d0cefff3013e77ed567e6b074f324e5c5bf5",
"version" : "6.3.1" "version" : "6.3.1"
} }
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "7c7dd06554a5fc3f452f1d16a780a81a3be04bce",
"version" : "0.50.4"
}
} }
], ],
"version" : 2 "version" : 2

View File

@ -18,6 +18,7 @@ let package = Package(
.package(url: "https://github.com/sushichop/Puppy", from: "0.5.1"), .package(url: "https://github.com/sushichop/Puppy", from: "0.5.1"),
.package(url: "https://github.com/antlr/antlr4", branch: "dev"), .package(url: "https://github.com/antlr/antlr4", branch: "dev"),
.package(url: "https://github.com/apple/swift-atomics.git", .upToNextMajor(from: "1.0.0")), .package(url: "https://github.com/apple/swift-atomics.git", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.50.4"),
], ],
targets: [ targets: [
.executableTarget(name: "tart", dependencies: [ .executableTarget(name: "tart", dependencies: [