LoginSignup
3
3

More than 5 years have passed since last update.

RuboCop | Style/Semicolon

Last updated at Posted at 2014-07-22

RuboCop | Style/Semicolon

概要

RuboCopの「Style/Semicolon」警告について。

セミコロンによって、同一行に複数ステートメントを記述しているかをチェックします。
デフォルトではセミコロンによる複数ステートメントの記述を認めません。

Semicolon

各設定値での検証結果をまとめます。

検証プログラム

predicate_name.rb
msg = 'hoge'; print msg

実行結果 デフォルト の場合

.rubocop.yml
Semicolon:
  AllowAsExpressionSeparator: false
$ rubocop semicolon.rb
Inspecting 1 file
C

Offenses:

semicolon.rb:1:13: C: Do not use semicolons to terminate expressions.
msg = 'hoge'; print msg
            ^

1 file inspected, 1 offense detected

実行結果 独自定義で hoge を追加, is/has_/have_ は無効にします

.rubocop.yml
Semicolon:
  AllowAsExpressionSeparator: true
$ rubocop semicolon.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

補足

この警告は rubocop -a で修正可能です。

RuboCopまとめ記事

3
3
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
3
3