rubocop-hk 1.0.9
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 +7 -0
- data/README.md +3732 -0
- data/STYLEGUIDE.md +1660 -0
- data/config/default.yml +59 -0
- data/config/rubocop-layout.yml +215 -0
- data/config/rubocop-lint.yml +43 -0
- data/config/rubocop-metrics.yml +14 -0
- data/config/rubocop-performance.yml +33 -0
- data/config/rubocop-rails.yml +374 -0
- data/config/rubocop-rspec.yml +29 -0
- data/config/rubocop-style.yml +197 -0
- data/lib/rubocop/hk/command.rb +27 -0
- data/lib/rubocop/hk/version.rb +7 -0
- data/lib/rubocop/hk.rb +9 -0
- metadata +126 -0
data/config/default.yml
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
AllCops:
|
2
|
+
# Target versions for Rails 6-8.x applications (2025)
|
3
|
+
TargetRubyVersion: 3.1
|
4
|
+
TargetRailsVersion: 8.0
|
5
|
+
|
6
|
+
# Enhanced exclusions for typical Rails project structure
|
7
|
+
Exclude:
|
8
|
+
- "bin/**/*"
|
9
|
+
- "db/**/*"
|
10
|
+
- "db/schema.rb"
|
11
|
+
- "db/migrate/**/*"
|
12
|
+
- "node_modules/**/*"
|
13
|
+
- "**/vendor/**/*"
|
14
|
+
- "**/vendor/**/.*"
|
15
|
+
- ".git/**/*"
|
16
|
+
- "tmp/**/*"
|
17
|
+
- "log/**/*"
|
18
|
+
- "public/**/*"
|
19
|
+
- "storage/**/*"
|
20
|
+
- "config/boot.rb"
|
21
|
+
- "config/environment.rb"
|
22
|
+
- "config/puma.rb"
|
23
|
+
- "config/spring.rb"
|
24
|
+
|
25
|
+
# Enhanced output formatting
|
26
|
+
DefaultFormatter: progress
|
27
|
+
DisplayCopNames: true
|
28
|
+
DisplayStyleGuide: true
|
29
|
+
ExtraDetails: true
|
30
|
+
|
31
|
+
# Enable new cops for modern Rails/Ruby features
|
32
|
+
NewCops: enable
|
33
|
+
|
34
|
+
# Extension suggestions for Rails 6-8.x
|
35
|
+
SuggestExtensions:
|
36
|
+
rubocop-performance: true
|
37
|
+
rubocop-thread_safety: false
|
38
|
+
rubocop-minitest: false
|
39
|
+
rubocop-capybara: true
|
40
|
+
|
41
|
+
Rails:
|
42
|
+
Enabled: true
|
43
|
+
|
44
|
+
# Modern plugin architecture (RuboCop 1.72+)
|
45
|
+
plugins:
|
46
|
+
- rubocop-rails
|
47
|
+
- rubocop-rspec
|
48
|
+
- rubocop-performance
|
49
|
+
|
50
|
+
# Configuration inheritance - modular approach
|
51
|
+
inherit_from:
|
52
|
+
- rubocop-layout.yml
|
53
|
+
- rubocop-lint.yml
|
54
|
+
- rubocop-metrics.yml
|
55
|
+
- rubocop-rspec.yml
|
56
|
+
- rubocop-rails.yml
|
57
|
+
- rubocop-style.yml
|
58
|
+
- rubocop-performance.yml
|
59
|
+
|
@@ -0,0 +1,215 @@
|
|
1
|
+
Layout/CaseIndentation:
|
2
|
+
Description: Indentation of when in a case/when/[else/]end.
|
3
|
+
Enabled: true
|
4
|
+
EnforcedStyle: case
|
5
|
+
IndentOneStep: false
|
6
|
+
SupportedStyles:
|
7
|
+
- case
|
8
|
+
- end
|
9
|
+
|
10
|
+
Layout/ClosingHeredocIndentation:
|
11
|
+
Description: Checks the indentation of here document closings.
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
Layout/CommentIndentation:
|
15
|
+
Description: Indentation of comments.
|
16
|
+
Enabled: true
|
17
|
+
|
18
|
+
Layout/DotPosition:
|
19
|
+
Description: Checks the . position in multi-line method calls..
|
20
|
+
Enabled: true
|
21
|
+
EnforcedStyle: trailing
|
22
|
+
SupportedStyles:
|
23
|
+
- leading
|
24
|
+
- trailing
|
25
|
+
|
26
|
+
Layout/ElseAlignment:
|
27
|
+
Description: Align elses and elsifs correctly.
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
Layout/EmptyLineAfterMagicComment:
|
31
|
+
Description: Checks for a newline after the final magic comment.
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
Layout/EmptyLinesAroundAccessModifier:
|
35
|
+
Description: Access modifiers should be surrounded by blank lines.
|
36
|
+
Enabled: true
|
37
|
+
EnforcedStyle: around
|
38
|
+
SupportedStyles:
|
39
|
+
- around
|
40
|
+
- only_before
|
41
|
+
|
42
|
+
Layout/EmptyLinesAroundBlockBody:
|
43
|
+
Description: Keeps track of empty lines around block bodies.
|
44
|
+
Enabled: true
|
45
|
+
EnforcedStyle: no_empty_lines
|
46
|
+
SupportedStyles:
|
47
|
+
- empty_lines
|
48
|
+
- no_empty_lines
|
49
|
+
|
50
|
+
Layout/EmptyLinesAroundClassBody:
|
51
|
+
Description: Keeps track of empty lines around class bodies.
|
52
|
+
Enabled: true
|
53
|
+
EnforcedStyle: no_empty_lines
|
54
|
+
SupportedStyles:
|
55
|
+
- empty_lines
|
56
|
+
- empty_lines_except_namespace
|
57
|
+
- empty_lines_special
|
58
|
+
- no_empty_lines
|
59
|
+
- beginning_only
|
60
|
+
- ending_only
|
61
|
+
|
62
|
+
Layout/EmptyLinesAroundMethodBody:
|
63
|
+
Description: Keeps track of empty lines around method bodies.
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Layout/EmptyLinesAroundModuleBody:
|
67
|
+
Description: Keeps track of empty lines around module bodies.
|
68
|
+
Enabled: true
|
69
|
+
EnforcedStyle: no_empty_lines
|
70
|
+
SupportedStyles:
|
71
|
+
- empty_lines
|
72
|
+
- empty_lines_except_namespace
|
73
|
+
- empty_lines_special
|
74
|
+
- no_empty_lines
|
75
|
+
|
76
|
+
Layout/EndAlignment:
|
77
|
+
Description: Align ends correctly.
|
78
|
+
Enabled: true
|
79
|
+
EnforcedStyleAlignWith: variable
|
80
|
+
SupportedStylesAlignWith:
|
81
|
+
- keyword
|
82
|
+
- variable
|
83
|
+
- start_of_line
|
84
|
+
|
85
|
+
Layout/FirstArgumentIndentation:
|
86
|
+
Description: Checks the indentation of the first parameter in a method call.
|
87
|
+
Enabled: true
|
88
|
+
EnforcedStyle: consistent
|
89
|
+
SupportedStyles:
|
90
|
+
- consistent
|
91
|
+
- consistent_relative_to_receiver
|
92
|
+
- special_for_inner_method_call
|
93
|
+
- special_for_inner_method_call_in_parentheses
|
94
|
+
|
95
|
+
Layout/IndentationConsistency:
|
96
|
+
Description: Keep indentation consistent.
|
97
|
+
Enabled: true
|
98
|
+
EnforcedStyle: normal
|
99
|
+
SupportedStyles:
|
100
|
+
- normal
|
101
|
+
- indented_internal_methods
|
102
|
+
|
103
|
+
Layout/IndentationWidth:
|
104
|
+
Description: Checks indentation that doesn’t use the specified number of spaces.
|
105
|
+
Enabled: true
|
106
|
+
Width: 2
|
107
|
+
|
108
|
+
Layout/LeadingCommentSpace:
|
109
|
+
Description: Checks whether comments have a leading space after the symbol denoting the start.
|
110
|
+
Enabled: true
|
111
|
+
|
112
|
+
Layout/LineLength:
|
113
|
+
Description: Length of lines in the source code
|
114
|
+
Max: 100
|
115
|
+
AutoCorrect: true
|
116
|
+
AllowHeredoc: true
|
117
|
+
AllowURI: true
|
118
|
+
URISchemes:
|
119
|
+
- http
|
120
|
+
- https
|
121
|
+
IgnoreCopDirectives: true
|
122
|
+
|
123
|
+
Layout/MultilineMethodCallIndentation:
|
124
|
+
Description: Checks indentation of method calls with the dot operator that span more
|
125
|
+
than one line.
|
126
|
+
Enabled: true
|
127
|
+
EnforcedStyle: aligned
|
128
|
+
SupportedStyles:
|
129
|
+
- aligned
|
130
|
+
- indented
|
131
|
+
|
132
|
+
Layout/SpaceAfterColon:
|
133
|
+
Description: Whether or not to require a space after colon.
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
Layout/SpaceAfterComma:
|
137
|
+
Description: Whether or not to require a space after commas.
|
138
|
+
Enabled: true
|
139
|
+
|
140
|
+
Layout/SpaceAfterSemicolon:
|
141
|
+
Description: Whether or not to require a space after semicolons.
|
142
|
+
Enabled: true
|
143
|
+
|
144
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
145
|
+
Description: Checks that the equals signs in parameter default assignments have or
|
146
|
+
don't have surrounding space depending on configuration.
|
147
|
+
Enabled: true
|
148
|
+
EnforcedStyle: space
|
149
|
+
SupportedStyles:
|
150
|
+
- space
|
151
|
+
- no_space
|
152
|
+
|
153
|
+
Layout/SpaceAroundKeyword:
|
154
|
+
Description: Whether or not to require a space around keywords.
|
155
|
+
Enabled: true
|
156
|
+
|
157
|
+
Layout/SpaceBeforeComma:
|
158
|
+
Description: Whether or not to require a space before commas.
|
159
|
+
Enabled: true
|
160
|
+
|
161
|
+
Layout/SpaceBeforeComment:
|
162
|
+
Description: Checks for missing space between code and a comment on the same line.
|
163
|
+
Enabled: true
|
164
|
+
|
165
|
+
Layout/SpaceBeforeFirstArg:
|
166
|
+
Description: Checks that exactly one space is used between a method name and the first argument
|
167
|
+
for method calls without parentheses.
|
168
|
+
Enabled: true
|
169
|
+
|
170
|
+
Layout/SpaceBeforeBlockBraces:
|
171
|
+
Description: Checks that block braces have or don’t have a space before the opening brace.
|
172
|
+
Enabled: true
|
173
|
+
EnforcedStyle: space
|
174
|
+
EnforcedStyleForEmptyBraces: space
|
175
|
+
SupportedStyles:
|
176
|
+
- space
|
177
|
+
- no_space
|
178
|
+
|
179
|
+
Layout/SpaceInsideBlockBraces:
|
180
|
+
Description: Checks that block braces have or don't have surrounding space. For blocks
|
181
|
+
taking parameters, checks that the left brace has or doesn't have trailing space.
|
182
|
+
Enabled: true
|
183
|
+
EnforcedStyle: space
|
184
|
+
EnforcedStyleForEmptyBraces: no_space
|
185
|
+
SpaceBeforeBlockParameters: true
|
186
|
+
SupportedStyles:
|
187
|
+
- space
|
188
|
+
- no_space
|
189
|
+
|
190
|
+
Layout/SpaceInsideHashLiteralBraces:
|
191
|
+
Description: Checks that braces used for hash literals have or don’t have surrounding space.
|
192
|
+
Enabled: true
|
193
|
+
EnforcedStyle: space
|
194
|
+
EnforcedStyleForEmptyBraces: no_space
|
195
|
+
SupportedStyles:
|
196
|
+
- space
|
197
|
+
- no_space
|
198
|
+
- compact
|
199
|
+
|
200
|
+
Layout/SpaceInsideParens:
|
201
|
+
Description: Checks for spaces inside ordinary round parentheses.
|
202
|
+
Enabled: true
|
203
|
+
|
204
|
+
Layout/TrailingEmptyLines:
|
205
|
+
Description: Checks for trailing blank lines and a final newline in the source code.
|
206
|
+
Enabled: true
|
207
|
+
EnforcedStyle: final_newline
|
208
|
+
SupportedStyles:
|
209
|
+
- final_newline
|
210
|
+
- final_blank_line
|
211
|
+
|
212
|
+
Layout/TrailingWhitespace:
|
213
|
+
Description: Checks for trailing whitespace in the source code.
|
214
|
+
Enabled: true
|
215
|
+
AllowInHeredoc: false
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Lint/AmbiguousOperator:
|
2
|
+
Description: Checks for ambiguous operators in the first argument of a method invocation
|
3
|
+
without parentheses.
|
4
|
+
Enabled: true
|
5
|
+
|
6
|
+
Lint/AmbiguousRegexpLiteral:
|
7
|
+
Description: Checks for ambiguous regexp literals in the first argument of a method
|
8
|
+
invocation without parenthesis.
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Lint/DeprecatedClassMethods:
|
12
|
+
Description: Check for deprecated class method calls.
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Lint/ErbNewArguments:
|
16
|
+
Description: Emulates warnings in Ruby 2.6
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Lint/RedundantStringCoercion:
|
20
|
+
Description: Checks for Object#to_s usage in string interpolation.
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
Lint/RequireParentheses:
|
24
|
+
Description: Checks for expressions where there is a call to a predicate method with at least one
|
25
|
+
argument, where no parentheses are used around the parameter list, and a boolean operator, &&
|
26
|
+
or ||, is used in the last argument.
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Lint/ShadowingOuterLocalVariable:
|
30
|
+
Description: checks for the use of local variable names from an outer scope in block arguments or
|
31
|
+
block-local variables.
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
Lint/UriEscapeUnescape:
|
35
|
+
Description: This cop identifies places where URI.escape can be replaced by CGI.escape,
|
36
|
+
URI.encode_www_form, or URI.encode_www_form_component depending on your specific use case.
|
37
|
+
Also this cop identifies places where URI.unescape can be replaced by CGI.unescape,
|
38
|
+
URI.decode_www_form, or URI.decode_www_form_component depending on your specific use case.
|
39
|
+
Enabled: true
|
40
|
+
|
41
|
+
Lint/UselessAssignment:
|
42
|
+
Description: Checks for useless assignment to a local variable.
|
43
|
+
Enabled: true
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Metrics/AbcSize:
|
2
|
+
Description: Checks that the ABC size of methods is not higher than the configured maximum.
|
3
|
+
Enabled: false
|
4
|
+
|
5
|
+
Metrics/BlockLength:
|
6
|
+
Description: Cop checks if the length of a block exceeds some maximum value.
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/MethodLength:
|
10
|
+
Description: Checks if the length of a method exceeds some maximum value.
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/ParameterLists:
|
14
|
+
CountKeywordArgs: false
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Performance Optimization Rules
|
2
|
+
# Configuration for rubocop-performance plugin
|
3
|
+
# Focused on Ruby performance patterns for Rails 6.0+ applications
|
4
|
+
|
5
|
+
# Note: Performance cops are now provided by the rubocop-performance gem
|
6
|
+
# This configuration file provides sensible defaults for performance-oriented development
|
7
|
+
|
8
|
+
# Enable all performance cops by default (can be overridden individually)
|
9
|
+
Performance:
|
10
|
+
Enabled: true
|
11
|
+
|
12
|
+
# Specific configurations for key performance cops
|
13
|
+
Performance/OpenStruct:
|
14
|
+
Enabled: false # Can be too restrictive in some Rails applications
|
15
|
+
Severity: warning
|
16
|
+
|
17
|
+
Performance/StringIdentifierArgument:
|
18
|
+
Enabled: true
|
19
|
+
Severity: warning # Warn instead of error for gradual adoption
|
20
|
+
|
21
|
+
Performance/ChainArrayAllocation:
|
22
|
+
Enabled: true
|
23
|
+
# Allow chaining in test files where readability is more important
|
24
|
+
Exclude:
|
25
|
+
- "spec/**/*"
|
26
|
+
- "test/**/*"
|
27
|
+
|
28
|
+
Performance/CollectionLiteralInLoop:
|
29
|
+
Enabled: true
|
30
|
+
# More permissive in configuration and initializer files
|
31
|
+
Exclude:
|
32
|
+
- "config/**/*"
|
33
|
+
- "db/**/*"
|