Skip to content

Commit 82812f2

Browse files
committed
Update .swiftlint.yml
1 parent da72b43 commit 82812f2

File tree

3 files changed

+52
-22
lines changed

3 files changed

+52
-22
lines changed

.swiftlint.yml

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
1+
# Note 1: 가독성 개선 및 코드 간략화를 위함
2+
# Note 2: Xcode 에디터 특성상 의미 없음
3+
# Note 3: VC 구조상 지킬 수 없음
4+
# Note 4: API 관련 Data class와 JSI 설계를 위함
5+
# Note 5: 속도 향상을 위함
6+
# Note 6: ObjC 스타일의 네이밍을 사용하기 때문에 지킬 수 없음
7+
# (Swift에 rename refactor가 지원되기 전까지는 ObjC 스타일을 유지할 예정)
8+
# Note 7: 추후 RxSwift 및 Swift3 대응으로 해결할 예정
9+
10+
disabled_rules:
11+
# Global
12+
- file_length # 파일 길이 제한 없음 (Note 3)
13+
- for_where # for-in-where 강제 안함 (Note 1)
14+
- force_cast # 강제 cast 허용 (Note 1)
15+
- force_try # 강제 try 허용 (Note 1)
16+
- function_body_length # 함수 구현부 길이 제한 없음 (Note 1)
17+
- function_parameter_count # 함수 파라메터 갯수 제한 없음 (Note 4)
18+
- line_length # 행 길이 제한 없음 (Note 2)
19+
- todo
20+
- trailing_whitespace # 구문 줄 바꿈 허용 (Note 1)
21+
- type_body_length # 타입 선언부 길이 제한 없음 (Note 3)
22+
- variable_name # 변수명 길이 제한 없음 (Note 4)
23+
- vertical_whitespace # 수직 여백 허용 (Note 1)
24+
# WKJavaScriptController
25+
- cyclomatic_complexity # 복잡도 무시 (Note 7)
26+
27+
opt_in_rules:
28+
- empty_count # isEmpty 사용 강제 (Note 1, 5)
29+
- closure_end_indentation # 클로저의 시작과 끝의 들여쓰기를 동일하게 맞추도록 (Note 1)
30+
- closure_spacing # 클로저 표현식의 시작과 끝에 공백을 넣도록 (Note 1)
31+
- explicit_init # 명시적인 init 호출을 하지 않도록 (Note 1)
32+
- first_where # `.filter { … }.first` 보다 `.first(where: { … })`를 사용하도록 (Note 1, 5)
33+
134
included:
235
- WKJavaScriptController
336
- WKJavaScriptController-Demo
437

538
excluded:
639
- Pods
7-
8-
variable_name:
9-
min_length:
10-
warning: 0
11-
error: 0
12-
13-
disabled_rules:
14-
- file_length
15-
- force_cast
16-
- force_try
17-
- function_body_length
18-
- function_parameter_count
19-
- todo
20-
- type_body_length
21-
- line_length
22-
- trailing_whitespace
23-
- cyclomatic_complexity
24-
- variable_name

WKJavaScriptController-Demo/WKJavaScriptController-Demo.xcodeproj/project.pbxproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
buildConfigurationList = 83FA359C1E2C5C6900A6B171 /* Build configuration list for PBXNativeTarget "WKJavaScriptController-Demo" */;
103103
buildPhases = (
104104
7C3475A598746FB73315144A /* [CP] Check Pods Manifest.lock */,
105+
83054A791F0C76460001C4B0 /* SwiftLint Script */,
105106
83FA35861E2C5C6900A6B171 /* Sources */,
106107
83FA35871E2C5C6900A6B171 /* Frameworks */,
107108
83FA35881E2C5C6900A6B171 /* Resources */,
@@ -198,6 +199,20 @@
198199
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
199200
showEnvVarsInLog = 0;
200201
};
202+
83054A791F0C76460001C4B0 /* SwiftLint Script */ = {
203+
isa = PBXShellScriptBuildPhase;
204+
buildActionMask = 2147483647;
205+
files = (
206+
);
207+
inputPaths = (
208+
);
209+
name = "SwiftLint Script";
210+
outputPaths = (
211+
);
212+
runOnlyForDeploymentPostprocessing = 0;
213+
shellPath = /bin/sh;
214+
shellScript = "function toVersion { echo -e \"$@\" | awk -F. '{ printf(\"%d%03d%03d%03d\\n\", $1,$2,$3,$4); }'; }\nif which swiftlint >/dev/null; then\n current=$(swiftlint version)\n require=\"0.20.0\"\n if [ $(toVersion \"$current\") -ge $(toVersion \"$require\") ]; then\n cd \"${PROJECT_DIR}/../\"\n swiftlint\n else\n echo \"SwiftLint requires a SwiftLint version of >= $require. You are on $current.\"\n echo \"Please update using 'brew upgrade swiftlint'.\"\n exit 101\n fi\nelse\n echo \"SwiftLint does not exist, download from https://github.com/realm/SwiftLint\"\n exit 100\nfi";
215+
};
201216
FAD7856FCA59270D07D9FB11 /* [CP] Embed Pods Frameworks */ = {
202217
isa = PBXShellScriptBuildPhase;
203218
buildActionMask = 2147483647;

WKJavaScriptController/WKJavaScriptController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ open class WKJavaScriptController: NSObject {
152152
guard let selector = list?.pointee.name,
153153
let types = list?.pointee.types,
154154
let signature = String(cString: types, encoding: String.Encoding.utf8) else {
155-
log("Method signature not found, so it was excluded. (selector: \(list?.pointee.name ?? "nil"))")
155+
log("Method signature not found, so it was excluded. (selector: \(list?.pointee.name ?? Selector(("nil"))))")
156156
continue
157157
}
158158

@@ -272,7 +272,7 @@ extension WKJavaScriptController: WKScriptMessageHandler {
272272
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
273273
guard let target = target,
274274
let args = message.body as? [Arg],
275-
let bridge = bridgeList.filter({ $0.jsSelector == message.name }).first else {
275+
let bridge = bridgeList.first(where: { $0.jsSelector == message.name }) else {
276276
return
277277
}
278278

@@ -318,7 +318,7 @@ extension WKJavaScriptController: WKScriptMessageHandler {
318318
let userInfo = [
319319
"nativeSelector": bridge.nativeSelector,
320320
"jsSelector": bridge.jsSelector,
321-
"args": args,
321+
"args": args
322322
] as [String: Any]
323323
NotificationCenter.default.post(name: WKJavaScriptControllerWillMethodInvocationNotification, object: nil, userInfo: userInfo)
324324

@@ -329,7 +329,7 @@ extension WKJavaScriptController: WKScriptMessageHandler {
329329
"nativeSelector": bridge.nativeSelector,
330330
"jsSelector": bridge.jsSelector,
331331
"args": args,
332-
"reason": "Arguments has NSNull(=undefined).",
332+
"reason": "Arguments has NSNull(=undefined)."
333333
] as [String: Any]
334334
NotificationCenter.default.post(name: WKJavaScriptControllerIgnoredMethodInvocationNotification, object: nil, userInfo: userInfo)
335335
return

0 commit comments

Comments
 (0)