diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..253a65d1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,28 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Danger Swift + uses: maxdesiatov/danger-swift@swiftlint-docker + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dangerfile.swift b/Dangerfile.swift new file mode 100644 index 00000000..8fbce09b --- /dev/null +++ b/Dangerfile.swift @@ -0,0 +1,3 @@ +import Danger + +SwiftLint.lint(inline: true, configFile: ".swiftlint.yml", strict: true) diff --git a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift index b6756dfa..6eec8951 100644 --- a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift +++ b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift @@ -71,7 +71,7 @@ class XMLDecoderImplementation: Decoder { } public func container(keyedBy keyType: Key.Type) throws -> KeyedDecodingContainer { - if let keyed = try self.topContainer() as? SharedBox { + if let keyed = try topContainer() as? SharedBox { return KeyedDecodingContainer(XMLKeyedDecodingContainer( referencing: self, wrapping: keyed diff --git a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift index 7aea290d..3fbcac10 100644 --- a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift +++ b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift @@ -227,7 +227,7 @@ extension XMLKeyedDecodingContainer { _ type: T.Type, forKey key: Key ) throws -> T { - guard let strategy = self.decoder.nodeDecodings.last else { + guard let strategy = decoder.nodeDecodings.last else { preconditionFailure( """ Attempt to access node decoding strategy from empty stack. diff --git a/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift b/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift index 71300449..09e37da3 100644 --- a/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift +++ b/Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift @@ -48,7 +48,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { public mutating func decodeNil() throws -> Bool { guard !isAtEnd else { throw DecodingError.valueNotFound(Any?.self, DecodingError.Context( - codingPath: decoder.codingPath + [XMLKey(index: self.currentIndex)], + codingPath: decoder.codingPath + [XMLKey(index: currentIndex)], debugDescription: "Unkeyed container is at end." )) } @@ -75,7 +75,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { _ type: T.Type, decode: (XMLDecoderImplementation, Box) throws -> T? ) throws -> T { - guard let strategy = self.decoder.nodeDecodings.last else { + guard let strategy = decoder.nodeDecodings.last else { preconditionFailure("Attempt to access node decoding strategy from empty stack.") } decoder.codingPath.append(XMLKey(index: currentIndex)) @@ -90,7 +90,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { } guard !isAtEnd else { throw DecodingError.valueNotFound(type, DecodingError.Context( - codingPath: decoder.codingPath + [XMLKey(index: self.currentIndex)], + codingPath: decoder.codingPath + [XMLKey(index: currentIndex)], debugDescription: "Unkeyed container is at end." )) } @@ -128,7 +128,7 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer { guard let decoded: T = value else { throw DecodingError.valueNotFound(type, DecodingError.Context( - codingPath: decoder.codingPath + [XMLKey(index: self.currentIndex)], + codingPath: decoder.codingPath + [XMLKey(index: currentIndex)], debugDescription: "Expected \(type) but found null instead." )) } diff --git a/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift b/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift index de04a225..e1378cb5 100644 --- a/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift +++ b/Sources/XMLCoder/Encoder/XMLKeyedEncodingContainer.swift @@ -91,7 +91,7 @@ struct XMLKeyedEncodingContainer: KeyedEncodingContainerProtocol { _ = self.encoder.nodeEncodings.removeLast() self.encoder.codingPath.removeLast() } - guard let strategy = self.encoder.nodeEncodings.last else { + guard let strategy = encoder.nodeEncodings.last else { preconditionFailure( "Attempt to access node encoding strategy from empty stack." ) diff --git a/lint.sh b/lint.sh index 08e52b35..8681785b 100755 --- a/lint.sh +++ b/lint.sh @@ -4,7 +4,6 @@ set -e set -o pipefail brew update -brew install swiftformat swiftlint +brew install swiftformat swiftformat --lint --verbose . -swiftlint