-
Notifications
You must be signed in to change notification settings - Fork 9
/
.rubocop.yml
116 lines (88 loc) · 4.16 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
inherit_from: .rubocop_todo.yml
require:
- rubocop-rspec
# Enable new cops when we update rubocop to a newer version
AllCops:
NewCops: enable
########## Lint / CodeStyle
# Especially for actions and methods like `self.run(params)` it's common to have the argument unused; but that
# comes with the parent class API / contract, so we feel it more readable to avoid the _ unused prefix for those.
Lint/UnusedMethodArgument:
Enabled: false
# Using trailing if/unless when the body is a one-liner is nice. But usually when we choose to use the if/unless
# as a control-flow construct rather than trailing modifier, it's because the line length of the body is long already;
# so in those cases it's still nice to avoid making even longer lines if we were using the trailing modifier construct.
Style/IfUnlessModifier:
Enabled: false
# We have a couple of empty methods especially when we implement an API contract on our Action subclasses
# and those look nicer to us when still written as expended (in separate lines) to suggest us to fill them at some point
# rather than the compact representation of having them one-liner `def foo; end` that is rubocop's default.
Style/EmptyMethod:
EnforcedStyle: expanded
# Trailing commas in array literals helps having smaller diffs when we want to add additional parameters
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
# Enabling the 'frozen_string_literal: true' comment is nice but should be done with extra care
# because enabling it on code that accidentally mutates string literals will crash at runtime
# (e.g. `name = 'Hello'` then later `name << ' world'` will crash if the comment is enabled)
# So we might enable it at some point, be we will need very careful review that this doesn't break everything.
Style/FrozenStringLiteralComment:
Enabled: false
# Unicode is pretty standard by now, and we want to be able to use em-dash, ellipsis, and unicode characters
# to provide nice Monodraw.app graphs and similar, without being limited only by ascii.
Style/AsciiComments:
Enabled: false
# This causes issues with Pathname#.+, which is why we disable it to avoid introducing bugs because of it.
# e.g. if `r = Pathname.new('root')` then `r + 'lib'` results in a `<Pathname:root/lib>` as expected;
# but this rubocop rule will suggest to change this to `#{r}lib` which results in `"rootlib"` string,
# which would be incorrect and not what we want
Style/StringConcatenation:
Enabled: false
# This rule was enforced after upgrading Rubocop from `1.22.1` to `1.50.2`. We are disabling this rule for the
# time being so that we don't see any unexpected behavior when running Release Toolkit actions that could be
# changed by this rule. See https://github.com/wordpress-mobile/release-toolkit/pull/464#pullrequestreview-1396569629
# for more discussion
Style/FetchEnvVar:
Enabled: false
# Rule enforced after migrating to Ruby 3, to prevent the new syntax which allows for hash values and keyword arguments
# omission, such as `myMethod(x:, y:)` and `h = { a:, b: }`.
Style/HashSyntax:
EnforcedShorthandSyntax: never
########## Gemspec Rules
# This was turned on by default after updating Rubocop to `1.50.2`. We want to disable this for now because
# all the gem publishing is done within CI and doesn't allow for user input such as an MFA code. See
# https://github.com/wordpress-mobile/release-toolkit/pull/464#pullrequestreview-1396569313 for more discussion
Gemspec/RequireMFA:
Enabled: false
########## Metrics / Max Lengths Rules
Layout/LineLength:
Max: 300
Metrics/AbcSize:
Max: 140
Metrics/BlockLength:
Max: 80
Exclude:
- spec/**/*_spec.rb
- spec/**/shared_examples_*.rb
Metrics/ClassLength:
Max: 300
Metrics/MethodLength:
Max: 150
Metrics/ModuleLength:
Max: 300
Metrics/ParameterLists:
Max: 10
########## Metrics / Complexity
Metrics/CyclomaticComplexity:
Max: 20
Metrics/PerceivedComplexity:
Max: 20
########## RSpec Rules
# We are not strict to the point that we want to enforce super-short `it '…' do … end` blocks in our specs.
RSpec/ExampleLength:
Enabled: false
# Same for number of let/subject
RSpec/MultipleMemoizedHelpers:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false