diff --git a/.swiftlint.yaml b/.swiftlint.yml similarity index 99% rename from .swiftlint.yaml rename to .swiftlint.yml index ed1566ad..86f3cbde 100644 --- a/.swiftlint.yaml +++ b/.swiftlint.yml @@ -75,7 +75,7 @@ excluded: # paths to ignore during linting. Takes precedence over `included`. - .build/ - .swiftpm/ - Package.swift - - .swiftlint.yaml + - .swiftlint.yml - Sources/CucumberSwift/Generated line_length: diff --git a/CucumberSwift.xcodeproj/project.pbxproj b/CucumberSwift.xcodeproj/project.pbxproj index d2536e82..b1727b39 100644 --- a/CucumberSwift.xcodeproj/project.pbxproj +++ b/CucumberSwift.xcodeproj/project.pbxproj @@ -103,6 +103,7 @@ CAA337AB21044ACC002C361D /* CucumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA337AA21044ACC002C361D /* CucumberTests.swift */; }; CAA337AF21045847002C361D /* testdata in Resources */ = {isa = PBXBuildFile; fileRef = CAA337AE21045847002C361D /* testdata */; }; CAA337B12104C310002C361D /* DocstringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA337B02104C310002C361D /* DocstringTests.swift */; }; + CAAD49C1266368D6007B6E6E /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = CAAD49C0266368D6007B6E6E /* .swiftlint.yml */; }; CAB20B3C24CCF5C10024C703 /* RuleDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB20B3B24CCF5C10024C703 /* RuleDSL.swift */; }; CAB20B3E24CCF6B20024C703 /* DSLRuleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB20B3D24CCF6B20024C703 /* DSLRuleTests.swift */; }; CADD26DD265B1D1F00EE8707 /* JSONReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CADD26DC265B1D1F00EE8707 /* JSONReporter.swift */; }; @@ -235,10 +236,10 @@ CA73474124CB4EDB00D1A018 /* CucumberSwiftDSLConsumerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CucumberSwiftDSLConsumerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; CA73474324CB4EDB00D1A018 /* CucumberSwiftDSLConsumerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CucumberSwiftDSLConsumerTests.swift; sourceTree = ""; }; CA73474524CB4EDB00D1A018 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - CA919A482650B8FD00AA111E /* .swiftlint.yaml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yaml; sourceTree = ""; }; CAA337AA21044ACC002C361D /* CucumberTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CucumberTests.swift; sourceTree = ""; }; CAA337AE21045847002C361D /* testdata */ = {isa = PBXFileReference; lastKnownFileType = folder; path = testdata; sourceTree = ""; }; CAA337B02104C310002C361D /* DocstringTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocstringTests.swift; sourceTree = ""; }; + CAAD49C0266368D6007B6E6E /* .swiftlint.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; CAB20B3B24CCF5C10024C703 /* RuleDSL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleDSL.swift; sourceTree = ""; }; CAB20B3D24CCF6B20024C703 /* DSLRuleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSLRuleTests.swift; sourceTree = ""; }; CABED02C256A17F2001E92C1 /* CucumberSwift.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = CucumberSwift.xctestplan; sourceTree = ""; }; @@ -362,7 +363,7 @@ AD9EB4562079CF87002494C0 = { isa = PBXGroup; children = ( - CA919A482650B8FD00AA111E /* .swiftlint.yaml */, + CAAD49C0266368D6007B6E6E /* .swiftlint.yml */, AD9EB4622079CF87002494C0 /* Sources */, AD9EB46D2079CF87002494C0 /* Tests */, AD9EB4612079CF87002494C0 /* Products */, @@ -796,6 +797,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + CAAD49C1266368D6007B6E6E /* .swiftlint.yml in Resources */, AD831B67222C961A003EE136 /* Gherkin.xclangspec in Resources */, AD22A1BF222C599F0025E41C /* Snippets in Resources */, AD7F1C0C2104D6B10004852A /* gherkin-languages.json in Resources */, @@ -847,7 +849,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint --config .swiftlint.yaml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint --config .swiftlint.yml\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/README.md b/README.md index 95bd693c..00a11526 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ![Build Status](https://github.com/Tyler-Keith-Thompson/CucumberSwift/actions/workflows/CI.yml/badge.svg?branch=master) ![Pod Platform](https://img.shields.io/cocoapods/p/CucumberSwift.svg?style=popout) [![Pod Version](https://img.shields.io/cocoapods/v/CucumberSwift.svg?style=popout)](http://cocoapods.org/pods/CucumberSwift) [![codecov](https://codecov.io/gh/Tyler-Keith-Thompson/CucumberSwift/branch/master/graph/badge.svg?token=ARIPC8Q7H1)](https://codecov.io/gh/Tyler-Keith-Thompson/CucumberSwift) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c29b0bf4883b4387a41ac1d090773f65)](https://www.codacy.com/gh/Tyler-Keith-Thompson/CucumberSwift/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Tyler-Keith-Thompson/CucumberSwift&utm_campaign=Badge_Grade) ### Welcome to CucumberSwift CucumberSwift is a lightweight Swift only Cucumber implementation for iOS, tvOS, and macOS. It was born out of frustration with current iOS Cucumber implementations. The whole goal is to make it easy to install and easy to use, so please feel free to give feedback. diff --git a/Sources/CucumberSwift/Gherkin/AST/AST.swift b/Sources/CucumberSwift/Gherkin/AST/AST.swift index 77f51d75..9cf1914d 100644 --- a/Sources/CucumberSwift/Gherkin/AST/AST.swift +++ b/Sources/CucumberSwift/Gherkin/AST/AST.swift @@ -37,7 +37,7 @@ class AST { func parse(_ tokens: [Lexer.Token], inFile url: String = "") -> [FeatureNode] { for token in tokens { - if case Lexer.Token.tag(_, _) = token { + if case Lexer.Token.tag = token { tags.append(token) } else { if let t = AST.Token(token) { diff --git a/Sources/CucumberSwift/Gherkin/AST/ASTToken.swift b/Sources/CucumberSwift/Gherkin/AST/ASTToken.swift index 2775e96e..44a241b1 100644 --- a/Sources/CucumberSwift/Gherkin/AST/ASTToken.swift +++ b/Sources/CucumberSwift/Gherkin/AST/ASTToken.swift @@ -20,14 +20,14 @@ extension AST { var priority: UInt { switch self { - case .feature(_): return 0 - case .rule(_): return 1 - case .background(_): return 2 - case .scenario(_): return 2 - case .scenarioOutline(_): return 2 - case .examples(_): return 2 - case .step(_): return 3 - case .description(_): return 3 + case .feature: return 0 + case .rule: return 1 + case .background: return 2 + case .scenario: return 2 + case .scenarioOutline: return 2 + case .examples: return 2 + case .step: return 3 + case .description: return 3 } } @@ -41,14 +41,14 @@ extension AST { func hash(into hasher: inout Hasher) { switch self { - case .feature(_): hasher.combine(1) - case .rule(_): hasher.combine(2) - case .background(_): hasher.combine(3) - case .scenario(_): hasher.combine(4) - case .scenarioOutline(_): hasher.combine(5) - case .examples(_): hasher.combine(6) - case .step(_): hasher.combine(7) - case .description(_): hasher.combine(8) + case .feature: hasher.combine(1) + case .rule: hasher.combine(2) + case .background: hasher.combine(3) + case .scenario: hasher.combine(4) + case .scenarioOutline: hasher.combine(5) + case .examples: hasher.combine(6) + case .step: hasher.combine(7) + case .description: hasher.combine(8) } } @@ -66,7 +66,7 @@ extension AST { } init?(_ token: Lexer.Token) { - if case Lexer.Token.keyword(_, _) = token { + if case Lexer.Token.keyword = token { self = .step(token) } else if case Lexer.Token.scope(_, let scope) = token { switch scope { @@ -78,7 +78,7 @@ extension AST { case .examples: self = .examples(token) default: return nil } - } else if case Lexer.Token.description(_, _) = token { + } else if case Lexer.Token.description = token { self = .description(token) } else { return nil diff --git a/Sources/CucumberSwift/Gherkin/Lexer/Position.swift b/Sources/CucumberSwift/Gherkin/Lexer/Position.swift index f79a3e97..abc43619 100644 --- a/Sources/CucumberSwift/Gherkin/Lexer/Position.swift +++ b/Sources/CucumberSwift/Gherkin/Lexer/Position.swift @@ -11,7 +11,7 @@ import Foundation extension Lexer { public struct Position: Hashable { static let start: Position = { - return Position(line: 0, column: 0) + Position(line: 0, column: 0) }() public internal(set) var line: UInt public internal(set) var column: UInt diff --git a/Sources/CucumberSwift/Gherkin/Lexer/StringReader.swift b/Sources/CucumberSwift/Gherkin/Lexer/StringReader.swift index feadaed7..d19ec384 100644 --- a/Sources/CucumberSwift/Gherkin/Lexer/StringReader.swift +++ b/Sources/CucumberSwift/Gherkin/Lexer/StringReader.swift @@ -61,7 +61,7 @@ public class StringReader { var str = "" var indexCopy = index let currentCharacter = { - return (indexCopy < self.input.endIndex && indexCopy >= self.input.startIndex) ? self.input[indexCopy] : nil + (indexCopy < self.input.endIndex && indexCopy >= self.input.startIndex) ? self.input[indexCopy] : nil } while let char = currentCharacter(), !evaluation(char) { str.append(char) diff --git a/Sources/CucumberSwift/Gherkin/Lexer/Token.swift b/Sources/CucumberSwift/Gherkin/Lexer/Token.swift index cf3b818b..81cfcec0 100644 --- a/Sources/CucumberSwift/Gherkin/Lexer/Token.swift +++ b/Sources/CucumberSwift/Gherkin/Lexer/Token.swift @@ -88,7 +88,7 @@ extension Lexer { var valueDescription: String { switch self { - case .newLine(_): return "\n" + case .newLine: return "\n" case .integer(_, let val): return "\(val)" case .string(_, let val): return "\(val)" case .docString(_, let val): return "\(val)" @@ -104,38 +104,38 @@ extension Lexer { } func isNewline() -> Bool { - if case .newLine(_) = self { + if case .newLine = self { return true } return false } func isTableCell() -> Bool { - if case .tableCell(_, _) = self { + if case .tableCell = self { return true } return false } func isKeyword() -> Bool { - if case .keyword(_, _) = self { + if case .keyword = self { return true } return false } func isString() -> Bool { - if case .string(_, _) = self { + if case .string = self { return true } return false } func isInteger() -> Bool { - if case .integer(_, _) = self { + if case .integer = self { return true } return false } func isDescription() -> Bool { - if case .description(_, _) = self { + if case .description = self { return true } return false diff --git a/Sources/CucumberSwift/Gherkin/Parser/Scope.swift b/Sources/CucumberSwift/Gherkin/Parser/Scope.swift index 26069895..e3d74393 100644 --- a/Sources/CucumberSwift/Gherkin/Parser/Scope.swift +++ b/Sources/CucumberSwift/Gherkin/Parser/Scope.swift @@ -56,7 +56,7 @@ enum Scope: Equatable, Hashable { } func isStep() -> Bool { - if case .step(_) = self { + if case .step = self { return true } return false diff --git a/Sources/CucumberSwift/Gherkin/Parser/Step.swift b/Sources/CucumberSwift/Gherkin/Parser/Step.swift index fe586233..acd3e6d6 100644 --- a/Sources/CucumberSwift/Gherkin/Parser/Step.swift +++ b/Sources/CucumberSwift/Gherkin/Parser/Step.swift @@ -77,7 +77,7 @@ public class Step: CustomStringConvertible { .filter { $0.isTableCell() || $0.isNewline() } .groupedByLine() .map { line -> [String] in - return line.filter { $0.isTableCell() } + line.filter { $0.isTableCell() } .map { token -> String in if case Lexer.Token.tableCell(_, let cellText) = token { return cellText @@ -172,9 +172,9 @@ extension Step { } public static let given = Keyword(rawValue: 1 << 0) - public static let when = Keyword(rawValue: 1 << 1) - public static let then = Keyword(rawValue: 1 << 2) - public static let and = Keyword(rawValue: 1 << 3) - public static let but = Keyword(rawValue: 1 << 4) + public static let when = Keyword(rawValue: 1 << 1) + public static let then = Keyword(rawValue: 1 << 2) + public static let and = Keyword(rawValue: 1 << 3) + public static let but = Keyword(rawValue: 1 << 4) } } diff --git a/Sources/CucumberSwift/Runner/Cucumber.swift b/Sources/CucumberSwift/Runner/Cucumber.swift index 740ad652..cfaed66a 100644 --- a/Sources/CucumberSwift/Runner/Cucumber.swift +++ b/Sources/CucumberSwift/Runner/Cucumber.swift @@ -15,7 +15,7 @@ import CucumberSwift_ObjC @objc public class Cucumber: NSObject { static var shared: Cucumber = { - return Cucumber() + Cucumber() }() var features = [Feature]() diff --git a/Sources/CucumberSwift/StubGeneration/StubGenerator.swift b/Sources/CucumberSwift/StubGeneration/StubGenerator.swift index 36fd7f20..057dfa74 100644 --- a/Sources/CucumberSwift/StubGeneration/StubGenerator.swift +++ b/Sources/CucumberSwift/StubGeneration/StubGenerator.swift @@ -16,9 +16,9 @@ enum StubGenerator { .escapedPattern(for: m) .replacingOccurrences(of: "\\", with: "\\\\", options: [], range: nil) .replacingOccurrences(of: "\"", with: "\\\"", options: [], range: nil) - } else if case Lexer.Token.string(_, _) = token { + } else if case Lexer.Token.string = token { regex += "\\\"(.*?)\\\"" - } else if case Lexer.Token.integer(_, _) = token { + } else if case Lexer.Token.integer = token { regex += "(\\\\d+)" } } diff --git a/Tests/CucumberSwiftTests/DSLTests/DSLFeatureTests.swift b/Tests/CucumberSwiftTests/DSLTests/DSLFeatureTests.swift index ff181044..13062dca 100644 --- a/Tests/CucumberSwiftTests/DSLTests/DSLFeatureTests.swift +++ b/Tests/CucumberSwiftTests/DSLTests/DSLFeatureTests.swift @@ -89,7 +89,7 @@ class DSLFeatureTests: XCTestCase { } Cucumber.shouldRunWith = { scenario, _ in - return shouldRun(scenario?.withLine(96)) + shouldRun(scenario?.withLine(96)) } Feature("") { @@ -116,7 +116,7 @@ class DSLFeatureTests: XCTestCase { } Cucumber.shouldRunWith = { scenario, _ in - return scenario?.title == "First" + scenario?.title == "First" } Feature("") { @@ -140,7 +140,7 @@ class DSLFeatureTests: XCTestCase { } Cucumber.shouldRunWith = { _, tags in - return tags.contains("t1") + tags.contains("t1") } Feature("") { diff --git a/Tests/CucumberSwiftTests/Gherkin/TableTests.swift b/Tests/CucumberSwiftTests/Gherkin/TableTests.swift index 6a6cf2d4..d128d622 100644 --- a/Tests/CucumberSwiftTests/Gherkin/TableTests.swift +++ b/Tests/CucumberSwiftTests/Gherkin/TableTests.swift @@ -177,11 +177,11 @@ class TableTests: XCTestCase { | uno | dos | """) var firstGivenCalled = false - Given("the un") { (_, _) in + Given("the un") { _, _ in firstGivenCalled = true } var secondGivenCalled = false - Given("the uno") { (_, _) in + Given("the uno") { _, _ in secondGivenCalled = true } Cucumber.shared.executeFeatures() diff --git a/deploy_pod.sh b/deploy_pod.sh deleted file mode 100755 index a3523c65..00000000 --- a/deploy_pod.sh +++ /dev/null @@ -1,25 +0,0 @@ -# get the latest code -if [[ -n ${TRAVIS_BRANCH} ]]; then - git config --global user.email "travis@travis-ci.org" - git config --global user.name "Travis CI" - git config --global push.default current -fi -git checkout master -git reset --hard origin/master -git clean -df - -# do the podspec stuff -npm install -g podspec-bump #uncomment if you need the node package -npm install simple-plist -podspec-bump -w - -# commit the podspec bump -node edit-plist.js `podspec-bump --dump-version` -git commit -am "[ci skip] publishing pod version: `podspec-bump --dump-version`" -git tag "`podspec-bump --dump-version`" -git push https://${PERSONAL_ACCESS_TOKEN}@github.com/Tyler-Keith-Thompson/CucumberSwift.git HEAD -u $(podspec-bump --dump-version) -git reset --hard -git clean -df -curl --data "{\"tag_name\": \"`podspec-bump --dump-version`\",\"target_commitish\": \"master\",\"name\": \"`podspec-bump --dump-version`\",\"body\": \"Release of version `podspec-bump --dump-version`\",\"draft\": false,\"prerelease\": false}" -H "Authorization: token $PERSONAL_ACCESS_TOKEN" "https://api.github.com/repos/Tyler-Keith-Thompson/CucumberSwift/releases" -pod repo add-cdn trunk 'https://cdn.cocoapods.org/' -pod trunk push CucumberSwift.podspec --allow-warnings \ No newline at end of file diff --git a/edit-plist.js b/edit-plist.js deleted file mode 100644 index 7b0f7dab..00000000 --- a/edit-plist.js +++ /dev/null @@ -1,4 +0,0 @@ -var plist = require('simple-plist'); -var data = plist.readFileSync('CucumberSwift/Info.plist'); -data.CFBundleVersion = process.argv[2].toString(); -plist.writeFileSync('CucumberSwift/Info.plist', data); diff --git a/generateSwift.sh b/generateSwift.sh index 8fcc2ff5..418b08c9 100755 --- a/generateSwift.sh +++ b/generateSwift.sh @@ -1 +1,2 @@ +#!/bin/bash swiftgen && awk -F '=' '!a[$1]++' CucumberSwift/Generated/I18n.swift > .gen.swift && cat .gen.swift > CucumberSwift/Generated/I18n.swift \ No newline at end of file diff --git a/xccov-to-sonarqube-generic.sh b/xccov-to-sonarqube-generic.sh deleted file mode 100755 index 8bfa558b..00000000 --- a/xccov-to-sonarqube-generic.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -function convert_file { - local xccovarchive_file="$1" - local file_name="$2" - local xccov_options="$3" - echo " " - xcrun xccov view $xccov_options --file "$file_name" "$xccovarchive_file" | \ - sed -n ' - s/^ *\([0-9][0-9]*\): 0.*$/ /p; - s/^ *\([0-9][0-9]*\): [1-9].*$/ /p - ' - echo ' ' -} - -function xccov_to_generic { - echo '' - for xccovarchive_file in "$@"; do - local xccov_options="" - if [[ ! -d $xccovarchive_file ]]; then - echo "Coverage FILE NOT FOUND AT PATH: $xccovarchive_file" 1>&2; - exit 1 - fi - if [[ $xccovarchive_file == *".xcresult"* ]]; then - xccov_options="--archive" - fi - xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | while read -r file_name; do - convert_file "$xccovarchive_file" "$file_name" "$xccov_options" - done - done - echo '' -} - -xccov_to_generic "$@" \ No newline at end of file