webit-ruby-rubocop 3.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0cdb697dd9a3f98ecb2cfad7cd8c86615d072fd7d81bc6707555e307a8e89a97
4
+ data.tar.gz: a66c58409808ba9ca07914ef9f445de5ad3d45451cf6c10279978902191b3d52
5
+ SHA512:
6
+ metadata.gz: ee269ac6b934b22b01d4fb27a32267a6bf25233909f9a75c83bd17c6554f8d838437773c923a889b1cd6290a79dea2f412554889dc9cbcdd1a86d575b4b4a119
7
+ data.tar.gz: 032a52fb7ec9ecf0cb89d29a7f857d381a8550a966e460e7bf527dda34ea17a2ea485f25ac863b31d258d8a12145145c27659b9f9aef311236d7862c8f342fb9
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 webit! Gesellschaft für neue Medien mbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # webit-ruby-rubocop
2
+
3
+ This gem provides webit specific rubocop configurations. The current webit code conventions can be found here: see https://github.com/webit-de/webit-ruby-styleguide.
4
+
5
+ If you are looking for Rails specific configuration, check out [webit-rails-rubocop](https://gitterlabor.webit.de/webit/intern/webit-rails-rubocop).
6
+
7
+ ## Installation
8
+
9
+ Add the following line to your Gemfile:
10
+
11
+ ```ruby
12
+ # Optionally: Add a custom git source to install gems from gitterlabor more easily.
13
+ git_source(:gitterlabor) { |repo| "git@gitterlabor.webit.de:webit/#{repo}.git" }
14
+
15
+ gem 'webit-ruby-rubocop', gitterlabor: 'intern/webit-ruby-rubocop'
16
+ ```
17
+
18
+ In your own project, add a `.rubocop.yml` containing this configuration:
19
+
20
+ ```yml
21
+ inherit_gem:
22
+ webit-ruby-rubocop: config.yml
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ $ bundle exec rubocop
29
+ ```
30
+
31
+ ## Migrating to Version 3
32
+
33
+ With version 3 of the webit-ruby-rubocop gem we introduced some breaking changes. The following steps will guide you through the update process.
34
+
35
+ 1. Update the gem's name in your `Gemfile`:
36
+
37
+ ```diff
38
+ - gem 'webit-rubocop', gitterlabor: 'intern/webit-ruby-rubocop'
39
+ + gem 'webit-ruby-rubocop', gitterlabor: 'intern/webit-ruby-rubocop'
40
+ ```
41
+
42
+ 2. Update your `.rubocop.yml` file:
43
+
44
+ ```diff
45
+ - inherit_gem:
46
+ - webit-rubocop: config/webit.yml
47
+
48
+ + inherit_gem:
49
+ + webit-ruby-rubocop: config.yml
50
+ ```
51
+
52
+ 3. Since version 3, the configuration for Rails cops were moved to [webit-rails-rubocop](https://gitterlabor.webit.de/webit/intern/webit-rails-rubocop). If you need Rails cops as well, follow the installation guide there.
data/config.yml ADDED
@@ -0,0 +1,19 @@
1
+ inherit_from:
2
+ - ./cops/capybara.yml
3
+ - ./cops/gemspec.yml
4
+ - ./cops/layout.yml
5
+ - ./cops/lint.yml
6
+ - ./cops/metrics.yml
7
+ - ./cops/minitest.yml
8
+ - ./cops/naming.yml
9
+ - ./cops/security.yml
10
+ - ./cops/style.yml
11
+ - ./cops/webit.yml
12
+
13
+ require:
14
+ - ./lib/custom_cops
15
+
16
+ plugins:
17
+ - rubocop-capybara
18
+ - rubocop-minitest
19
+ - rubocop-rake
data/cops/capybara.yml ADDED
@@ -0,0 +1,32 @@
1
+ Capybara/ClickLinkOrButtonStyle:
2
+ Enabled: true
3
+
4
+ Capybara/FindAllFirst:
5
+ Enabled: true
6
+
7
+ Capybara/MatchStyle:
8
+ Enabled: true
9
+
10
+ Capybara/NegationMatcher:
11
+ Enabled: true
12
+
13
+ Capybara/NegationMatcherAfterVisit:
14
+ Enabled: true
15
+
16
+ Capybara/RedundantWithinFind:
17
+ Enabled: true
18
+
19
+ Capybara/RSpec/HaveSelector:
20
+ Enabled: true
21
+
22
+ Capybara/RSpec/PredicateMatcher:
23
+ Enabled: true
24
+
25
+ Capybara/SpecificActions:
26
+ Enabled: true
27
+
28
+ Capybara/SpecificFinders:
29
+ Enabled: true
30
+
31
+ Capybara/SpecificMatcher:
32
+ Enabled: true
data/cops/gemspec.yml ADDED
@@ -0,0 +1,14 @@
1
+ Gemspec/AddRuntimeDependency:
2
+ Enabled: true
3
+
4
+ Gemspec/AttributeAssignment:
5
+ Enabled: true
6
+
7
+ Gemspec/DeprecatedAttributeAssignment:
8
+ Enabled: true
9
+
10
+ Gemspec/DevelopmentDependencies:
11
+ Enabled: true
12
+
13
+ Gemspec/RequireMFA:
14
+ Enabled: false
data/cops/layout.yml ADDED
@@ -0,0 +1,86 @@
1
+ Layout/ArgumentAlignment:
2
+ Enabled: true
3
+ EnforcedStyle: with_first_argument
4
+
5
+ Layout/DotPosition:
6
+ Enabled: true
7
+ EnforcedStyle: trailing
8
+
9
+ Layout/EmptyLineAfterGuardClause:
10
+ Enabled: true
11
+
12
+ Layout/EmptyLinesAfterModuleInclusion:
13
+ Enabled: true
14
+
15
+ Layout/EmptyLines:
16
+ Enabled: false
17
+
18
+ Layout/EmptyLinesAroundAttributeAccessor:
19
+ Enabled: true
20
+
21
+ Layout/EmptyLinesAroundBlockBody:
22
+ Enabled: false
23
+
24
+ Layout/EmptyLinesAroundClassBody:
25
+ Enabled: false
26
+
27
+ Layout/EmptyLinesAroundModuleBody:
28
+ Enabled: false
29
+
30
+ Layout/FirstArgumentIndentation:
31
+ Enabled: true
32
+ EnforcedStyle: consistent
33
+
34
+ Layout/FirstMethodArgumentLineBreak:
35
+ Enabled: true
36
+
37
+ Layout/FirstParameterIndentation:
38
+ Enabled: true
39
+ EnforcedStyle: consistent
40
+
41
+ Layout/FirstMethodParameterLineBreak:
42
+ Enabled: true
43
+
44
+ Layout/LineContinuationLeadingSpace:
45
+ Enabled: true
46
+
47
+ Layout/LineContinuationSpacing:
48
+ Enabled: true
49
+
50
+ Layout/LineEndStringConcatenationIndentation:
51
+ Enabled: true
52
+ EnforcedStyle: indented
53
+
54
+ Layout/LineLength:
55
+ AllowHeredoc: false
56
+ AllowQualifiedName: false
57
+ AllowURI: false
58
+ Description: Limit lines to 150 characters.
59
+ Enabled: true
60
+ Max: 150
61
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
62
+
63
+ Layout/MultilineMethodArgumentLineBreaks:
64
+ Enabled: true
65
+
66
+ Layout/MultilineMethodCallIndentation:
67
+ Enabled: true
68
+ EnforcedStyle: indented_relative_to_receiver
69
+
70
+ Layout/MultilineOperationIndentation:
71
+ Description: Checks indentation of binary operations that span more than one line.
72
+ Enabled: true
73
+ EnforcedStyle: indented
74
+
75
+ Layout/ParameterAlignment:
76
+ Enabled: true
77
+ EnforcedStyle: with_first_parameter
78
+
79
+ Layout/SpaceAroundMethodCallOperator:
80
+ Enabled: false
81
+
82
+ Layout/SpaceBeforeBrackets:
83
+ Enabled: true
84
+
85
+ Layout/SpaceInLambdaLiteral:
86
+ Enabled: true
data/cops/lint.yml ADDED
@@ -0,0 +1,161 @@
1
+ Lint/AmbiguousAssignment:
2
+ Enabled: true
3
+
4
+ Lint/AmbiguousOperatorPrecedence:
5
+ Enabled: true
6
+
7
+ Lint/AmbiguousRange:
8
+ Enabled: true
9
+
10
+ Lint/ArrayLiteralInRegexp:
11
+ Enabled: true
12
+
13
+ Lint/ConstantOverwrittenInRescue:
14
+ Enabled: true
15
+
16
+ Lint/ConstantReassignment:
17
+ Enabled: true
18
+
19
+ Lint/CopDirectiveSyntax:
20
+ Enabled: true
21
+
22
+ Lint/DeprecatedConstants:
23
+ Enabled: true
24
+
25
+ Lint/DeprecatedOpenSSLConstant:
26
+ Enabled: true
27
+
28
+ Lint/DuplicateBranch:
29
+ Enabled: true
30
+
31
+ Lint/DuplicateElsifCondition:
32
+ Enabled: true
33
+
34
+ Lint/DuplicateMagicComment:
35
+ Enabled: true
36
+
37
+ Lint/DuplicateMatchPattern:
38
+ Enabled: true
39
+
40
+ Lint/DuplicateRegexpCharacterClassElement:
41
+ Enabled: true
42
+
43
+ Lint/DuplicateSetElement:
44
+ Enabled: true
45
+
46
+ Lint/EmptyBlock:
47
+ Enabled: true
48
+
49
+ Lint/EmptyClass:
50
+ Enabled: true
51
+
52
+ Lint/EmptyInPattern:
53
+ Enabled: true
54
+
55
+ Lint/HashNewWithKeywordArgumentsAsDefault:
56
+ Enabled: true
57
+
58
+ Lint/IncompatibleIoSelectWithFiberScheduler:
59
+ Enabled: true
60
+
61
+ Lint/ItWithoutArgumentsInBlock:
62
+ Enabled: true
63
+
64
+ Lint/LambdaWithoutLiteralBlock:
65
+ Enabled: true
66
+
67
+ Lint/LiteralAssignmentInCondition:
68
+ Enabled: true
69
+
70
+ Lint/MixedCaseRange:
71
+ Enabled: true
72
+
73
+ Lint/MixedRegexpCaptureTypes:
74
+ Enabled: true
75
+
76
+ Lint/NonAtomicFileOperation:
77
+ Enabled: true
78
+
79
+ Lint/NoReturnInBeginEndBlocks:
80
+ Enabled: true
81
+
82
+ Lint/NumberedParameterAssignment:
83
+ Enabled: true
84
+
85
+ Lint/NumericOperationWithConstantResult:
86
+ Enabled: true
87
+
88
+ Lint/OrAssignmentToConstant:
89
+ Enabled: true
90
+
91
+ Lint/RaiseException:
92
+ Enabled: true
93
+
94
+ Lint/RedundantDirGlobSort:
95
+ Enabled: true
96
+
97
+ Lint/RedundantRegexpQuantifiers:
98
+ Enabled: true
99
+
100
+ Lint/RedundantTypeConversion:
101
+ Enabled: true
102
+
103
+ Lint/RefinementImportMethods:
104
+ Enabled: true
105
+
106
+ Lint/RequireRangeParentheses:
107
+ Enabled: true
108
+
109
+ Lint/RequireRelativeSelfPath:
110
+ Enabled: true
111
+
112
+ Lint/SharedMutableDefault:
113
+ Enabled: true
114
+
115
+ Lint/StructNewOverride:
116
+ Enabled: true
117
+
118
+ Lint/SuppressedExceptionInNumberConversion:
119
+ Enabled: true
120
+
121
+ Lint/SymbolConversion:
122
+ Enabled: true
123
+
124
+ Lint/ToEnumArguments:
125
+ Enabled: true
126
+
127
+ Lint/TripleQuotes:
128
+ Enabled: true
129
+
130
+ Lint/UnescapedBracketInRegexp:
131
+ Enabled: true
132
+
133
+ Lint/UnexpectedBlockArity:
134
+ Enabled: true
135
+
136
+ Lint/UnmodifiedReduceAccumulator:
137
+ Enabled: true
138
+
139
+ Lint/UnreachableCode:
140
+ Enabled: true
141
+
142
+ Lint/UselessConstantScoping:
143
+ Enabled: true
144
+
145
+ Lint/UselessDefaultValueArgument:
146
+ Enabled: true
147
+
148
+ Lint/UselessDefined:
149
+ Enabled: true
150
+
151
+ Lint/UselessNumericOperation:
152
+ Enabled: true
153
+
154
+ Lint/UselessOr:
155
+ Enabled: true
156
+
157
+ Lint/UselessRescue:
158
+ Enabled: true
159
+
160
+ Lint/UselessRuby2Keywords:
161
+ Enabled: true
data/cops/metrics.yml ADDED
@@ -0,0 +1,46 @@
1
+ Metrics/AbcSize:
2
+ Description: A calculated magnitude based on number of assignments, branches, and conditions.
3
+ Enabled: false
4
+ Reference: http://c2.com/cgi/wiki?AbcMetric
5
+
6
+ Metrics/BlockLength:
7
+ Enabled: true
8
+ Exclude:
9
+ - 'Rakefile'
10
+ - '**/*.rake'
11
+ - 'test/**/*.rb'
12
+
13
+ Metrics/BlockNesting:
14
+ Description: Avoid excessive block nesting
15
+ Enabled: false
16
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count
17
+
18
+ Metrics/ClassLength:
19
+ Description: Avoid classes longer than 100 lines of code.
20
+ Enabled: false
21
+
22
+ Metrics/CollectionLiteralLength:
23
+ Enabled: false
24
+
25
+ Metrics/CyclomaticComplexity:
26
+ Description: A complexity metric that is strongly correlated to the number of test cases needed to validate a method.
27
+ Enabled: false
28
+
29
+ Metrics/MethodLength:
30
+ Description: Avoid methods longer than 10 lines of code.
31
+ Enabled: false
32
+ Max: 10
33
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
34
+
35
+ Metrics/ModuleLength:
36
+ Description: Avoid modules longer than 100 lines of code.
37
+ Enabled: false
38
+
39
+ Metrics/ParameterLists:
40
+ Description: Avoid parameter lists longer than three or four parameters.
41
+ Enabled: false
42
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
43
+
44
+ Metrics/PerceivedComplexity:
45
+ Description: A complexity metric geared towards measuring complexity for a human reader.
46
+ Enabled: false
data/cops/minitest.yml ADDED
@@ -0,0 +1,104 @@
1
+ Minitest/AssertInDelta:
2
+ Enabled: true
3
+
4
+ Minitest/AssertKindOf:
5
+ Enabled: true
6
+
7
+ Minitest/AssertOperator:
8
+ Enabled: true
9
+
10
+ Minitest/AssertOutput:
11
+ Enabled: true
12
+
13
+ Minitest/AssertPathExists:
14
+ Enabled: true
15
+
16
+ Minitest/AssertPredicate:
17
+ Enabled: true
18
+
19
+ Minitest/AssertRaisesCompoundBody:
20
+ Enabled: true
21
+
22
+ Minitest/AssertRaisesWithRegexpArgument:
23
+ Enabled: true
24
+
25
+ Minitest/AssertSame:
26
+ Enabled: true
27
+
28
+ Minitest/AssertSilent:
29
+ Enabled: true
30
+
31
+ Minitest/AssertWithExpectedArgument:
32
+ Enabled: false
33
+
34
+ Minitest/AssertionInLifecycleHook:
35
+ Enabled: false
36
+
37
+ Minitest/DuplicateTestRun:
38
+ Enabled: true
39
+
40
+ Minitest/EmptyLineBeforeAssertionMethods:
41
+ Enabled: false
42
+
43
+ Minitest/Focus:
44
+ Enabled: true
45
+
46
+ Minitest/LifecycleHooksOrder:
47
+ Enabled: true
48
+
49
+ Minitest/LiteralAsActualArgument:
50
+ Enabled: true
51
+
52
+ Minitest/MultipleAssertions:
53
+ Enabled: false
54
+
55
+ Minitest/NonExecutableTestMethod:
56
+ Enabled: true
57
+
58
+ Minitest/NonPublicTestMethod:
59
+ Enabled: true
60
+
61
+ Minitest/RedundantMessageArgument:
62
+ Enabled: true
63
+
64
+ Minitest/RefuteInDelta:
65
+ Enabled: true
66
+
67
+ Minitest/RefuteKindOf:
68
+ Enabled: true
69
+
70
+ Minitest/RefuteOperator:
71
+ Enabled: true
72
+
73
+ Minitest/RefutePathExists:
74
+ Enabled: true
75
+
76
+ Minitest/RefutePredicate:
77
+ Enabled: true
78
+
79
+ Minitest/RefuteSame:
80
+ Enabled: true
81
+
82
+ Minitest/ReturnInTestMethod:
83
+ Enabled: true
84
+
85
+ Minitest/SkipEnsure:
86
+ Enabled: true
87
+
88
+ Minitest/SkipWithoutReason:
89
+ Enabled: true
90
+
91
+ Minitest/TestFileName:
92
+ Enabled: true
93
+
94
+ Minitest/TestMethodName:
95
+ Enabled: true
96
+
97
+ Minitest/UnreachableAssertion:
98
+ Enabled: true
99
+
100
+ Minitest/UnspecifiedException:
101
+ Enabled: true
102
+
103
+ Minitest/UselessAssertion:
104
+ Enabled: true
data/cops/naming.yml ADDED
@@ -0,0 +1,32 @@
1
+ Naming/BlockForwarding:
2
+ Enabled: true
3
+ EnforcedStyle: explicit
4
+
5
+ Naming/InclusiveLanguage:
6
+ Enabled: true
7
+ CheckStrings: true
8
+
9
+ Naming/MethodParameterName:
10
+ AllowedNames:
11
+ # default config from https://docs.rubocop.org/rubocop/1.11/cops_naming.html#configurable-attributes-9
12
+ - at
13
+ - by
14
+ - db
15
+ - id
16
+ - in
17
+ - io
18
+ - ip
19
+ - of
20
+ - 'on'
21
+ - os
22
+ - pp
23
+ - to
24
+ # additional custom allowed variable names
25
+ - e
26
+
27
+ Naming/PredicateMethod:
28
+ Enabled: false
29
+
30
+ Naming/RescuedExceptionsVariableName:
31
+ Enabled: true
32
+ PreferredName: exception
data/cops/security.yml ADDED
@@ -0,0 +1,5 @@
1
+ Security/CompoundHash:
2
+ Enabled: true
3
+
4
+ Security/IoMethods:
5
+ Enabled: true
data/cops/style.yml ADDED
@@ -0,0 +1,381 @@
1
+ Style/AccessorGrouping:
2
+ Enabled: true
3
+
4
+ Style/AmbiguousEndlessMethodDefinition:
5
+ Enabled: true
6
+
7
+ Style/AndOr:
8
+ EnforcedStyle: always
9
+
10
+ Style/ArgumentsForwarding:
11
+ Enabled: true
12
+
13
+ Style/ArrayCoercion:
14
+ Enabled: true
15
+
16
+ Style/ArrayIntersect:
17
+ Enabled: true
18
+
19
+ Style/ArrayIntersectWithSingleElement:
20
+ Enabled: true
21
+
22
+ Style/AsciiComments:
23
+ Description: Use only ascii symbols in comments.
24
+ Enabled: false
25
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#english-comments
26
+
27
+ Style/BisectedAttrAccessor:
28
+ Enabled: true
29
+
30
+ Style/BitwisePredicate:
31
+ Enabled: true
32
+
33
+ Style/CaseEquality:
34
+ Enabled: true
35
+
36
+ Style/CaseLikeIf:
37
+ Enabled: true
38
+
39
+ Style/ClassAndModuleChildren:
40
+ Enabled: false
41
+
42
+ Style/CollectionCompact:
43
+ Enabled: true
44
+
45
+ Style/CollectionQuerying:
46
+ Enabled: true
47
+
48
+ Style/CombinableDefined:
49
+ Enabled: true
50
+
51
+ Style/CommandLiteral:
52
+ EnforcedStyle: mixed
53
+
54
+ Style/ComparableBetween:
55
+ Enabled: true
56
+
57
+ Style/ComparableClamp:
58
+ Enabled: true
59
+
60
+ Style/ConcatArrayLiterals:
61
+ Enabled: true
62
+
63
+ Style/DataInheritance:
64
+ Enabled: true
65
+
66
+ Style/DigChain:
67
+ Enabled: true
68
+
69
+ Style/DirEmpty:
70
+ Enabled: true
71
+
72
+ Style/DocumentDynamicEvalDefinition:
73
+ Enabled: false
74
+
75
+ Style/Documentation:
76
+ Enabled: false
77
+
78
+ Style/EmptyClassDefinition:
79
+ Enabled: true
80
+
81
+ Style/EmptyHeredoc:
82
+ Enabled: true
83
+
84
+ Style/EmptyStringInsideInterpolation:
85
+ Enabled: true
86
+
87
+ Style/EndlessMethod:
88
+ Enabled: true
89
+ EnforcedStyle: disallow
90
+
91
+ Style/EnvHome:
92
+ Enabled: true
93
+
94
+ Style/ExactRegexpMatch:
95
+ Enabled: true
96
+
97
+ Style/ExponentialNotation:
98
+ Enabled: true
99
+
100
+ Style/FetchEnvVar:
101
+ Enabled: true
102
+
103
+ Style/FileEmpty:
104
+ Enabled: true
105
+
106
+ Style/FileNull:
107
+ Enabled: true
108
+
109
+ Style/FileRead:
110
+ Enabled: true
111
+
112
+ Style/FileTouch:
113
+ Enabled: true
114
+
115
+ Style/FileWrite:
116
+ Enabled: true
117
+
118
+ Style/FrozenStringLiteralComment:
119
+ Enabled: true
120
+
121
+ Style/GuardClause:
122
+ Description: Check for conditionals that can be replaced with guard clauses
123
+ Enabled: false
124
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
125
+
126
+ Style/HashAsLastArrayItem:
127
+ Enabled: true
128
+
129
+ Style/HashConversion:
130
+ Enabled: true
131
+
132
+ Style/HashEachMethods:
133
+ Enabled: false
134
+
135
+ Style/HashExcept:
136
+ Enabled: true
137
+
138
+ Style/HashFetchChain:
139
+ Enabled: true
140
+
141
+ Style/HashLikeCase:
142
+ Enabled: true
143
+ MinBranchesCount: 1
144
+
145
+ Style/HashSlice:
146
+ Enabled: true
147
+
148
+ Style/HashSyntax:
149
+ Enabled: true
150
+ EnforcedShorthandSyntax: either
151
+
152
+ Style/HashTransformKeys:
153
+ Enabled: true
154
+
155
+ Style/HashTransformValues:
156
+ Enabled: true
157
+
158
+ Style/IfUnlessModifier:
159
+ Enabled: false
160
+
161
+ Style/IfWithBooleanLiteralBranches:
162
+ Enabled: true
163
+
164
+ Style/InPatternThen:
165
+ Enabled: true
166
+
167
+ Style/ItAssignment:
168
+ Enabled: true
169
+
170
+ Style/ItBlockParameter:
171
+ Enabled: true
172
+
173
+ Style/KeywordArgumentsMerging:
174
+ Enabled: true
175
+
176
+ Style/Lambda:
177
+ Enabled: true
178
+ EnforcedStyle: literal
179
+
180
+ Style/LambdaCall:
181
+ Description: Use lambda.call(...) instead of lambda.(...).
182
+ Enabled: false
183
+ StyleGuide: '#proc-call'
184
+
185
+ Style/MagicCommentFormat:
186
+ Enabled: true
187
+
188
+ Style/MapCompactWithConditionalBlock:
189
+ Enabled: true
190
+
191
+ Style/MapIntoArray:
192
+ Enabled: true
193
+
194
+ Style/MapToHash:
195
+ Enabled: true
196
+
197
+ Style/MapToSet:
198
+ Enabled: true
199
+
200
+ Style/MinMaxComparison:
201
+ Enabled: true
202
+
203
+ Style/ModuleMemberExistenceCheck:
204
+ Enabled: true
205
+
206
+ Style/MultilineInPatternThen:
207
+ Enabled: false
208
+
209
+ Style/MultilineMemoization:
210
+ Enabled: false
211
+
212
+ Style/NegatedIfElseCondition:
213
+ Enabled: true
214
+
215
+ Style/NegativeArrayIndex:
216
+ Enabled: true
217
+
218
+ Style/NestedFileDirname:
219
+ Enabled: true
220
+
221
+ Style/NilLambda:
222
+ Enabled: true
223
+
224
+ Style/NumberedParameters:
225
+ Enabled: true
226
+ EnforcedStyle: disallow
227
+
228
+ Style/NumberedParametersLimit:
229
+ Enabled: false
230
+
231
+ Style/ObjectThen:
232
+ Enabled: true
233
+
234
+ Style/OneLineConditional:
235
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
236
+ Enabled: false
237
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
238
+
239
+ Style/OpenStructUse:
240
+ Enabled: false
241
+
242
+ Style/OperatorMethodCall:
243
+ Enabled: true
244
+
245
+ Style/ParallelAssignment:
246
+ Enabled: false
247
+
248
+ Style/ParenthesesAroundCondition:
249
+ Enabled: true
250
+ AllowInMultilineConditions: true
251
+ AllowSafeAssignment: true
252
+
253
+ Style/PercentLiteralDelimiters:
254
+ Enabled: false
255
+
256
+ Style/QuotedSymbols:
257
+ Enabled: true
258
+
259
+ Style/RedundantArgument:
260
+ Enabled: true
261
+
262
+ Style/RedundantArrayConstructor:
263
+ Enabled: true
264
+
265
+ Style/RedundantArrayFlatten:
266
+ Enabled: true
267
+
268
+ Style/RedundantAssignment:
269
+ Enabled: true
270
+
271
+ Style/RedundantConstantBase:
272
+ Enabled: true
273
+
274
+ Style/RedundantCurrentDirectoryInPath:
275
+ Enabled: true
276
+
277
+ Style/RedundantDoubleSplatHashBraces:
278
+ Enabled: true
279
+
280
+ Style/RedundantEach:
281
+ Enabled: true
282
+
283
+ Style/RedundantFetchBlock:
284
+ Enabled: true
285
+
286
+ Style/RedundantFileExtensionInRequire:
287
+ Enabled: true
288
+
289
+ Style/RedundantFilterChain:
290
+ Enabled: true
291
+
292
+ Style/RedundantFormat:
293
+ Enabled: true
294
+
295
+ Style/RedundantHeredocDelimiterQuotes:
296
+ Enabled: true
297
+
298
+ Style/RedundantInitialize:
299
+ Enabled: true
300
+
301
+ Style/RedundantInterpolationUnfreeze:
302
+ Enabled: true
303
+
304
+ Style/RedundantLineContinuation:
305
+ Enabled: true
306
+
307
+ Style/RedundantRegexpArgument:
308
+ Enabled: true
309
+
310
+ Style/RedundantRegexpCharacterClass:
311
+ Enabled: true
312
+
313
+ Style/RedundantRegexpConstructor:
314
+ Enabled: true
315
+
316
+ Style/RedundantRegexpEscape:
317
+ Enabled: true
318
+
319
+ Style/RedundantSelfAssignmentBranch:
320
+ Enabled: true
321
+
322
+ Style/RedundantStringEscape:
323
+ Enabled: true
324
+
325
+ Style/RegexpLiteral:
326
+ AllowInnerSlashes: false
327
+ EnforcedStyle: mixed
328
+
329
+ Style/ReturnNilInPredicateMethodDefinition:
330
+ Enabled: true
331
+
332
+ Style/ReverseFind:
333
+ Enabled: true
334
+
335
+ Style/SafeNavigationChainLength:
336
+ Enabled: true
337
+
338
+ Style/SelectByRegexp:
339
+ Enabled: true
340
+
341
+ Style/SendWithLiteralMethodName:
342
+ Enabled: true
343
+
344
+ Style/SignalException:
345
+ Enabled: true
346
+ EnforcedStyle: only_raise
347
+
348
+ Style/SingleLineDoEndBlock:
349
+ Enabled: true
350
+
351
+ Style/SlicingWithRange:
352
+ Enabled: false
353
+
354
+ Style/StringChars:
355
+ Enabled: true
356
+
357
+ Style/StringLiterals:
358
+ Enabled: true
359
+ EnforcedStyle: double_quotes
360
+
361
+ Style/StringLiteralsInInterpolation:
362
+ Enabled: true
363
+ EnforcedStyle: double_quotes
364
+
365
+ Style/SuperArguments:
366
+ Enabled: true
367
+
368
+ Style/SuperWithArgsParentheses:
369
+ Enabled: true
370
+
371
+ Style/SwapValues:
372
+ Enabled: true
373
+
374
+ Style/WhileUntilModifier:
375
+ Enabled: false
376
+
377
+ Style/YAMLFileRead:
378
+ Enabled: true
379
+
380
+ Style/YodaExpression:
381
+ Enabled: false
data/cops/webit.yml ADDED
@@ -0,0 +1,2 @@
1
+ Webit/MultilineMethodCalls:
2
+ Enabled: true
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rubocop/cop/webit/multiline_method_calls"
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Webit
6
+ # Checks for the usage of parentheses on multi-line method calls.
7
+ #
8
+ # @example
9
+ #
10
+ # # bad (multiple lines without parentheses)
11
+ # puts foo,
12
+ # bar,
13
+ # baz
14
+ #
15
+ # # good (multiple lines with parentheses)
16
+ # puts(
17
+ # foo,
18
+ # bar,
19
+ # baz
20
+ # )
21
+ #
22
+ # # good (one line)
23
+ # puts foo, bar, baz
24
+ #
25
+ # # good (assignment is special method call)
26
+ # obj.attr =
27
+ # if foo
28
+ # bar
29
+ # else
30
+ # baz
31
+ # end
32
+ #
33
+ class MultilineMethodCalls < RuboCop::Cop::Base
34
+ extend AutoCorrector
35
+
36
+ MSG_PARENTHESES = "Multiline method calls must have parentheses."
37
+
38
+ def on_send(node)
39
+ return if node.children.empty? || !multiline_method_call?(node)
40
+ return if node.assignment_method?
41
+ return if node.operator_method?
42
+
43
+ unless node.parenthesized_call?
44
+ add_offense(node, message: MSG_PARENTHESES) do |corrector|
45
+ corrector.replace(node, "#{node.source.sub("#{node.method_name} ", "#{node.method_name}(")})")
46
+ end
47
+ end
48
+ end
49
+
50
+ alias on_csend on_send
51
+
52
+ private
53
+
54
+ def multiline_method_call?(node)
55
+ node.type?(:call) && node.arguments.size.positive? && node.location.selector && node.location.selector.line != node.last_argument.loc.line
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webit-ruby-rubocop
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.16
5
+ platform: ruby
6
+ authors:
7
+ - Roland Schwarzer
8
+ - Martin Schrader
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.84.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.84.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.22.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.22.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.35.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.35.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.5.1
69
+ description: This gem provides webit! specific rubocop configurations.
70
+ email:
71
+ - schwarzer@webit.de
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - LICENSE
77
+ - README.md
78
+ - config.yml
79
+ - cops/capybara.yml
80
+ - cops/gemspec.yml
81
+ - cops/layout.yml
82
+ - cops/lint.yml
83
+ - cops/metrics.yml
84
+ - cops/minitest.yml
85
+ - cops/naming.yml
86
+ - cops/security.yml
87
+ - cops/style.yml
88
+ - cops/webit.yml
89
+ - lib/custom_cops.rb
90
+ - lib/rubocop/cop/webit/multiline_method_calls.rb
91
+ homepage: https://github.com/webit-de/webit-ruby-rubocop
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 2.6.0
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubygems_version: 4.0.3
110
+ specification_version: 4
111
+ summary: webit! specific rubocop configurations
112
+ test_files: []