Swiftがオープンソース化されたことで、多くのオープンソース・ソフトウェアが生み出されています。かつ、それらはMac OSX以外のプラットフォームでも使えるようになっています。 Tailorもそんなオープンソース化に伴って生まれたソフトウェアで、Swiftのコードを静的解析してくれます。

Tailorの使い方

Tailorはプロジェクトをまとめて解析してくれます。例えば次のように実行します。

$ tailor .

********** /SwiftExample/AppDelegate.swift **********
SwiftExample/AppDelegate.swift:13:28: warning: [trailing-whitespace] Line should not have any trailing whitespace
SwiftExample/AppDelegate.swift:23:29: warning: [colon-whitespace] Colon at column 29 should have exactly one space after it
SwiftExample/AppDelegate.swift:24:20: warning: [redundant-parentheses] Conditional clause should not be enclosed within parentheses
SwiftExample/AppDelegate.swift:27:22: warning: [brace-style] Opening brace should have exactly one space before it
SwiftExample/AppDelegate.swift:28:28: warning: [colon-whitespace] Colon at column 28 should have exactly one space after it
SwiftExample/AppDelegate.swift:29:57: warning: [colon-whitespace] Colon at column 57 should have exactly one space after it
SwiftExample/AppDelegate.swift:31:28: warning: [redundant-parentheses] Conditional clause should not be enclosed within parentheses
SwiftExample/AppDelegate.swift:38:18: warning: [brace-style] Opening brace should have exactly one space before it
SwiftExample/AppDelegate.swift:69:    warning: [terminating-newline] File should terminate with exactly one newline character ('\n')

********** SwiftExample/ViewController.swift **********
SwiftExample/ViewController.swift:12:28: warning: [trailing-whitespace] Line should not have any trailing whitespace
SwiftExample/ViewController.swift:25:    warning: [terminating-newline] File should terminate with exactly one newline character ('\n')

Analyzed 2 files, skipped 0 files, and detected 11 violations (0 errors, 11 warnings).

このように解析したファイル数、警告やエラーなどが一覧になって表示されます。Lint系なので厳しくチェックしてくれるでしょう。さらにWindowsやLinuxでも動作したり、Mac OSXであればXcodeのバージョンを指定して実行もできます。

TailorはJava/Ruby/Python製のオープンソース・ソフトウェア(MIT License)です。

Tailor sleekbyte/tailor