Skip to content

Commit 6eaf330

Browse files
committed
Refactoring according to swxftlint.
Updated build settings.
1 parent 4f6bd98 commit 6eaf330

File tree

4 files changed

+64
-51
lines changed

4 files changed

+64
-51
lines changed

.swiftlint.yml

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,43 @@
1-
# 無効にするルール
21
disabled_rules:
3-
- trailing_whitespace # 余分に改行がある方が視認性が上がる為、無効
2+
- trailing_whitespace
43
- valid_docs
5-
- type_name # クラス名は長くして情報を詰めておく必要もある為、無効
6-
7-
# ルール一覧を表示
8-
#- colon
9-
#- control_statement
10-
#- file_length
11-
#- force_cast
12-
#- function_body_length
13-
#- leading_whitespace
14-
#- line_length
15-
#- nesting
16-
#- operator_whitespace
17-
#- return_arrow_whitespace
18-
#- todo
19-
#- trailing_newline
20-
#- variable_name_max_length
21-
#- variable_name_min_length
22-
#- type_body_length
23-
- variable_name
24-
- function_parameter_count
25-
26-
# 一行の文字列制限を100文字から300文字に変更
27-
line_length:
28-
- 800
29-
30-
file_length:
31-
- 800
4+
- type_name
325

33-
excluded: # Lint対象から外すファイルのあるパスを記述
6+
excluded:
347
- reddift/vendor
358
- reddift.playground
369
- reddiftTests
3710
- reddiftSample
3811
- reddiftSampleTV
3912

40-
# クラスの行数
13+
file_length:
14+
warning: 800
15+
error: 1000
16+
17+
line_length:
18+
warning: 800
19+
error: 1000
20+
4121
type_body_length:
42-
- 400 # warning
43-
- 800 # error
22+
warning: 400
23+
error: 800
4424

45-
# 変数名の最大文字数
46-
variable_name_max_length:
47-
- 60 # warning
48-
- 80 # error
25+
variable_name:
26+
max_length:
27+
warning: 50
28+
error: 40
29+
min_length:
30+
warning: 1
31+
error: 0
4932

50-
# 変数名の最小文字数
51-
variable_name_min_length:
52-
- 1 # warning
53-
- 0 # error
33+
function_parameter_count:
34+
warning: 10
35+
error: 20
5436

55-
# 関数の長さ
5637
function_body_length:
57-
- 100 # warning
58-
- 200 # error
38+
warning: 100
39+
error: 200
5940

6041
cyclomatic_complexity:
61-
- 100
42+
warning: 50
43+
error: 100

reddift.xcodeproj/project.pbxproj

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@
12381238
14364C891BEDA09F00FECE58 /* Frameworks */,
12391239
14364C8A1BEDA09F00FECE58 /* Headers */,
12401240
14364C8B1BEDA09F00FECE58 /* Resources */,
1241+
146576321CC85E1D005ED404 /* Swiftlint */,
12411242
);
12421243
buildRules = (
12431244
);
@@ -1289,8 +1290,8 @@
12891290
isa = PBXNativeTarget;
12901291
buildConfigurationList = 14B5EBC41AF34D590065BC5E /* Build configuration list for PBXNativeTarget "reddift-iOS" */;
12911292
buildPhases = (
1292-
14B5EBAC1AF34D580065BC5E /* Sources */,
12931293
14E4D64C1C94473F00442A4A /* Swiftlint */,
1294+
14B5EBAC1AF34D580065BC5E /* Sources */,
12941295
14B5EBAD1AF34D580065BC5E /* Frameworks */,
12951296
14B5EBAE1AF34D580065BC5E /* Headers */,
12961297
14B5EBAF1AF34D580065BC5E /* Resources */,
@@ -1349,6 +1350,7 @@
13491350
14F811FC1AF9EA9F008F6F3C /* Frameworks */,
13501351
14F811FD1AF9EA9F008F6F3C /* Headers */,
13511352
14F811FE1AF9EA9F008F6F3C /* Resources */,
1353+
146576331CC85E32005ED404 /* Swiftlint */,
13521354
);
13531355
buildRules = (
13541356
);
@@ -1595,6 +1597,34 @@
15951597
/* End PBXResourcesBuildPhase section */
15961598

15971599
/* Begin PBXShellScriptBuildPhase section */
1600+
146576321CC85E1D005ED404 /* Swiftlint */ = {
1601+
isa = PBXShellScriptBuildPhase;
1602+
buildActionMask = 2147483647;
1603+
files = (
1604+
);
1605+
inputPaths = (
1606+
);
1607+
name = Swiftlint;
1608+
outputPaths = (
1609+
);
1610+
runOnlyForDeploymentPostprocessing = 0;
1611+
shellPath = /bin/sh;
1612+
shellScript = "if which swiftlint >/dev/null; then\n echo \"SwiftLint\"\n swiftlint\nelse\n echo \"SwiftLint does not exist, download from https://github.com/realm/SwiftLint\"\nfi";
1613+
};
1614+
146576331CC85E32005ED404 /* Swiftlint */ = {
1615+
isa = PBXShellScriptBuildPhase;
1616+
buildActionMask = 2147483647;
1617+
files = (
1618+
);
1619+
inputPaths = (
1620+
);
1621+
name = Swiftlint;
1622+
outputPaths = (
1623+
);
1624+
runOnlyForDeploymentPostprocessing = 0;
1625+
shellPath = /bin/sh;
1626+
shellScript = "if which swiftlint >/dev/null; then\n echo \"SwiftLint\"\n swiftlint\nelse\n echo \"SwiftLint does not exist, download from https://github.com/realm/SwiftLint\"\nfi";
1627+
};
15981628
14E4D64C1C94473F00442A4A /* Swiftlint */ = {
15991629
isa = PBXShellScriptBuildPhase;
16001630
buildActionMask = 2147483647;

reddift/Network/Session+users.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public enum FriendType: String {
2424
case Friend = "friend"
2525
case Enemy = "enemy"
2626
case Moderator = "moderator"
27-
case ModeratorInvite = "moderator_invite"
27+
case ModeratorInvite = "moderator_invite"
2828
case Contributor = "contributor"
2929
case Banned = "banned"
3030
case Muted = "muted"

reddift/Utility/helper.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,23 @@ extension Dictionary {
1919
}
2020
}
2121

22+
2223
extension Bool {
2324
var string: String {
2425
return self ? "true" : "false"
2526
}
2627
}
2728

28-
private var time_buffer: timeval = timeval(tv_sec: 0, tv_usec: 0)
29+
private var timeBuffer: timeval = timeval(tv_sec: 0, tv_usec: 0)
2930

3031
func tic() {
31-
gettimeofday(&time_buffer, nil)
32+
gettimeofday(&timeBuffer, nil)
3233
}
3334

3435
func toc() {
3536
var time_buffer2: timeval = timeval(tv_sec: 0, tv_usec: 0)
3637
gettimeofday(&time_buffer2, nil)
37-
let diff = time_buffer2.tv_sec - time_buffer.tv_sec
38-
let diff_u = time_buffer2.tv_usec - time_buffer.tv_usec
38+
let diff = time_buffer2.tv_sec - timeBuffer.tv_sec
39+
let diff_u = time_buffer2.tv_usec - timeBuffer.tv_usec
3940
print("\(diff * 1000000 + diff_u)[msec]")
4041
}

0 commit comments

Comments
 (0)