2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RuboCop | Style/MethodName

Last updated at Posted at 2014-07-13

RuboCop | Style/MethodName

概要

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

メソッド名をチェックします。
デフォルトはsanake caseを正とします。

設定値一覧

設定対象 設定値 内容 デフォルト
EnforcedStyle snake_case sanake caseではない場合は警告する
EnforcedStyle camelCase camel caseではない場合は警告する --

MethodName

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

検証プログラム

method_name.rb

def snake_case
  puts 'snake'
end

def camelCase
  puts 'camel'
end

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

.rubocop.yml

MethodName:
  EnforcedStyle: snake_case
$rubocop method_name.rb
Inspecting 1 file
C

Offenses:

method_name.rb:5:5: C: Use snake_case for methods.
def camelCase
    ^^^^^^^^^

1 file inspected, 1 offense detected

実行結果 camelCase に設定します

.rubocop.yml

MethodName:
  EnforcedStyle: camelCase
$rubocop method_name.rb
Inspecting 1 file
C

Offenses:

method_name.rb:1:5: C: Use camelCase for methods.
def snake_case
    ^^^^^^^^^^

1 file inspected, 1 offense detected

RuboCopまとめ記事

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?