LoginSignup
4
4

More than 5 years have passed since last update.

SwiftLint 0.7.1 アップデート内容まとめ

Last updated at Posted at 2016-01-28

強化されたもの

MissingDocsRule

パフォーマンスが上がりました。

CustomRules

新しく追加されたルールです。名前の通り、ルールをカスタマイズして追加することができます。
ただしものすごく自由にカスタマイズできるわけではなく、「正規表現ベースのルール」という制限があります。
書き方は以下のようになります(公式のDefining Custom Rulesから抜粋)。

custom_rules:
  dont_use_str: # rule identifier
    name: "Don't use 'str'" # rule name. optional.
    regex: "(str)" # matching pattern
    match_kinds: # SyntaxKinds to match. optional.
      - doccomment
    message: "Don't use 'str' in doc comment and parameter." # violation message. optional.
    severity: error # violation severity. optional.

上記の例の場合、ドキュメントコメントの中に”str”という文字列が存在していたらエラーを出す、というルールになります。
なので、以下のような結果になります。
ドキュメントコメント中の”str”にはエラーが出ていますが、メソッドの引数部分、メソッド内部の”str”にはエラーが出ていません。

スクリーンショット 2016-01-28 10.05.23.png

ちなみにmatch_kindsには以下の種類があります。
これらの値は(全部かはわかりませんが)SourceKittenから来ているみたいですね。
なのでこれらが具体的に何を指すのかはSourceKittenをご参照ください。

  • argument
  • attribute.builtin
  • attribute.id
  • buildconfig.id
  • buildconfig.keyword
  • comment
  • comment.mark
  • comment.url
  • doccomment
  • doccomment.field
  • identifier
  • keyword
  • number
  • objectliteral
  • parameter
  • placeholder
  • string
  • string_interpolation_anchor
  • typeidentifier

ForceUnwrappingRule

全てのforced unwrapに対して警告が出されるようになりました。

バグFix

ValidDocsRuleに存在していたいくつかの偽陽性が修正されました。
※偽陽性
今回の場合で言うと、「本当はvalidなのにinvalidと判定された」ということになると思います。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4