Skip to content

Commit 98d85c3

Browse files
authored
Merge pull request #96 from smartmobilefactory/feature/swiftlint
add new Swiftlint Rules
2 parents a7af175 + 277700b commit 98d85c3

3 files changed

Lines changed: 46 additions & 125 deletions

File tree

SwiftLint/swiftlint.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ disabled_rules:
1515
- switch_case_alignment
1616
- empty_enum_arguments # case .unexpectedSituation(_): ... is not allowed
1717
- duplicate_enum_cases
18+
- identifier_name
1819

1920
# paths to ignore during linting. overridden by `included`.
2021
excluded:
@@ -54,6 +55,35 @@ opt_in_rules:
5455
- identical_operands
5556
- collection_alignment
5657
- empty_xctest_method
58+
- array_init
59+
- contains_over_filter_count
60+
- contains_over_filter_is_empty
61+
- contains_over_first_not_nil
62+
- empty_collection_literal
63+
- empty_string
64+
- explicit_self
65+
- file_name
66+
- for_where
67+
- joined_default_parameter
68+
- last_where
69+
- legacy_multiple
70+
- literal_expression_end_indentation
71+
- lower_acl_than_parent
72+
- modifier_order
73+
- multiline_arguments
74+
- multiline_function_chains
75+
- multiline_literal_brackets
76+
- convenience_type
77+
- overridden_super_call
78+
- redundant_type_annotation
79+
- sorted_first_last
80+
- static_operator
81+
- toggle_bool
82+
- unowned_variable_capture
83+
- unused_import
84+
- vertical_whitespace_closing_braces
85+
- single_test_class
86+
- strong_iboutlet
5787

5888
# rule parameters
5989
file_length:
@@ -86,23 +116,6 @@ large_tuple:
86116
warning: 4
87117
error: 6
88118

89-
identifier_name:
90-
excluded:
91-
- to
92-
- id
93-
- by
94-
- of
95-
- at
96-
- in
97-
- !str on
98-
- x
99-
- y
100-
- L
101-
# Allow the usage of underscores at the start of variables or constants. The lowercase check has currently to be disabled as "_" isn't considered as lowercase character
102-
validates_start_lowercase: false
103-
allowed_symbols:
104-
- _
105-
106119
type_name:
107120
min_length: 3
108121
max_length: 60
@@ -129,11 +142,6 @@ custom_rules:
129142
- typeidentifier
130143
- number
131144
- identifier
132-
unnecessary_datatype:
133-
name: "Unnecessary Datatype"
134-
regex: '(?m-s)(let|var).*(:\s\[+(\w|:| |\t)+\]+\s*=\s*\[:*\])'
135-
message: "Unnecessary datatype. Use '= [DataType]()' instead of ': [DataType] = []'"
136-
severity: warning
137145
missing_closure_name:
138146
name: "Missing closure name"
139147
regex: '^\s*\}\) \{.*'
@@ -155,7 +163,7 @@ custom_rules:
155163
- doccomment.field
156164
empty_first_line:
157165
name: "Empty First Line"
158-
regex: '(extension|class|struct) (?!(?:func|let|var))[^\{]*\{[^\n]*\n[\t ]*\w+'
166+
regex: '(extension|class|struct|protocol) (?!(?:func|let|var))[^\{]*\{[^\n]*\n[\t ]*\w+'
159167
message: "There should be an empty line after a class or extension declaration."
160168
severity: warning
161169
match_kinds:

Xcode/check-xcode-version.sh

Lines changed: 0 additions & 99 deletions
This file was deleted.

Xcode/check-xcode-version.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ let env = ProcessInfo.processInfo.environment
77
guard
88
let path = env["PROJECT_DIR"],
99
var url = URL(string: "file://" + path),
10+
let projectPath = env["PROJECT_FILE_PATH"],
11+
let xcodeVersionMajor = env["XCODE_VERSION_MAJOR"],
1012
let xcodeVersion = env["XCODE_VERSION_ACTUAL"] else {
1113
exit(0)
1214
}
@@ -18,14 +20,24 @@ guard
1820
let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
1921
let project = json["project"] as? [String: Any],
2022
let projectXcodeVersion = project["xcode_version"] as? String else {
21-
fatalError("'xcode_version' not found, please check your Config.json")
23+
print("\(projectPath):1:1: error: Xcode Version not found in Config.json")
24+
exit(1)
2225
}
2326

2427
let xcodeVersionCleaned = xcodeVersion.trimmingCharacters(in: .init(charactersIn: "0"))
25-
let projectXcodeVersionCleaned = projectXcodeVersion.replacingOccurrences(of: ".", with: "")
28+
let projectXcodeVersionCleaned = projectXcodeVersion.replacingOccurrences(of: ".", with: "").trimmingCharacters(in: .init(charactersIn: "0"))
29+
30+
let projectXcodeVersionMajorCleaned = projectXcodeVersion.split(separator: ".")[0].trimmingCharacters(in: .init(charactersIn: "0"))
31+
let xcodeVersionMajorCleaned = xcodeVersionMajor.trimmingCharacters(in: .init(charactersIn: "0"))
32+
33+
if (projectXcodeVersionMajorCleaned != xcodeVersionMajorCleaned) {
34+
print("\(projectPath):1:1: error: Xcode Version does not match Config.json. Please use Xcode-\(projectXcodeVersion) or change Config.json")
35+
exit(1)
36+
}
2637

2738
if (xcodeVersionCleaned != projectXcodeVersionCleaned) {
28-
fatalError("Xcode Version mismatch: please open Project with Xcode \(projectXcodeVersion) or change Xcode Version in Config.json")
39+
print("\(projectPath):1:1: warning: Xcode Version does not match Config.json. Please consider using Xcode-\(projectXcodeVersion) or change Config.json")
40+
exit(0)
2941
}
3042

3143
exit(0)

0 commit comments

Comments
 (0)