Skip to content

Commit 5956e1c

Browse files
authored
Merge pull request #14 from tschob/development
Development
2 parents c754ba8 + d1d4784 commit 5956e1c

24 files changed

+842
-488
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ playground.xcworkspace
4343
# you should judge for yourself, the pros and cons are mentioned at:
4444
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
4545
#
46-
# Pods/
46+
47+
Pods/
4748

4849
# Carthage
4950
#

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

.travis.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
osx_image: xcode8.2
1+
osx_image: xcode9
22
language: objective-c
33

44
env:
5-
global:
6-
- LC_CTYPE=en_US.UTF-8
7-
- LANG=en_US.UTF-8
85
matrix:
96
- DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=9.3"
107
- DESTINATION="platform=iOS Simulator,name=iPhone 7,OS=10.1"
8+
- DESTINATION="platform=iOS Simulator,name=iPhone X,OS=11.0"
9+
10+
podfile: Example/Podfile
11+
before_install:
12+
- gem install cocoapods
13+
- pod repo update
14+
- pod install --project-directory=Example
15+
1116

1217
script:
1318
- set -o pipefail
14-
- xcodebuild build -workspace ContainerController.xcworkspace -scheme Example -destination "$DESTINATION"
19+
- xcodebuild build -workspace Example/Example.xcworkspace -scheme Example -destination "$DESTINATION"
1520
- pod lib lint --allow-warnings

ContainerController/.swiftlint.yml

Lines changed: 191 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,226 @@
11
###
22
# Swiftlint configuration file.
3-
# Latest version supported: 0.11.1
3+
# Latest version supported: 0.21.0
44
# Any newer version hasn't been checked yet and might not follow the style guide.
55
###
66

77
disabled_rules: # rule identifiers to exclude from running
8-
- colon # exaclty one space after the : >>> let abc: Void\n
8+
- colon # exaclty one space after the : >>> let abc: Void\n
99
- control_statement # no rounded brackets around conditions. we would need this the other way around
1010
- todo # TODO can be written in the code but should be linked to a ticket on JIRA.
11-
- nesting # func nesting max 1 level
11+
- unused_closure_parameter
12+
- redundant_string_enum_value
13+
- vertical_parameter_alignment
1214

1315
excluded: # paths to ignore during linting. overridden by `included`.
1416
- Carthage
1517
- Pods
1618
- External
19+
- Submodules
20+
- Generated
21+
- Core/Model/CoreData
22+
- App/Model/CoreData
23+
- Database/Model
24+
- fastlane
25+
26+
opt_in_rules:
27+
- valid_docs
28+
- force_unwrapping
29+
- conditional_returns_on_newline
30+
- private_outlet
31+
- vertical_whitespace
32+
- closure_spacing
33+
- explicit_init
34+
- redundant_nil_coalescing
35+
- nimble_operator
36+
- attributes
37+
- closure_end_indentation
38+
- empty_count
39+
- first_where
40+
- implicitly_unwrapped_optional
41+
- unneeded_parentheses_in_closure_argument
42+
- multiline_parameters
43+
- fatal_error_message
44+
- let_var_whitespace
45+
- redundant_string_enum_value
1746

1847
# rule parameters
19-
function_parameter_count:
20-
- 6 #warning
21-
- 8 #error
48+
file_length:
49+
warning: 600
50+
error: 800
51+
ignore_comment_only_lines: true
2252

2353
cyclomatic_complexity:
24-
- 20 #warning
25-
- 35 #error
54+
ignores_case_statements: true
55+
warning: 10
56+
error: 20
2657

27-
file_length:
28-
- 600 #warning
29-
- 800 #error
58+
nesting:
59+
type_level:
60+
warning: 6
61+
statement_level:
62+
warning: 6
3063

3164
function_body_length:
32-
- 40 #warning
33-
- 80 #error
65+
warning: 40
66+
error: 80
3467

35-
line_length:
36-
- 300 #warning
37-
- 350 #error
68+
line_length: 300
3869

3970
type_body_length:
40-
- 400 #warning
41-
- 500 #error
42-
43-
opt_in_rules:
44-
- missing_docs
45-
- force_unwrapping
71+
warning: 400
72+
error: 500
73+
74+
large_tuple:
75+
warning: 4
76+
error: 6
77+
78+
identifier_name:
79+
excluded:
80+
- to
81+
- id
82+
- by
83+
- of
84+
- at
85+
- !str on
86+
- x
87+
- y
88+
- L
89+
90+
private_outlet:
91+
allow_private_set: true
4692

