Skip to content

Instantly share code, notes, and snippets.

@SatoshiN303
Created June 3, 2020 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SatoshiN303/9e651f2c9094ee82861211b1395e70dd to your computer and use it in GitHub Desktop.
Save SatoshiN303/9e651f2c9094ee82861211b1395e70dd to your computer and use it in GitHub Desktop.
.swiftlint.yml
###===Rules
#
# https://github.com/realm/SwiftLint/blob/master/Rules.md
#
# 除外ディレクトリ
excluded:
- Carthage
- Pods
- fastlane
- SPN-app-ios/Helpers/R-Swift/R.generated.swift
- SPN-app-ios/Swaggers
- SPN-app-iosTests
- SPN-app-iosUITests
- vendor
# 無効にするルール
disabled_rules:
- identifier_name # 変数などの識別子
- line_length # 1 行の長さ
- trailing_whitespace # 行末に余計なスペース
- force_try # try!
- explicit_type_interface # プロパティ宣言時の型の明記必須
- fatal_error_message # fataleError呼び出し時のメッセージ必須
- switch_case_on_newline # switch文におけるcaseの各処理は改行した後書く
- todo
- cyclomatic_complexity # 一旦外す TODO: 戻す
# error 扱いにするルール
force_cast: error # [NG] as!
force_unwrapping: error # [NG] value!
opening_brace: error # [NG] if x == 0{ / [OK] if x == 0 {
statement_position: error # [NG] if x == 0 \n { / [OK] if x == 0 {
return_arrow_whitespace: error # [NG] func foo()->Int / [OK] func foo() -> Int
colon: # [NG] let x:Int = 0 / [OK] let x: Int = 0
severity: error
comma: # [NG] foo(x,y , z) / [OK] foo(x, y, z)
severity: error
control_statement: # [NG] if (x == 0) / [OK] if x == 0
severity: error
#cyclomatic_complexity: # [NG] 関数内の複雑性(ネストの深いifやifの連続)は程々にしましょう
# severity: error
# 変数名命名規則(id,x,y,z 以外に適用)
variable_name:
max_length:
warning: 30
error: 40
min_length:
warning: 3
error: 0
excluded:
- id
- x
- y
- z
# 1行あたりの文字数制限を300に変更
# プロジェクト作成時にデフォルトで追加されるコメントをひっかけないため
line_length: 300
# デフォルト無効のルールで有効にするもの
opt_in_rules:
- force_cast # [NG] as!
- force_unwrapping # [NG] value!
#- attributes
- closure_end_indentation
- closure_spacing
- empty_count
- explicit_init
- explicit_type_interface # クラス変数とかインスタンス変数とかには"型"を記述した方がいい
- fatal_error_message # fatalErrorを使う場合はメッセージを記述した方がいい
#- implicitly_unwrapped_optional # 暗黙的なUnwrapはやめた方がいい
- object_literal
- operator_usage_whitespace
- overridden_super_call
#- private_outlet         # IBOutletはprivateにしたほうが良い
- prohibited_super_call
- redundant_nil_coalescing
#- sorted_imports # import部分はソートされているべき
- switch_case_on_newline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment