forked from nanoc/nanoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rubocop.yml
237 lines (167 loc) · 5.09 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
inherit_from: .rubocop_todo.yml
# ----- CONFIGURED -----
AllCops:
TargetRubyVersion: 2.4
require: rubocop-rspec
# We use filenames such as “create-site.rb” that translate to method names.
Naming/FileName:
Exclude:
- 'nanoc/lib/nanoc/orig_cli/commands/*.rb'
- 'nanoc-cli/lib/nanoc/cli/commands/*.rb'
- 'nanoc-*/lib/nanoc-*.rb'
- 'guard-nanoc/lib/guard-nanoc.rb'
- '*/*.gemspec'
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
Naming/MethodParameterName:
AllowedNames:
- "to" # destination
- "e" # element
- "id" # identifier
- "io" # IO instance
- "y" # enumerator yielder
# Some specs deal with things that aren’t classes.
RSpec/DescribeClass:
Exclude:
- '*/spec/gem_spec.rb'
- '*/spec/manifest_spec.rb'
- '*/spec/meta_spec.rb'
- 'nanoc/spec/contributors_spec.rb'
- 'nanoc/spec/nanoc/integration/*_spec.rb'
- 'nanoc/spec/nanoc/regressions/*_spec.rb'
- 'nanoc/spec/regression_filenames_spec.rb'
# ----- CONFIGURED (enabled non-default cops) -----
Layout/ClassStructure:
Enabled: true
Include:
- 'nanoc-core/**/*.rb'
# ----- CONFIGURED (exceptions for tests) -----
# This breaks RSpec on occasion, e.g. `expect { subject }.not_to change { foo }`,
# and generally does not provide useful warnings
Lint/AmbiguousBlockAssociation:
Exclude:
- '*/spec/**/*.rb'
# `rescue nil` is useful in specs where the exception is not important, but
# the size effects are.
Style/RescueModifier:
Exclude:
- '*/spec/**/*.rb'
# A common pattern in tests is to define anonymous classes in which methods are defined, which trips
# up Rubocop’s nested method definition cop.
Lint/NestedMethodDefinition:
Exclude:
- '*/test/**/*.rb'
- '*/spec/**/*.rb'
# This is used in tests, to verify the effect of state-changing functions.
Style/GlobalVars:
Exclude:
- '*/test/**/*.rb'
- '*/spec/**/*.rb'
# ----- TO ENABLE LATER -----
# Valid cops, but fixing the offenses they report is non-trivial.
Style/RegexpLiteral:
Enabled: false
Style/EmptyElse:
Enabled: false
Style/Next:
Enabled: false
Naming/HeredocDelimiterNaming:
Enabled: false
Style/EvalWithLocation:
Enabled: false
Naming/MemoizedInstanceVariableName:
Enabled: false
Layout/LineLength:
Enabled: false
# ----- DISABLED (security) -----
# Nanoc runs offline in a trusted environment, and these security checks are false positives.
Security/YAMLLoad:
Enabled: false
Security/MarshalLoad:
Enabled: false
Security/Eval:
Exclude:
- '*/test/**/*.rb'
- '*/spec/**/*.rb'
- 'nanoc/lib/nanoc/filters/erubi.rb'
# ----- DISABLED (metrics) -----
# Cops for metrics are disabled because they should not cause tests to fail.
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/BlockNesting:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
# ----- DISABLED (opinionated) -----
# We should embrace UTF-8, not avoid it. Since the Encoding cop is enabled,
# there’s no point in enforcing ASCII comments.
Style/AsciiComments:
Enabled: false
# It does not make sense to enforce everything to have documentation.
Style/Documentation:
Enabled: false
# Nanoc suppresses exceptions for valid reasons in a few cases.
Lint/SuppressedException:
Enabled: false
# if/unless at the end of the line makes it too easy to oversee.
Style/IfUnlessModifier:
Enabled: false
# Personal preference is to have decent constructors for exceptions rather than
# just a class and a message.
Style/RaiseArgs:
Enabled: false
# Some methods that appear to be accessors (return a single value or set a
# single value) should still not be considered to be accessors. This is a purely
# semantic difference.
Style/TrivialAccessors:
Enabled: false
# This does not always semantically make sense.
Style/GuardClause:
Enabled: false
# Used for “undo work, whatever error happens”
Style/RescueStandardError:
Enabled: false
# For the sake of consistency, it makes the most sense to retain $stderr.puts
# when used in situations where $stderr.flush, $stderr.print, … are also used.
Style/StderrPuts:
Enabled: false
# This catches too many false positives. A string that contains a % followed by
# a letter is not always a format string.
Style/FormatStringToken:
Enabled: false
# ----- DISABLED (buggy) -----
# This cop attempts to replace Nanoc::VERSION with described_class, which makes
# the spec fail.
RSpec/DescribedClass:
Exclude:
- '**/version_spec.rb'
# This turns
#
# expect(File.directory?('output')).to be_falsy
#
# into
#
# expect(File).not_to be_directory('output')
#
# … which does not look right.
RSpec/PredicateMatcher:
Exclude:
- 'nanoc-core/spec/nanoc/core/item_rep_writer_spec.rb'