4793
custom_rules:
94+
extra_whitespace:
95+
name: "Extra whitespaces"
96+
regex: '([^\n/ \t] | | \t)'
97+
message: "Indentation should be done with tabs. Only whitespaces in comments and up to three whitespaces at the start of a line or after tabs are allowed."
98+
severity: warning
99+
match_kinds:
100+
- string
101+
- keyword
102+
- parameter
103+
- typeidentifier
104+
- number
105+
- identifier
106+
unnecessary_datatype:
107+
name: "Unnecessary Datatype"
108+
regex: '(?m-s)(let|var).*(:\s\[+(\w|:| |\t)+\]+\s*=\s*\[:*\])'
109+
message: "Unnecessary datatype. Use '= [DataType]()' instead of ': [DataType] = []'"
110+
severity: warning
111+
missing_closure_name:
112+
name: "Missing closure name"
113+
regex: '^\s*\}\) \{.*'
114+
message: "Add the missing closure name"
115+
severity: warning
116+
empty_commented_line:
117+
name: "Empty Commented Out Line"
118+
regex: '(\t+| +)//\n'
119+
message: "Remove useless comment lines or use /* format */"
120+
severity: warning
48121
comments_space:
49122
name: "Space After Comment"
50-
regex: "(^ *//\w+)"
51-
message: "There should be a space after //"
52-
severity: error
123+
regex: '(//\w+|///\w+)'
124+
message: "There should be a space between the start of a comment and the first character."
125+
severity: warning
126+
match_kinds:
127+
- comment
128+
- doccomment
129+
- doccomment.field
53130
comments_capitalized_ignore_possible_code:
54131
name: "Capitalize First Word In Comment"
55-
regex: "(^ +// +(?!swiftlint)[a-z]+)"
132+
regex: '(// +(?!swiftlint)[a-z]+)'
56133
message: "The first word of a comment should be capitalized"
57-
severity: error
134+
severity: warning
135+
match_kinds:
136+
- comment
137+
- doccomment
58138
empty_first_line:
59139
name: "Empty First Line"
60-
regex: "(^[ a-zA-Z ]*(?:protocol|extension|class|struct) (?!(?:var|let))[ a-zA-Z:]*\{\n *\S+)"
61-
message: "There should be an empty line after a declaration"
62-
severity: error
63-
empty_line_after_guard:
64-
name: "Empty Line After Guard"
65-
regex: "(^ *guard[ a-zA-Z0-9=?.\(\),><!]*\{[ a-zA-Z0-9=?.\(\),><!]*\}\n *(?!(?:return|guard))\S+)"
66-
message: "There should be an empty line after a guard"
67-
severity: error
68-
empty_line_after_super:
69-
name: "Empty Line After Super"
70-
regex: "(^ *super\.[ a-zA-Z0-9=?.\(\)\{\}:,><!]*\n *(?!(?:\}|return))\S+)"
71-
message: "There should be an empty line after super"
72-
severity: error
73-
multiple_empty_lines:
74-
name: "Multiple Empty Lines"
75-
regex: "((?:\s*\n){3,})"
76-
message: "There are too many line breaks"
77-
severity: error
140+
regex: '(extension|class) (?!(?:func))[^\{]*\{[^\n]*\n[\t ]*\w+'
141+
message: "There should be an empty line after a class or extension declaration."
142+
severity: warning
143+
match_kinds:
144+
- keyword
145+
- typeidentifier
146+
- identifier
147+
- typeidentifier
148+
- argument
149+
- string
150+
- objectliteral
151+
- placeholder
152+
- parameter
153+
- attribute.builtin
154+
unnecessary_leading_void_in:
155+
name: "Unnecessary -> Void in at the end of the line"
156+
regex: '(-> (Void|\(\)) in$)'
157+
message: "Unnecessary '-> Void in' at the end of the line. Use only 'in'"
158+
severity: warning
78159
unnecessary_type:
79160
name: "Unnecessary Type"
80-
regex: "[ a-zA-Z0-9]*(?:let|var) [ a-zA-Z0-9]*: ([a-zA-Z0-9]*)[\? ]*= \1"
161+
regex: '(?sm)[ \ta-zA-Z0-9]?(?:let|var){1} [ \ta-zA-Z0-9]+?:[ \t]+?([a-zA-Z0-9]+?)[\t ]+?=[\t ]?\1'
81162
message: "Type Definition Not Needed"
82-
severity: error
83-
84-
####### enabled rules #######
85-
# - comma # k,v >> k, v
86-
# - file_length # max number of lines per file
87-
# - force_cast # as!
88-
# - force_try # try!
89-
# - function_body_length # max length of function body
90-
# - leading_whitespace # empty lines with whitespaces only
91-
# - legacy_constructor # e.g CGPointMake(...) >>> CGPoint(x: ..., y: ...)
92-
# - line_length # max length of a line
93-
# - opening_brace # [].map(){ ... } >>> [].map() { ... }
94-
# - operator_function_whitespace # func thing () {...} >>> func thing() {...}
95-
# - return_arrow_whitespace # func thing()->Bool >>> func thing() -> Bool
96-
# - statement_position # }else if { >>> } else if {
97-
# - trailing_newline # new line at the end of a file
98-
# - trailing_semicolon # no ;
99-
# - trailing_whitespace # no trailing whitespaced
100-
# - type_body_length # max body length
101-
# - type_name # types should start with a capital letter
102-
# - valid_docs # docs should match the method signature
103-
# - variable_name_min_length # variables should have a 3 letter minimum name and 40 maximum.
104-
# - variable_name # variables should start with a lower case character or a capitalized one if `static`.
105-
# - cyclomatic_complexity # limit the number of entries inside an enum or struct.
163+
severity: warning
164+
empty_closure_params:
165+
name: "Empty closure params"
166+
regex: '\{ (\(\) -> Void in)$'
167+
message: "`() -> Void in` should be avoided"
168+
severity: warning
169+
single_line_body:
170+
name: "Single Line Body"
171+
regex: '(?i-sm)((if|while|do|for)*? \{(?!\n|.?(s|g)et).+?\}\n)'
172+
message: "Single line bodies are not allowed"
173+
severity: warning
174+
missing_closure_datatype:
175+
name: "Missing Closure Data Type"
176+
regex: '(\{[\s]{1}(\[weak [\w]+?\][\s]{1})*?\([^:]+?\)[\s]{1}in)'
177+
message: "Data Type in Closure is missing"
178+
severity: warning
179+
invalid_mark_format:
180+
name: "Invalid MARK Format"
181+
regex: '(?m-s)(\/\/[\s]*?MARK(?!(\:[\s]{1}\-[\s]{1}){1}))'
182+
message: "Use format: MARK: - Your Info"
183+
severity: warning
184+
unnecessary_space:
185+
name: "Unnecessary Space"
186+
regex: '(\[[a-zA-Z0-9]+? {1}: {1}[a-zA-Z0-9]+?\])'
187+
message: "Unnecessary space. use [DataType: DataType]."
188+
severity: warning
189+
missing_space:
190+
name: "Missing Space"
191+
regex: '(\[[a-zA-Z0-9]+?:[a-zA-Z0-9]+?\])'
192+
message: "Missing space. use [DataType: DataType]."
193+
severity: warning
194+
get_prefixed_function:
195+
name: "Get prefixed function"
196+
regex: '(?-smxi)(func get[A-Z0-9][\w]+?(\())'
197+
message: "You should not prefix your functions with the word get."
198+
severity: warning
199+
lowercase_constants:
200+
name: "Lowercase Constants"
201+
regex: '[ \t]let[ \t]*[A-Z][\w]*[ \t]*(=|:)'
202+
message: "Constants should begin with a lowercase character."
203+
severity: warning
204+
match_kinds:
205+
- argument
206+
- attribute.builtin
207+
- attribute.id
208+
- buildconfig.id
209+
- buildconfig.keyword
210+
- comment
211+
- comment.mark
212+
- comment.url
213+
- doccomment
214+
- doccomment.field
215+
- identifier
216+
- keyword
217+
- number
218+
- objectliteral
219+
- parameter
220+
- placeholder
221+
- typeidentifier
222+
empty_lines_before_declaration_end:
223+
name: "Empty lines before declaration end"
224+
regex: '\n[ \t]*\n[ \t]*\}([ \t]*\n|\n)'
225+
message: "Empty lines before a declaration aren't improving the readability."
226+
severity: warning

0 commit comments

Comments
 (0)