rubocop-hk 1.1.1 → 1.2.0
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 +4 -4
- data/config/default.yml +2 -2
- data/config/rubocop-lint.yml +87 -0
- data/config/rubocop-performance.yml +75 -1
- data/config/rubocop-rails.yml +113 -10
- data/config/rubocop-rspec.yml +109 -0
- data/config/rubocop-style.yml +87 -11
- data/lib/rubocop/hk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99001468214b3d18783e17411c2adbcf9ce55703a2ec3a975f8f673b05b2fc0a
|
4
|
+
data.tar.gz: bf63386c1eebe83bce0fce9e621f863e95572ff8e7a11e572b321b4918f21f2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92b2d5dffb92e97f6c9de6921e5f3a3636fac9363591a289e9f8a693ce04fcfc06ef2a45e0d6ecd77d7a577d71b9880541508a71f95be917a75f7e8f17734717
|
7
|
+
data.tar.gz: '00559444896a2c0e48ea8a4f015e2d82676acd7cc5bc11bb0cb7f91ec969aba0923634652eb352ebe7ed01ade47590bda3b1507925752da928ae19506879138d'
|
data/config/default.yml
CHANGED
data/config/rubocop-lint.yml
CHANGED
@@ -41,3 +41,90 @@ Lint/UriEscapeUnescape:
|
|
41
41
|
Lint/UselessAssignment:
|
42
42
|
Description: Checks for useless assignment to a local variable.
|
43
43
|
Enabled: true
|
44
|
+
|
45
|
+
# ==========================================
|
46
|
+
# Modern Security & Quality Lint Cops (2025) - All WARNING ONLY
|
47
|
+
# These catch potential bugs and security issues without breaking builds
|
48
|
+
# ==========================================
|
49
|
+
|
50
|
+
Lint/RequireRangeParentheses:
|
51
|
+
Description: |
|
52
|
+
Use parentheses for ranges in conditionals to avoid precedence issues.
|
53
|
+
Without parentheses, expressions like x == 1..10 are parsed as (x == 1)..10
|
54
|
+
instead of x == (1..10). This prevents subtle bugs and makes intent clear.
|
55
|
+
Enabled: true
|
56
|
+
Severity: warning
|
57
|
+
|
58
|
+
Lint/SymbolConversion:
|
59
|
+
Description: |
|
60
|
+
Avoid unnecessary symbol conversions that can impact performance.
|
61
|
+
Converting strings to symbols repeatedly or converting symbols back to strings
|
62
|
+
unnecessarily creates memory overhead. Use the appropriate type from the start
|
63
|
+
when possible for better performance.
|
64
|
+
Enabled: true
|
65
|
+
Severity: warning
|
66
|
+
|
67
|
+
Lint/ToEnumArguments:
|
68
|
+
Description: |
|
69
|
+
Pass correct arguments to to_enum for proper enumerator behavior.
|
70
|
+
Incorrect arguments can cause enumerators to behave unexpectedly or
|
71
|
+
raise errors when iterated. This ensures enumerators work as expected
|
72
|
+
and prevents runtime errors.
|
73
|
+
Enabled: true
|
74
|
+
Severity: warning
|
75
|
+
|
76
|
+
Lint/UnexpectedBlockArity:
|
77
|
+
Description: |
|
78
|
+
Check for unexpected block arity in method calls. When blocks expect
|
79
|
+
a certain number of arguments but receive different amounts, it can
|
80
|
+
cause unexpected behavior or errors. This helps catch such mismatches early.
|
81
|
+
Enabled: true
|
82
|
+
Severity: warning
|
83
|
+
|
84
|
+
Lint/DuplicateBranch:
|
85
|
+
Description: |
|
86
|
+
Avoid duplicate branches in conditional statements. Having identical
|
87
|
+
code in multiple branches often indicates a logic error or unnecessary
|
88
|
+
complexity. This helps identify redundant code that can be simplified.
|
89
|
+
Enabled: true
|
90
|
+
Severity: warning
|
91
|
+
|
92
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
93
|
+
Description: |
|
94
|
+
Remove duplicate elements in regexp character classes. Duplicates like
|
95
|
+
[aa-z] or [a-za] don't change regexp behavior but add confusion and
|
96
|
+
may indicate typos. Clean character classes are easier to understand and maintain.
|
97
|
+
Enabled: true
|
98
|
+
Severity: warning
|
99
|
+
|
100
|
+
Lint/EmptyBlock:
|
101
|
+
Description: |
|
102
|
+
Avoid empty blocks that serve no purpose. Empty blocks often indicate
|
103
|
+
incomplete implementation or can be removed entirely. This helps identify
|
104
|
+
dead code and potential bugs from incomplete implementations.
|
105
|
+
Enabled: true
|
106
|
+
Severity: warning
|
107
|
+
|
108
|
+
Lint/NoReturnInBeginEndBlocks:
|
109
|
+
Description: |
|
110
|
+
Avoid using return in begin/end blocks as it can cause unexpected behavior.
|
111
|
+
Return statements in begin blocks can bypass ensure clauses or cause
|
112
|
+
confusing control flow. Use explicit value assignment instead.
|
113
|
+
Enabled: true
|
114
|
+
Severity: warning
|
115
|
+
|
116
|
+
Lint/NumberedParameterAssignment:
|
117
|
+
Description: |
|
118
|
+
Avoid assigning to numbered parameters (_1, _2, etc.) as it can cause
|
119
|
+
confusion and unexpected behavior. Numbered parameters should be treated
|
120
|
+
as read-only to maintain clarity in block parameter usage.
|
121
|
+
Enabled: true
|
122
|
+
Severity: warning
|
123
|
+
|
124
|
+
Lint/OrAssignmentToConstant:
|
125
|
+
Description: |
|
126
|
+
Avoid using ||= with constants as it can cause unexpected behavior.
|
127
|
+
Constants should be assigned once and not modified. Using ||= with
|
128
|
+
constants can lead to confusing code and potential runtime errors.
|
129
|
+
Enabled: true
|
130
|
+
Severity: warning
|
@@ -30,4 +30,78 @@ Performance/CollectionLiteralInLoop:
|
|
30
30
|
# More permissive in configuration and initializer files
|
31
31
|
Exclude:
|
32
32
|
- "config/**/*"
|
33
|
-
- "db/**/*"
|
33
|
+
- "db/**/*"
|
34
|
+
|
35
|
+
# ==========================================
|
36
|
+
# Modern Performance Cops (2025) - All WARNING ONLY
|
37
|
+
# These improve code performance without breaking builds
|
38
|
+
# ==========================================
|
39
|
+
|
40
|
+
Performance/BlockGivenWithExplicitBlock:
|
41
|
+
Description: |
|
42
|
+
Use block_given? efficiently with explicit blocks. When a method accepts
|
43
|
+
an explicit block parameter (&block), using block_given? is redundant
|
44
|
+
because you can check if the block parameter is nil. This improves performance
|
45
|
+
by avoiding unnecessary method calls.
|
46
|
+
Enabled: true
|
47
|
+
Severity: warning
|
48
|
+
|
49
|
+
Performance/ConstantRegexp:
|
50
|
+
Description: |
|
51
|
+
Use constant regexps for better performance. Creating regexp objects
|
52
|
+
repeatedly in loops or frequently-called methods is expensive. Store
|
53
|
+
regexps in constants to avoid recompilation and improve performance
|
54
|
+
in performance-critical code paths.
|
55
|
+
Enabled: true
|
56
|
+
Severity: warning
|
57
|
+
|
58
|
+
Performance/MethodObjectAsBlock:
|
59
|
+
Description: |
|
60
|
+
Use method objects as blocks when appropriate for better performance.
|
61
|
+
Using &:method_name syntax is often more performant than creating
|
62
|
+
explicit blocks, especially in collection methods like map, select, etc.
|
63
|
+
This reduces object allocation overhead.
|
64
|
+
Enabled: true
|
65
|
+
Severity: warning
|
66
|
+
|
67
|
+
Performance/RedundantEqualityComparisonBlock:
|
68
|
+
Description: |
|
69
|
+
Avoid redundant equality comparison blocks in collection methods.
|
70
|
+
Instead of arr.select { |x| x == value }, use more direct approaches
|
71
|
+
or built-in methods when available. This reduces unnecessary block
|
72
|
+
calls and improves performance.
|
73
|
+
Enabled: true
|
74
|
+
Severity: warning
|
75
|
+
|
76
|
+
Performance/RedundantSplitRegexpArgument:
|
77
|
+
Description: |
|
78
|
+
Avoid redundant regexp arguments to String#split. When splitting on
|
79
|
+
single characters, use string arguments instead of regexp for better
|
80
|
+
performance. For example, use str.split(',') instead of str.split(/,/).
|
81
|
+
Enabled: true
|
82
|
+
Severity: warning
|
83
|
+
|
84
|
+
Performance/StringInclude:
|
85
|
+
Description: |
|
86
|
+
Use String#include? instead of String#match? when you only need to
|
87
|
+
check for substring presence. #include? is faster for simple substring
|
88
|
+
checks because it doesn't need to compile regexp patterns or capture groups.
|
89
|
+
Enabled: true
|
90
|
+
Severity: warning
|
91
|
+
|
92
|
+
Performance/Sum:
|
93
|
+
Description: |
|
94
|
+
Use Array#sum instead of inject(:+) or reduce(:+) for numeric calculations.
|
95
|
+
Array#sum is optimized for numeric operations and provides better performance
|
96
|
+
and clearer intent when summing arrays of numbers.
|
97
|
+
Enabled: true
|
98
|
+
Severity: warning
|
99
|
+
|
100
|
+
Performance/RangeInclude:
|
101
|
+
Description: |
|
102
|
+
Use Range#cover? instead of Range#include? for performance. #cover? only
|
103
|
+
checks if the value falls within the range boundaries, while #include?
|
104
|
+
iterates through all values in the range, making #cover? much faster
|
105
|
+
for large ranges.
|
106
|
+
Enabled: true
|
107
|
+
Severity: warning
|
data/config/rubocop-rails.yml
CHANGED
@@ -321,13 +321,9 @@ Rails/CompactBlank:
|
|
321
321
|
Description: Use compact_blank instead of reject(&:blank?)
|
322
322
|
Enabled: true
|
323
323
|
|
324
|
-
Rails/DuplicateAssociation:
|
325
|
-
Description: Avoid duplicate associations in models
|
326
|
-
Enabled: true
|
324
|
+
# Rails/DuplicateAssociation: Moved to modern cops section below
|
327
325
|
|
328
|
-
Rails/DuplicateScope:
|
329
|
-
Description: Avoid duplicate scopes in models
|
330
|
-
Enabled: true
|
326
|
+
# Rails/DuplicateScope: Moved to modern cops section below
|
331
327
|
|
332
328
|
Rails/ExpandedDateRange:
|
333
329
|
Description: Use Range#cover? instead of Range#include? for date ranges
|
@@ -345,9 +341,7 @@ Rails/PluralizationGrammar:
|
|
345
341
|
Description: Use correct pluralization grammar
|
346
342
|
Enabled: true
|
347
343
|
|
348
|
-
Rails/ResponseParsedBody:
|
349
|
-
Description: Use response.parsed_body in tests
|
350
|
-
Enabled: true
|
344
|
+
# Rails/ResponseParsedBody: Moved to modern cops section below
|
351
345
|
|
352
346
|
Rails/RootJoinChain:
|
353
347
|
Description: Use Rails.root.join for multiple path segments
|
@@ -371,4 +365,113 @@ Rails/TransactionExitStatement:
|
|
371
365
|
|
372
366
|
Rails/UniqueValidationWithoutIndex:
|
373
367
|
Description: Add database index for unique validations
|
374
|
-
Enabled: true
|
368
|
+
Enabled: true
|
369
|
+
|
370
|
+
# ==========================================
|
371
|
+
# Rails 8.0+ Modern Cops (2025) - All WARNING ONLY
|
372
|
+
# These enforce Rails 8.0 best practices and modern patterns
|
373
|
+
# ==========================================
|
374
|
+
|
375
|
+
Rails/EnumSyntax:
|
376
|
+
Description: |
|
377
|
+
Use Rails 8.0+ enum syntax with positional arguments instead of keyword arguments.
|
378
|
+
The keyword argument syntax (enum status: {...}, _prefix: true) is deprecated in Rails 8.0.
|
379
|
+
Use: enum :status, {...}, prefix: true instead. This prepares your code for future Rails versions.
|
380
|
+
Enabled: true
|
381
|
+
Severity: warning
|
382
|
+
|
383
|
+
Rails/RedundantActiveRecordAllMethod:
|
384
|
+
Description: |
|
385
|
+
Avoid redundant .all method calls in ActiveRecord queries. Modern Rails often
|
386
|
+
returns ActiveRecord::Relation objects that are already lazy-loaded, so .all
|
387
|
+
may be unnecessary and can impact performance. Remove when the relation is already sufficient.
|
388
|
+
Enabled: true
|
389
|
+
Severity: warning
|
390
|
+
|
391
|
+
Rails/MigrationClassName:
|
392
|
+
Description: |
|
393
|
+
Use appropriate migration class names that reflect the migration's purpose.
|
394
|
+
Migration class names should be descriptive and follow Rails conventions
|
395
|
+
(PascalCase matching the filename). This improves code maintainability and searchability.
|
396
|
+
Enabled: true
|
397
|
+
Severity: warning
|
398
|
+
|
399
|
+
Rails/WhereRange:
|
400
|
+
Description: |
|
401
|
+
Use range conditions in where clauses for better readability and performance.
|
402
|
+
Instead of where(created_at: start_date..end_date), consider using where(created_at: start_date...end_date)
|
403
|
+
or explicit range methods for clearer intent and potential query optimization.
|
404
|
+
Enabled: true
|
405
|
+
Severity: warning
|
406
|
+
|
407
|
+
Rails/ThreeStateBooleanColumn:
|
408
|
+
Description: |
|
409
|
+
Avoid three-state boolean columns (true/false/null). These create confusion
|
410
|
+
about the meaning of null vs false. Use explicit status enums or separate
|
411
|
+
boolean columns with defaults to make data meaning clear and queries predictable.
|
412
|
+
Enabled: true
|
413
|
+
Severity: warning
|
414
|
+
|
415
|
+
Rails/AddColumnIndex:
|
416
|
+
Description: |
|
417
|
+
Add database indexes when adding new columns that will be queried frequently.
|
418
|
+
This prevents performance issues as data grows. Consider adding indexes for
|
419
|
+
foreign keys, columns used in where clauses, and columns used for ordering.
|
420
|
+
Enabled: true
|
421
|
+
Severity: warning
|
422
|
+
|
423
|
+
Rails/FreezeTime:
|
424
|
+
Description: |
|
425
|
+
Use Rails' travel_to instead of Time.stub or similar time mocking approaches.
|
426
|
+
travel_to is the Rails-standard way to manipulate time in tests and provides
|
427
|
+
better integration with Rails' time handling and ActiveSupport extensions.
|
428
|
+
Enabled: true
|
429
|
+
Severity: warning
|
430
|
+
|
431
|
+
Rails/ResponseParsedBody:
|
432
|
+
Description: |
|
433
|
+
Use response.parsed_body in tests instead of JSON.parse(response.body).
|
434
|
+
This is more reliable, handles different content types automatically,
|
435
|
+
and is the Rails-standard approach for parsing response bodies in tests.
|
436
|
+
Enabled: true
|
437
|
+
Severity: warning
|
438
|
+
|
439
|
+
Rails/DotSeparatedKeys:
|
440
|
+
Description: |
|
441
|
+
Use dot-separated keys in I18n for better organization and namespacing.
|
442
|
+
This creates clearer hierarchical structure in locale files and makes
|
443
|
+
translations easier to organize and maintain in large applications.
|
444
|
+
Enabled: true
|
445
|
+
Severity: warning
|
446
|
+
|
447
|
+
Rails/RootPublicPath:
|
448
|
+
Description: |
|
449
|
+
Use Rails.root.join('public') instead of File.join(Rails.root, 'public').
|
450
|
+
This is more idiomatic Rails and handles path construction more reliably
|
451
|
+
across different operating systems and Ruby versions.
|
452
|
+
Enabled: true
|
453
|
+
Severity: warning
|
454
|
+
|
455
|
+
Rails/DeprecatedActiveModelErrorsMethods:
|
456
|
+
Description: |
|
457
|
+
Avoid deprecated ActiveModel::Errors methods. Rails 6.1+ changed the errors
|
458
|
+
API significantly. Use errors.add instead of errors[] = and similar modern
|
459
|
+
approaches to future-proof your validation error handling.
|
460
|
+
Enabled: true
|
461
|
+
Severity: warning
|
462
|
+
|
463
|
+
Rails/DuplicateAssociation:
|
464
|
+
Description: |
|
465
|
+
Avoid duplicate associations in ActiveRecord models. Multiple associations
|
466
|
+
with the same name can cause unexpected behavior and make code harder to
|
467
|
+
understand. Each association should have a unique, descriptive name.
|
468
|
+
Enabled: true
|
469
|
+
Severity: warning
|
470
|
+
|
471
|
+
Rails/DuplicateScope:
|
472
|
+
Description: |
|
473
|
+
Avoid duplicate scopes in ActiveRecord models. Multiple scopes with the
|
474
|
+
same name override each other, leading to confusion. Each scope should
|
475
|
+
have a unique, descriptive name that clearly indicates its purpose.
|
476
|
+
Enabled: true
|
477
|
+
Severity: warning
|
data/config/rubocop-rspec.yml
CHANGED
@@ -27,3 +27,112 @@ RSpec/MultipleMemoizedHelpers:
|
|
27
27
|
RSpec/NestedGroups:
|
28
28
|
Description: Checks for nested example groups.
|
29
29
|
Enabled: false
|
30
|
+
|
31
|
+
RSpec/VerifiedDoubles:
|
32
|
+
Description: Prefer instance doubles over stubbing any instance of a class.
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
RSpec/MessageChain:
|
36
|
+
Description: Check that chains of messages are not being stubbed.
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# ==========================================
|
40
|
+
# Modern RSpec Cops (2025) - All WARNING ONLY
|
41
|
+
# These improve test quality and readability without breaking builds
|
42
|
+
# ==========================================
|
43
|
+
|
44
|
+
RSpec/BeEq:
|
45
|
+
Description: |
|
46
|
+
Use be_eq matcher when testing for object equality. This is more explicit than
|
47
|
+
using == and provides better failure messages. It clearly indicates you're testing
|
48
|
+
for value equality rather than object identity (be_equal).
|
49
|
+
Enabled: true
|
50
|
+
Severity: warning
|
51
|
+
|
52
|
+
RSpec/BeNil:
|
53
|
+
Description: |
|
54
|
+
Use be_nil matcher instead of be(nil) or eq(nil). This provides more descriptive
|
55
|
+
failure messages and is the conventional RSpec way to test for nil values.
|
56
|
+
Makes test intent clearer and improves readability.
|
57
|
+
Enabled: true
|
58
|
+
Severity: warning
|
59
|
+
|
60
|
+
RSpec/ChangeByZero:
|
61
|
+
Description: |
|
62
|
+
Use 'not_to change' instead of 'to change.by(0)' for better expressiveness.
|
63
|
+
This makes test intent clearer - you're explicitly stating that something
|
64
|
+
should NOT change rather than implying it changes by zero.
|
65
|
+
Enabled: true
|
66
|
+
Severity: warning
|
67
|
+
|
68
|
+
RSpec/ClassCheck:
|
69
|
+
Description: |
|
70
|
+
Use be_a/be_kind_of instead of be_instance_of when testing class inheritance.
|
71
|
+
be_instance_of tests for exact class match, while be_a allows inheritance,
|
72
|
+
which is usually what you want in object-oriented testing.
|
73
|
+
Enabled: true
|
74
|
+
Severity: warning
|
75
|
+
|
76
|
+
RSpec/EmptyMetadata:
|
77
|
+
Description: |
|
78
|
+
Avoid empty metadata hashes in RSpec examples. Empty metadata serves no purpose
|
79
|
+
and adds noise to test files. Either add meaningful metadata or remove the
|
80
|
+
empty hash entirely for cleaner test code.
|
81
|
+
Enabled: true
|
82
|
+
Severity: warning
|
83
|
+
|
84
|
+
RSpec/ExcessiveDocstringSpacing:
|
85
|
+
Description: |
|
86
|
+
Avoid excessive spacing in RSpec docstrings. Consistent formatting improves
|
87
|
+
readability and maintains professional code appearance. Too much spacing
|
88
|
+
makes tests harder to scan and understand quickly.
|
89
|
+
Enabled: true
|
90
|
+
Severity: warning
|
91
|
+
|
92
|
+
RSpec/IdenticalEqualityAssertion:
|
93
|
+
Description: |
|
94
|
+
Avoid identical equality assertions like expect(foo).to eq(foo). These tests
|
95
|
+
will always pass and don't provide value. They may indicate copy-paste errors
|
96
|
+
or misunderstanding of what's being tested.
|
97
|
+
Enabled: true
|
98
|
+
Severity: warning
|
99
|
+
|
100
|
+
RSpec/SubjectDeclaration:
|
101
|
+
Description: |
|
102
|
+
Use subject blocks consistently throughout your test suite. This ensures
|
103
|
+
uniform test structure and makes tests more predictable and maintainable.
|
104
|
+
Consistent patterns reduce cognitive load when reading tests.
|
105
|
+
Enabled: true
|
106
|
+
Severity: warning
|
107
|
+
|
108
|
+
RSpec/VerifiedDoubleReference:
|
109
|
+
Description: |
|
110
|
+
Reference classes when using verified doubles for better test reliability.
|
111
|
+
Verified doubles catch method signature changes and prevent tests from
|
112
|
+
passing when the actual API has changed. However, kept flexible per your needs.
|
113
|
+
Enabled: false
|
114
|
+
Severity: warning
|
115
|
+
|
116
|
+
RSpec/RedundantAround:
|
117
|
+
Description: |
|
118
|
+
Avoid redundant around blocks that only call yield. These add complexity
|
119
|
+
without providing value. Use before/after hooks or remove the around block
|
120
|
+
entirely for cleaner, more direct test setup.
|
121
|
+
Enabled: true
|
122
|
+
Severity: warning
|
123
|
+
|
124
|
+
RSpec/ScatteredSetup:
|
125
|
+
Description: |
|
126
|
+
Group setup logic together instead of scattering it throughout tests.
|
127
|
+
This improves test readability and makes the setup phase clear and
|
128
|
+
maintainable. Scattered setup makes tests harder to understand.
|
129
|
+
Enabled: true
|
130
|
+
Severity: warning
|
131
|
+
|
132
|
+
RSpec/StubbedMock:
|
133
|
+
Description: |
|
134
|
+
Avoid stubbing methods on mocked objects. This can create confusing test
|
135
|
+
scenarios where it's unclear what's being tested. Keep mocking and stubbing
|
136
|
+
separate for clearer test intent and easier debugging.
|
137
|
+
Enabled: true
|
138
|
+
Severity: warning
|
data/config/rubocop-style.yml
CHANGED
@@ -105,17 +105,7 @@ Style/FrozenStringLiteralComment:
|
|
105
105
|
- "config/boot.rb"
|
106
106
|
- "db/migrate/**/*"
|
107
107
|
|
108
|
-
Style/HashSyntax:
|
109
|
-
Description: Checks hash literal syntax
|
110
|
-
Enabled: true
|
111
|
-
EnforcedStyle: ruby19
|
112
|
-
UseHashRocketsWithSymbolValues: false
|
113
|
-
PreferHashRocketsForNonAlnumEndingSymbols: false
|
114
|
-
SupportedStyles:
|
115
|
-
- ruby19
|
116
|
-
- hash_rockets
|
117
|
-
- no_mixed_keys
|
118
|
-
- ruby19_no_mixed_keys
|
108
|
+
# Style/HashSyntax: Updated configuration moved to modern cops section below
|
119
109
|
|
120
110
|
Style/MethodDefParentheses:
|
121
111
|
Description: Checks if the method definitions have or don't have parentheses.
|
@@ -195,3 +185,89 @@ Style/TrivialAccessors:
|
|
195
185
|
AllowDSLWriters: true
|
196
186
|
IgnoreClassMethods: false
|
197
187
|
|
188
|
+
# ==========================================
|
189
|
+
# Modern Ruby 3.3 Style Cops (2025) - All WARNING ONLY
|
190
|
+
# These help adopt modern Ruby patterns without breaking builds
|
191
|
+
# ==========================================
|
192
|
+
|
193
|
+
Style/FetchEnvVar:
|
194
|
+
Description: |
|
195
|
+
Use ENV.fetch for environment variables instead of ENV[] for better error handling.
|
196
|
+
This prevents silent failures when environment variables are missing and provides
|
197
|
+
clear error messages. Example: ENV.fetch('API_KEY') vs ENV['API_KEY']
|
198
|
+
Enabled: true
|
199
|
+
Severity: warning
|
200
|
+
|
201
|
+
Style/HashSyntax:
|
202
|
+
Description: |
|
203
|
+
Use modern Ruby hash syntax consistently. Ruby 1.9+ allows symbol: value syntax
|
204
|
+
which is more readable and concise than :symbol => value. This cop enforces
|
205
|
+
consistent usage across your codebase for better readability.
|
206
|
+
Enabled: true
|
207
|
+
Severity: warning
|
208
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
209
|
+
|
210
|
+
Style/ArgumentsForwarding:
|
211
|
+
Description: |
|
212
|
+
Use Ruby 2.7+ argument forwarding (...) instead of explicit *args, **kwargs.
|
213
|
+
This makes method delegation cleaner and more efficient. Example: def foo(...); bar(...); end
|
214
|
+
instead of def foo(*args, **kwargs); bar(*args, **kwargs); end
|
215
|
+
Enabled: true
|
216
|
+
Severity: warning
|
217
|
+
|
218
|
+
Style/CollectionCompact:
|
219
|
+
Description: |
|
220
|
+
Use Array#compact and Hash#compact instead of reject(&:nil?) or similar patterns.
|
221
|
+
These methods are more expressive and potentially more performant. They clearly
|
222
|
+
indicate intent to remove nil values from collections.
|
223
|
+
Enabled: true
|
224
|
+
Severity: warning
|
225
|
+
|
226
|
+
Style/StringChars:
|
227
|
+
Description: |
|
228
|
+
Use String#chars instead of String#each_char.to_a for converting strings to arrays.
|
229
|
+
#chars is more direct and readable, clearly expressing the intent to get an array
|
230
|
+
of characters rather than iterating through them.
|
231
|
+
Enabled: true
|
232
|
+
Severity: warning
|
233
|
+
|
234
|
+
Style/MapToHash:
|
235
|
+
Description: |
|
236
|
+
Use to_h instead of map followed by Hash[] for converting arrays to hashes.
|
237
|
+
This is more readable and potentially more performant, clearly expressing the
|
238
|
+
intent to create a hash from key-value pairs.
|
239
|
+
Enabled: true
|
240
|
+
Severity: warning
|
241
|
+
|
242
|
+
Style/HashTransformKeys:
|
243
|
+
Description: |
|
244
|
+
Use transform_keys instead of each_with_object or map for transforming hash keys.
|
245
|
+
This method is more expressive and clearly indicates the intent to modify keys
|
246
|
+
while preserving values, making code more maintainable.
|
247
|
+
Enabled: true
|
248
|
+
Severity: warning
|
249
|
+
|
250
|
+
Style/HashTransformValues:
|
251
|
+
Description: |
|
252
|
+
Use transform_values instead of each_with_object or map for transforming hash values.
|
253
|
+
This method is more expressive and clearly indicates the intent to modify values
|
254
|
+
while preserving keys, improving code readability and intent.
|
255
|
+
Enabled: true
|
256
|
+
Severity: warning
|
257
|
+
|
258
|
+
Style/SlicingWithRange:
|
259
|
+
Description: |
|
260
|
+
Use range slicing syntax (arr[1..3]) instead of arr.slice(1, 3) when working with ranges.
|
261
|
+
This is more concise and idiomatic Ruby, making code more readable and consistent
|
262
|
+
with Ruby conventions for array manipulation.
|
263
|
+
Enabled: true
|
264
|
+
Severity: warning
|
265
|
+
|
266
|
+
Style/RedundantArgument:
|
267
|
+
Description: |
|
268
|
+
Remove redundant arguments that match method defaults. This reduces code noise
|
269
|
+
and makes the essential parts of method calls more visible. It also future-proofs
|
270
|
+
code against changes in default values.
|
271
|
+
Enabled: true
|
272
|
+
Severity: warning
|
273
|
+
|
data/lib/rubocop/hk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-hk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hammad Khan
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 3.
|
117
|
+
version: 3.3.0
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - ">="
|