-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.rubocop.yml
More file actions
171 lines (143 loc) · 5.47 KB
/
.rubocop.yml
File metadata and controls
171 lines (143 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://docs.rubocop.org/rubocop/configuration
require:
- rubocop-rspec
AllCops:
TargetRubyVersion: 3.1
NewCops: enable
Exclude:
- "bin/*"
- "vendor/**/*"
- "db/schema.rb"
- "db/migrate/**/*.rb"
- "lib/openapi/**/*"
Metrics/BlockLength:
Exclude:
- "lib/tasks/**/*"
- "config/routes.rb"
- "config/environments/*.rb"
- "config/initializers/*.rb"
- "test/**/*"
- "spec/**/*"
Lint/EmptyBlock:
Exclude:
- "test/factories/**/*.rb"
# blockの書き方を、関数か手続きかで書き分けることで意図を伝えたい
Style/BlockDelimiters:
EnforcedStyle: semantic
# single linerに限って { } を許す(モデルやコントローラのDSLをdo..endで改行すると冗長になるので)
AllowBracesOnProceduralOneLiners: true
# let, beforeブロックやfactoryの書き方はDSLの慣習に合わせたいので緩めておく
Exclude:
- "spec/**/*.rb"
# classにドキュメント必須とはしない(乖離が生まれるためコードを正とする)
Style/Documentation:
Enabled: false
# 日本語によるコードコメントを許可。開発チームが多国籍化する場合は再検討
Style/AsciiComments:
Enabled: false
# single-linerを強制せず、明示的にIFブロックを示すことを許す
Style/IfUnlessModifier:
Enabled: false
Style/RedundantFetchBlock:
# railsの設定ファイルはデフォルトでfetchにブロックを利用するため、そちらの記法に合わせておく
Exclude:
- "config/**/*.rb"
# Style/HashSyntax:
# # TODO: defaultの `always`だと違反コードが目立つため、いったんは旧来のRubyistが
# # 慣れている冗長な書き方を許可する。
# # どこかの時点でこれを外し、新しいシンタックスに一括移行したい
# EnforcedShorthandSyntax: either
Style/RescueModifier:
Exclude:
- "spec/**/*_spec.rb"
# spec内ではDSL的に見やすい記法を許可する
# (require_parenthesis, omit_parenthesisいずれも強制せず、実装者に委ねる)
Style/MethodCallWithArgsParentheses:
Exclude:
- "spec/**/*_spec.rb"
# 最終要素の追加・削除時に他の要素に差分が出ることがあるため、いわゆるケツカンマを許可する
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma
Style/FrozenStringLiteralComment:
# 本番でrequireされない場所は高速化に寄与しないため、実装の簡便さのために許可しておく
Exclude:
- "db/**/*/"
- "lib/tasks"
Metrics/MethodLength:
Enabled: true
CountComments: false
Max: 20
Layout/HashAlignment:
EnforcedHashRocketStyle: "table"
EnforcedColonStyle: "table"
Layout/LineLength:
Max: 130
AllowedPatterns: ['(\A|\s)#'] # ignore comments
Exclude:
- "db/fixtures/**"
- "spec/**/*"
- "config/initializers/*.rb"
Metrics/AbcSize:
Max: 20
Style/StringLiterals:
Enabled: false
# ブロック表記を明示的にしておきます。(暗黙のブロック引数のバケツリレーを期待していると、引数漏れに気づかないので)
# https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Naming/BlockForwarding
Naming/BlockForwarding:
EnforcedStyle: explicit
RSpec/ExampleLength:
# 配列やハッシュは記法により行数を稼ぐため許可しておく
CountAsOne: ["array", "hash", "heredoc"]
# system specはシナリオテストのため長くなることを受け入れる
Exclude:
- "spec/system/**/*"
RSpec/MultipleExpectations:
# system specにかぎって複数の期待値を許可する
Exclude:
- "spec/system/**/*"
RSpec/ExampleWithoutDescription:
EnforcedStyle: single_line_only
RSpec/NestedGroups:
# request specやmodelの責務が大きなメソッドのテストで複合条件を表現するために
# contextを重ねることがあるため、条件を緩和しています (default Max: 3)
Max: 8
RSpec/NamedSubject:
# 副作用のテストをする際にsubjectを単体で使うことが多い。各テストでsubjectとして
# テスト対象を明示することを迂回させたくないのと、named subjectでなければ読みづらい
# ケースが特にみられないので切っておく
Enabled: false
RSpec/MultipleMemoizedHelpers:
# テストケースのコンテキストが複合していくと増えてしまうため、現状に合わせておく(default 5)
# 特に依存関係が深いパターンが多いがrspec-parameterizedなどを使って利用を減らす
Max: 10
RSpec/ContextWording:
Prefixes:
- when
- with
- without
- if
- unless
- for
- before
- after
- in
AllowedPatterns:
- /とき$/
- /時$/
- /場合$/
RSpec/IndexedLet:
# テストケース中で特に区別する理由のない2つのレコードにindexを多用しているが
# 変数名には適切な意図が表現されるよう意識されていることが多く現状それほど困っていない。
# 実装の簡便性を重視しいったん黙らせる。
Enabled: false