Skip to content

Commit a7af175

Browse files
authored
Merge pull request #95 from smartmobilefactory/feature/swiftlint
Feature/swiftlint
2 parents b3001e3 + 6c9bb14 commit a7af175

3 files changed

Lines changed: 33 additions & 15 deletions

File tree

SwiftLint/swiftlint.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,9 @@ custom_rules:
153153
- comment
154154
- doccomment
155155
- doccomment.field
156-
comments_capitalized_ignore_possible_code:
157-
name: "Capitalize First Word In Comment"
158-
regex: '(// +(?!swiftlint)[a-z]+)'
159-
message: "The first word of a comment should be capitalized"
160-
severity: warning
161-
match_kinds:
162-
- comment
163-
- doccomment
164156
empty_first_line:
165157
name: "Empty First Line"
166-
regex: '(extension|class) (?!(?:func|let|var))[^\{]*\{[^\n]*\n[\t ]*\w+'
158+
regex: '(extension|class|struct) (?!(?:func|let|var))[^\{]*\{[^\n]*\n[\t ]*\w+'
167159
message: "There should be an empty line after a class or extension declaration."
168160
severity: warning
169161
match_kinds:
@@ -212,11 +204,6 @@ custom_rules:
212204
regex: '(^ *if \(((?!( is | > | < | (=|!|<|>)= )).)*\) \{)'
213205
message: "if should contain == true or == false"
214206
severity: warning
215-
single_line_body:
216-
name: "Single Line Body"
217-
regex: '(?i-sm)((if|while|do|for)*? \{(?!\n|.?(s|g)et).+?\}\n)'
218-
message: "Single line bodies are not allowed"
219-
severity: warning
220207
missing_closure_datatype:
221208
name: "Missing Closure Data Type"
222209
regex: '(\{[\s]{1}(\[weak [\w]+?\][\s]{1})*?\([^:]+?\)[\s]{1}in)'

Xcode/check-xcode-version.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env xcrun --sdk macosx swift
2+
3+
import Foundation
4+
5+
let env = ProcessInfo.processInfo.environment
6+
7+
guard
8+
let path = env["PROJECT_DIR"],
9+
var url = URL(string: "file://" + path),
10+
let xcodeVersion = env["XCODE_VERSION_ACTUAL"] else {
11+
exit(0)
12+
}
13+
14+
url.appendPathComponent("Config.json")
15+
16+
guard
17+
let data = try? Data(contentsOf: url),
18+
let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
19+
let project = json["project"] as? [String: Any],
20+
let projectXcodeVersion = project["xcode_version"] as? String else {
21+
fatalError("'xcode_version' not found, please check your Config.json")
22+
}
23+
24+
let xcodeVersionCleaned = xcodeVersion.trimmingCharacters(in: .init(charactersIn: "0"))
25+
let projectXcodeVersionCleaned = projectXcodeVersion.replacingOccurrences(of: ".", with: "")
26+
27+
if (xcodeVersionCleaned != projectXcodeVersionCleaned) {
28+
fatalError("Xcode Version mismatch: please open Project with Xcode \(projectXcodeVersion) or change Xcode Version in Config.json")
29+
}
30+
31+
exit(0)

setup-common-project-files.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,5 @@ if [ $copyPRTemplate = true ]; then
151151
fi
152152

153153
if [ $checkXcodeVersion = true ]; then
154-
./Xcode/check-xcode-version.sh "$projectDir" || exit 1;
154+
./Xcode/check-xcode-version.swift;
155155
fi

0 commit comments

Comments
 (0)