-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy path.rubocop.yml
179 lines (141 loc) · 5 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
inherit_from: .rubocop_todo.yml
# Common configuration.
AllCops:
TargetRubyVersion: 3.1.2
Naming/MethodName:
EnforcedStyle: snake_case
Exclude:
# Overriding WEBrick::HTTPServlet::AbstractServlet::do_GET.
# It's not ours to fix, it comes from the WEBrick libraries.
- lib/sitediff/webserver/resultserver.rb
# Check for grouping of accessors in class and module bodies.
# By default it enforces accessors to be placed in grouped declarations
Style/AccessorGrouping:
Enabled: true
#
Style/ArrayCoercion:
Enabled: false
# Check for places where attr_reader and attr_writer for the same method
# can be combined into single attr_accessor
Style/BisectedAttrAccessor:
Enabled: true
# Identifies places where if-elsif constructions can be replaced with case-when
Style/CaseLikeIf:
Enabled: true
# Disable rules enforcing unreadable programming styles.
# Example: Use the return of the conditional for variable assignment
# and comparison
Style/ConditionalAssignment:
Enabled: false
# Require documentation for class methods.
Style/DocumentationMethod:
Enabled: true
# Exponential notation: enforces a mantissa between 1 (inclusive) and 10 (exclusive).
Style/ExponentialNotation:
Enabled: true
# Checks for presence or absence of braces around hash literal as a last array
# item depending on configuration.
Style/HashAsLastArrayItem:
Enabled: true
# Check for uses of `each_key` and `each_value` Hash methods.
Style/HashEachMethods:
Enabled: true
# Check for places where case-when represents a simple 1:1 mapping and
# can be replaced with a hash lookup.
Style/HashLikeCase:
Enabled: true
# Use of `transform_keys`: This cop should only be enabled on Ruby version 2.5 or newer.
Style/HashTransformKeys:
Enabled: false
# Use of `transform_values`.
Style/HashTransformValues:
Enabled: true
# Check this as the value is changed somewhere after initial assignment.
Style/MutableConstant:
Exclude:
- 'lib/sitediff/sanitize/dom_transform.rb'
# Checks for redundant assignment before returning.
Style/RedundantAssignment:
Enabled: true
# Checks for where fetch(key) { value } can be replaced by fetch(key, value)
Style/RedundantFetchBlock:
Enabled: true
# Checks for the presence of superfluous .rb extension in the filename
# provided to require and require_relative.
Style/RedundantFileExtensionInRequire:
Enabled: true
# Check for unnecessary single-element Regexp character classes.
Style/RedundantRegexpCharacterClass:
Enabled: true
# Checks for redundant escapes inside Regexp literals.
Style/RedundantRegexpEscape:
Enabled: true
# Check that arrays are sliced with endless ranges instead of ary[start..-1] on Ruby 2.6+.
Style/SlicingWithRange:
Enabled: true
# Allow developers to write complex code.
Metrics/AbcSize:
Max: 100
# Allow developers to write complex code.
Metrics/CyclomaticComplexity:
Max: 15
# Allow developers to write complex code.
Metrics/PerceivedComplexity:
Max: 15
# Classes can have as many lines as they want.
# Complex classes can have many methods after all.
Metrics/ClassLength:
Enabled: false
# Methods can have a maximum of 128 lines.
# Complex methods might need to be broken in to multiple methods.
Metrics/MethodLength:
Max: 64
CountComments: false
# Methods can have a maximum of 128 lines.
# Complex methods might need to be broken in to multiple methods.
Metrics/BlockLength:
CountComments: false
Max: 64
Exclude:
# Tests can get fairly long, so we ignore them.
- 'spec/**/*_spec.rb'
# Some files have very long lines and need to be ignored.
# Otherwise, we enforce a max-length of 80 characters per line.
Layout/LineLength:
AllowHeredoc: true
AllowURI: true
IgnoredPatterns:
- '^\s*SiteDiff\.log'
- '^\s*run\s'
- '\sif|elsif|unless\s'
Exclude:
- 'Thorfile'
# Spec files contain long strings for testing, so we ignore them.
- 'spec/**/*_spec.rb'
# Checks if empty lines exist around the arguments of a method invocation.
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
# Checks that operators have space around them, except for ** which should or shouldn't have surrounding space.
Layout/SpaceAroundMethodCallOperator:
Enabled: true
# MarshalLoad helps in creating a clone of a Ruby hash, ensuring that it is
# completely disconnected from the original hash. A common way of doing this
# is by serializing an object and then un-serializing it with Marshal.
Security/MarshalLoad:
Exclude:
- 'lib/sitediff/cache.rb'
# Disallow algorithmic constants for OpenSSL::Cipher and OpenSSL::Digest.
Lint/DeprecatedOpenSSLConstant:
Enabled: true
# Check that there are no repeated conditions used in if 'elsif'.
Lint/DuplicateElsifCondition:
Enabled: true
# Do not mix named captures and numbered captures in a Regexp literal.
Lint/MixedRegexpCaptureTypes:
Enabled: true
# This cop checks for `raise` or `fail` statements which are raising `Exception` class.
Lint/RaiseException:
Enabled: true
# Check for unexpected overrides of the `Struct` built-in methods via `Struct.new`.
Lint/StructNewOverride:
Enabled: true