Skip to content

Instantly share code, notes, and snippets.

@tkawa
Last active May 10, 2018 08:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkawa/933f1b9773af21c2fbd5e0ca4bd8a03f to your computer and use it in GitHub Desktop.
Save tkawa/933f1b9773af21c2fbd5e0ca4bd8a03f to your computer and use it in GitHub Desktop.
Rubocop settings
# cf.
# http://nttpc.now.tl/ac2014/?p=20#toc_4
# https://github.com/cookpad/styleguide/blob/master/ruby.ja.md
# https://gist.github.com/onk/38bfbd78899d892e0e83
# https://github.com/onk/onkcop/blob/master/config/rubocop.yml
AllCops:
DisplayCopNames: true
Exclude:
- db/schema.rb
- db/migrate/*
- config/unicorn/*
- tmp/**/*
- vendor/**/*
TargetRubyVersion: 2.3
## Style
# メソッド名のprefixに `set_`, `get_` を許可
Style/AccessorMethodName:
Enabled: false
# できるだけ alias より alias_method を使う
Style/Alias:
EnforcedStyle: prefer_alias_method
# メソッド呼び出しの行から1段階インデントする
Style/AlignParameters:
EnforcedStyle: with_fixed_indentation
# 日本語でのコメントを許可
Style/AsciiComments:
Enabled: false
# モジュール名::クラス名の定義を許可
Style/ClassAndModuleChildren:
Enabled: false
# コメントのないクラス・モジュールを許可
Style/Documentation:
Enabled: false
# !! 演算子を許可
Style/DoubleNegation:
Enabled: false
# nil を返す else を許可
Style/EmptyElse:
EnforcedStyle: empty
# `sprintf`, `format` ではなく String#% を使う
Style/FormatString:
EnforcedStyle: percent
# frozen_string_literal マジックコメントはまだつけない
Style/FrozenStringLiteralComment:
Enabled: false
# 5行以上の場合ガード節を使用するようチェック
Style/GuardClause:
MinBodyLength: 5
# 1行だけの if/unless を許可
Style/IfUnlessModifier:
Enabled: false
# lambda はすべて `->` リテラルで書く
Style/Lambda:
EnforcedStyle: literal
# 12桁以上の数値にはアンダースコアをつける
Style/NumericLiterals:
MinDigits: 12
# 正規表現参照の $1, $2,... を許可
Style/PerlBackrefs:
Enabled: false
# Exception.new(arg) を渡す raise を許可
Style/RaiseArgs:
Enabled: false
# ローカル変数とメソッド呼び出しを区別しやすくするため `self.` をつけてもよい
Style/RedundantSelf:
Enabled: false
# fail/raiseを使い分けなくてもよい
Style/SignalException:
Enabled: false
# 1行の inject ブロック引数も適切に名前を付ける
Style/SingleLineBlockParams:
Enabled: false
# メソッド引数の初期値の周りにはスペースを入れる
Style/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: space
# ブロックの直前にはスペースを入れる
Style/SpaceBeforeBlockBraces:
EnforcedStyle: space
# Rangeリテラルの内側にスペースを許可
Style/SpaceInsideRangeLiteral:
Enabled: false
# 可能な限りシングルクォートを使う
Style/StringLiterals:
EnforcedStyle: single_quotes
# 最後の余分なcommaを許可(リテラル)
Style/TrailingCommaInLiteral:
Enabled: false
## Lint
# 条件文の中での代入を許可
Lint/AssignmentInCondition:
Enabled: false
# 何もしないrescueを許可
Lint/HandleExceptions:
Enabled: false
# `_` で始まる変数名を許可
Lint/UnderscorePrefixedVariableName:
Enabled: false
## Rails
Rails:
Enabled: true
# Date.today, Date#to_time はtimezoneを考慮しないので使わない
# current, yesterday, tomorrow は許可
Rails/Date:
EnforcedStyle: flexible
# validates_xxx_of を許可
Rails/Validation:
Enabled: false
## Metrics(指摘しますが努力目標)
# 代入、メソッド呼び出し、条件文の合計数
Metrics/AbcSize:
Max: 30
# 条件文の数
Metrics/CyclomaticComplexity:
Max: 10
# 1行の文字数
Metrics/LineLength:
Max: 160
# メソッドの行数
Metrics/MethodLength:
Max: 30
# 条件分岐の数
Metrics/PerceivedComplexity:
Max: 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment