Skip to content

Commit

Permalink
Merge pull request #30 from Tyler-Keith-Thompson/codacity
Browse files Browse the repository at this point in the history
Given I'm the submitter and the only one to review I am approving this.
  • Loading branch information
Tyler-Keith-Thompson authored May 30, 2021
2 parents 179b34a + b09896b commit a599cf4
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .swiftlint.yaml → .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions CucumberSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
CA73474524CB4EDB00D1A018 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CA919A482650B8FD00AA111E /* .swiftlint.yaml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yaml; sourceTree = "<group>"; };
CAA337AA21044ACC002C361D /* CucumberTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CucumberTests.swift; sourceTree = "<group>"; };
CAA337AE21045847002C361D /* testdata */ = {isa = PBXFileReference; lastKnownFileType = folder; path = testdata; sourceTree = "<group>"; };
CAA337B02104C310002C361D /* DocstringTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocstringTests.swift; sourceTree = "<group>"; };
CAAD49C0266368D6007B6E6E /* .swiftlint.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
CAB20B3B24CCF5C10024C703 /* RuleDSL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleDSL.swift; sourceTree = "<group>"; };
CAB20B3D24CCF6B20024C703 /* DSLRuleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSLRuleTests.swift; sourceTree = "<group>"; };
CABED02C256A17F2001E92C1 /* CucumberSwift.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = CucumberSwift.xctestplan; sourceTree = "<group>"; };
Expand Down Expand Up @@ -362,7 +363,7 @@
AD9EB4562079CF87002494C0 = {
isa = PBXGroup;
children = (
CA919A482650B8FD00AA111E /* .swiftlint.yaml */,
CAAD49C0266368D6007B6E6E /* .swiftlint.yml */,
AD9EB4622079CF87002494C0 /* Sources */,
AD9EB46D2079CF87002494C0 /* Tests */,
AD9EB4612079CF87002494C0 /* Products */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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&amp;utm_medium=referral&amp;utm_content=Tyler-Keith-Thompson/CucumberSwift&amp;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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/CucumberSwift/Gherkin/AST/AST.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
36 changes: 18 additions & 18 deletions Sources/CucumberSwift/Gherkin/AST/ASTToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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)
}
}

Expand All @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/CucumberSwift/Gherkin/Lexer/Position.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/CucumberSwift/Gherkin/Lexer/StringReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions Sources/CucumberSwift/Gherkin/Lexer/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/CucumberSwift/Gherkin/Parser/Scope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum Scope: Equatable, Hashable {
}

func isStep() -> Bool {
if case .step(_) = self {
if case .step = self {
return true
}
return false
Expand Down
10 changes: 5 additions & 5 deletions Sources/CucumberSwift/Gherkin/Parser/Step.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion Sources/CucumberSwift/Runner/Cucumber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import CucumberSwift_ObjC

@objc public class Cucumber: NSObject {
static var shared: Cucumber = {
return Cucumber()
Cucumber()
}()

var features = [Feature]()
Expand Down
4 changes: 2 additions & 2 deletions Sources/CucumberSwift/StubGeneration/StubGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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+)"
}
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/CucumberSwiftTests/DSLTests/DSLFeatureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DSLFeatureTests: XCTestCase {
}

Cucumber.shouldRunWith = { scenario, _ in
return shouldRun(scenario?.withLine(96))
shouldRun(scenario?.withLine(96))
}

Feature("") {
Expand All @@ -116,7 +116,7 @@ class DSLFeatureTests: XCTestCase {
}

Cucumber.shouldRunWith = { scenario, _ in
return scenario?.title == "First"
scenario?.title == "First"
}

Feature("") {
Expand All @@ -140,7 +140,7 @@ class DSLFeatureTests: XCTestCase {
}

Cucumber.shouldRunWith = { _, tags in
return tags.contains("t1")
tags.contains("t1")
}

Feature("") {
Expand Down
4 changes: 2 additions & 2 deletions Tests/CucumberSwiftTests/Gherkin/TableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
25 changes: 0 additions & 25 deletions deploy_pod.sh

This file was deleted.

4 changes: 0 additions & 4 deletions edit-plist.js

This file was deleted.

1 change: 1 addition & 0 deletions generateSwift.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#!/bin/bash
swiftgen && awk -F '=' '!a[$1]++' CucumberSwift/Generated/I18n.swift > .gen.swift && cat .gen.swift > CucumberSwift/Generated/I18n.swift
35 changes: 0 additions & 35 deletions xccov-to-sonarqube-generic.sh

This file was deleted.

0 comments on commit a599cf4

Please sign in to comment.