Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SwiftLint

1,578 views

Published on

関西モバイルアプリ研究会 #10での発表スライドです。

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

SwiftLint

  1. 1. Swi$Lint @ikesyo 関西モバイルアプリ研究会 #10, 2016-01-27 Wed #関モバ
  2. 2. @ikesyo ikesyo_nnid いけしょー/池田翔 京都でフリーランスのiOSエンジニア (時々Android)しています フリュー㈱のモバイル開発の チームにジョイン中。
  3. 3. ✨ Contribu*ons ✨ • Himotoki • Carthage • Reac0veCocoa • APIKit • Result • AMScrollingNavbar
  4. 4. try! Swi)2016.3.2∼2016.3.4 東京・渋谷
  5. 5. 閑話休題
  6. 6. 3人チーム
  7. 7. @yashigani @niwatako @ikesyo <- New❗
  8. 8. コードレビュー • スタイルの指摘に時間取られたくないよね • 自動化 • 余計なことに頭を使わない • ユーザーに価値を届けることに集中するために
  9. 9. Swi$Lint
  10. 10. Swi$Lint • h#ps://github.com/realm/Swi7Lint • $ brew install swiftlint • Swi7用のlintツール • Swi7製 • SourceKi#en • Swi7XPC sourcekitd.h (from apple/swi7) • Commandant • Result • SWXMLHash • YamlSwi7
  11. 11. History • 2015-05-18: 0.1.0 • 2015-10-01: 0.2.0 ... Swi. 2.0, .swiftlint.yml, Custom reporters • 2015-11-04: 0.3.0 • 2015-11-18: 0.4.0 • 2015-12-13: 0.5.0 ... autocorrect • 2016-01-15: 0.6.0 ... Various auto-correc?on, Opt-in rules, Dic?onary format config • 2016-01-25: 0.7.0 ... More configurable rules, CyclomaticComplexityRule • 2016-01-27: 0.7.1 ... Custom Rules through regular expression (#416)
  12. 12. .swi%lint.yml disabled_rules: # rule identifiers to exclude from running - colon - comma - control_statement enabled_rules: # some rules are only opt-in - empty_count - missing_docs # Find all the available rules by running: # swiftlint rules included: # paths to include during linting. `--path` is ignored if present. - Source excluded: # paths to ignore during linting. Takes precedence over `included`. - Carthage - Pods - Source/ExcludedFolder - Source/ExcludedFile.swift
  13. 13. .swi%lint.yml # configurable rules can be customized from this configuration file # binary rules can set their severity level force_cast: warning # implicitly force_try: severity: warning # explicitly # rules that have both warning and error levels, can set just the warning level # implicitly line_length: 110 # they can set both implicitly with an array type_body_length: - 300 # warning - 400 # error # or they can set both explicitly file_length: warning: 500 error: 1200
  14. 14. .swi%lint.yml # naming rules can set warnings/errors for min_length and max_length # additionally they can set excluded names type_name: min_length: 4 # only warning max_length: # warning and error warning: 40 error: 50 excluded: iPhone # excluded via string variable_name: min_length: # only min_length error: 4 # only error excluded: # excluded via string array - id - URL - GlobalAPIKey reporter: "csv" # reporter type (xcode, json, csv, checkstyle)
  15. 15. Nested Configura/ons • use_nested_configs: true • ルート階層の設定と、特定のディレクトリ以下で設定を変えた い場合
  16. 16. Disable a rule in code 例外を弾いてルール全体を無効化しないようにする。 // swiftlint:disable colon let noWarning :String = "" // ここは警告されない // swiftlint:enable colon let hasWarning :String = "" // ここは警告される // swiftlint:disable:next force_cast <- 次の行だけ無効 let noWarning = NSNumber() as! Int let hasWarning = NSNumber() as! Int let noWarning2 = NSNumber() as! Int // swiftlint:disable:this force_cast <- この行だけ無効 let noWarning3 = NSNumber() as! Int // swiftlint:disable:previous force_cast <- 前の行だけ無効
  17. 17. Auto-correct • swiftlint autocorrect • 一部のルールでは自動修正が可能 (0.7.0時点で以下の10個) • closing_brace, colon, comma • legacy_constant, legacy_constructor, opening_brace • statement_posi;on, trailing_newline • trailing_semicolon, trailing_whitespace • disabled_rules にあるものは修正もされない。 • 差分を少なくしながら導入できる !
  18. 18. To contribute • Improve lin-ng performance (let's follow @norio-nomura! !) • Implement new rules • Fix bugs • ...
  19. 19. ! Happy Swi) lin,ng!! !
  20. 20. Thank you❗"

×