-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rubocop.yml
172 lines (138 loc) · 5.28 KB
/
.rubocop.yml
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
172
require:
- rubocop-rails
- rubocop-capybara
- rubocop-factory_bot
# Exclude entire directories/files from being linted.
AllCops:
# Enable newly added cops by default.
NewCops: enable
Exclude:
- '**/*.slim'
- 'lib/tasks/local.rake' # For running random stuff in dev.
- 'db/' # schema and migrations
# The ordering of gems in the Gemfile make sense, keeping Rails stuff
# at the top, and organizing under different comment sections. Additionally,
# some gems are order-dependant.
Bundler/OrderedGems:
Enabled: false
# Default is 80, which seemed a bit restrictive. The team discussed and decided to
# try 120.
Layout/LineLength:
Max: 120
# Reasoning: other values lead to too much indentation
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
# Methods that take a single array or hash are quite readable when the method
# parentheses and the hash brace (or array bracket) are on the same line. The
# default is annoying to line up right and wastes space (potentially pushing
# us into lines that are too long).
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
# Enforce either the table-style (aligned values) or normal style.
Layout/HashAlignment:
EnforcedColonStyle:
- key
- table
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/StructNewOverride:
Enabled: true
Lint/UnusedMethodArgument:
AutoCorrect: false
# Reasoning: these can happen pretty frequently and tend to cover up more important
# style violations. We may want to consider being more surgical in disabling them.
Metrics/BlockLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
# This is generally a good idea, but ViewComponent parameters are always named and we
# want them to more or less feel like custom HTML tags, where the named parameters map
# to attributes. HTML tags don't really put a limit on the number of attributes, and
# allowing more attributes here encourages making components a little more multi-purpose.
# We might want to adjust a bit if we find allowing so many parameters reduces modularity
# through composition in cases where this makes more sense.
Metrics/ParameterLists:
Exclude:
- 'app/components/**/*.rb'
# Reasoning: without the ability to do this, you often end up reassigning very
# different values to the same variable or creating meaningless intermediate
# variables, which can become more confusing than getting used to block chains.
Style/MultilineBlockChain:
Enabled: false
# There is lots of existing code using %i() etc.
Style/PercentLiteralDelimiters:
PreferredDelimiters:
default: '()'
'%i': '()'
'%w': '()'
'%s': '()'
# Enforcing top level module documentation on helpers isn't really helpful. The
# comment will likely be redundant.
Style/Documentation:
Exclude:
- 'app/**/*.rb'
- 'db/migrate/**/*.rb'
- 'lib/ui/components/previews/**/*.rb'
# We prefer the compact style and saving the level of indentation
Style/ClassAndModuleChildren:
Enabled: false
# This rule has good intent but isn't discriminating enough for cases that really need
# guard clauses vs ones where explicit if statements are more readable. It seems to
# interpret any final if statement as something that should be a guard clause.
Style/GuardClause:
Enabled: false
Style/ExponentialNotation:
Enabled: true
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/HashSyntax:
# We're not sure about the new hash shorthand just yet. We don't want to
# force people to use it, but also don't want to force them to not use it.
EnforcedShorthandSyntax: either
# Don't auto-correct, leave it up to the developer. Sometimes it is clearer to explictly
# return nil.
Style/EmptyElse:
AutoCorrect: false
##############
### Rails Cops
##############
# We are smart enough to know when it's okay to skip model validations.
Rails/SkipsModelValidations:
Enabled: false
# In our code, this seems to almost always be false positives.
# Also, rubocop format broke code autocorrecting this rule
Rails/DynamicFindBy:
Enabled: false
# This suggestion comes up when using add_index in migrations, which is the default
# generated code. Although it looks like using `change_table do |t|` and then `t.index`
# calls in place of `add_index` would be equivalent, it's hard to find any evidence of
# this in practice. Given the lack of direction to avoid triggering this cop (at least
# when adding indexes) and the fact that rails generates it out of the box this way,
# keeping this rule in place only encourages us to leave a cop unaddressed. Silencing
# the cop won't prevent use of bulk operations, of course, and if they become more
# standard so that we're not triggering it with every new table migration we add, then
# we might want to take this out.
Rails/BulkChangeTable:
Enabled: false
# Sometimes we want to direct our output to stdout via puts, instead of defaulting to the
# Rails logger. Don't auto-correct, leave it up to the developer.
Rails/Output:
AutoCorrect: false