gemwork 0.7.19 → 0.7.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbc5491e286cd012bfc6af3218a975ab71c2fdf9c5d48e1cc11629e7f0df3fd7
4
- data.tar.gz: 5221fbf8bcb678c7415c52b07eb52772ef9c147e745709007ca46448ccc8b864
3
+ metadata.gz: 9b5a2126cb36e2888966c286fb921ba2ce7d58c219846e0f7110f0fb19147463
4
+ data.tar.gz: 450f4d526499f10d177576e83217f58190b6866576623b09a97089c82f906fb1
5
5
  SHA512:
6
- metadata.gz: 64e5a84ea52820dab69533c4572cc0c8d862708ab3595a6d5e718e7d8033ff7cee6e3e133e58750872ce05fce09c7dc1d3a72389994fea4d7fd5fd684330972d
7
- data.tar.gz: ddd21dc01acd9d609846c55b894c0c237026159b93dbc1f15e040493f143d9d0a45d911d63bb11fc31f0f9a3320ffa6b2eaac0394ecf8ef90fbe5ef58bf9fd6a
6
+ metadata.gz: bd056e7cb7a911da9a56fbbc2cc7327a79f2210c9f63dfaede37072d718761560b1b17ac5517651630a15b060ac7365de47a60493c6b90ad5aea4768d574a325
7
+ data.tar.gz: 29face0701ef9cccc049958853e8bcf6be4f744845be33227c05975f46d7ee15207f45422105dfb75270f10f72efd1d99199e863e57cd072988bdd818fa828d2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.21] - 2025-10-12
4
+
5
+ - Exclude BaseControllers from Rails/ApplicationController
6
+ - Remove `EnabledByDefault` from all_cops-rails.yml
7
+
8
+ ## [0.7.20] - 2025-10-11
9
+
10
+ - Mass-Update Rubocop styles to match latest conventions from my professional projects
11
+
3
12
  ## [0.7.19] - 2025-7-5
4
13
 
5
14
  - Update Rubocop styles re: multi-line method definitions/calls.
@@ -35,6 +44,7 @@
35
44
  - Fix `brakeman` task to not report on filtered warnings (i.e. ignored warnings)
36
45
 
37
46
  ## [0.7.11] - 2025-2-15
47
+
38
48
  (0.7.10 yanked)
39
49
 
40
50
  - Minimize `rake brakeman` output when no warnings; return failure otherwise
data/lib/.DS_Store CHANGED
Binary file
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gemwork
4
- VERSION = "0.7.19"
4
+ VERSION = "0.7.22"
5
+ public_constant :VERSION
5
6
  end
@@ -8,6 +8,7 @@ inherit_from:
8
8
  - ./metrics-rails.yml
9
9
  - ./minitest.yml
10
10
  - ./naming.yml
11
+ - ./naming-rails.yml
11
12
  - ./performance.yml
12
13
  - ./rails.yml
13
14
  - ./style.yml
@@ -1,7 +1,6 @@
1
1
  AllCops:
2
2
  ActiveSupportExtensionsEnabled: true
3
3
  DisplayStyleGuide: true
4
- EnabledByDefault: true
5
4
  ExtraDetails: true
6
5
  NewCops: enable
7
6
  UseCache: true
@@ -1,6 +1,5 @@
1
1
  AllCops:
2
2
  DisplayStyleGuide: true
3
- EnabledByDefault: true
4
3
  ExtraDetails: true
5
4
  NewCops: enable
6
5
  UseCache: true
@@ -1,7 +1,12 @@
1
1
  Bundler/GemComment:
2
+ # When limiting a gem version or restricing to a GitHub commit-ish, it's
3
+ # helpful to say why (inline) so deciding on upgradability later is easier.
2
4
  OnlyFor:
3
5
  - restrictive_version_specifiers
4
6
  - github
5
7
 
6
8
  Bundler/GemVersion:
9
+ # Don't require specifying a gem version. Prefer to optimize for
10
+ # upgradeability, so we don't become stale.
11
+ # Don't forbid specifying a gem version, either, as it's sometimes necessary.
7
12
  Enabled: false
@@ -1,4 +1,76 @@
1
+ Layout/ClassStructure:
2
+ # Establish a convention for code order within classes.
3
+ Enabled: true
4
+ AutoCorrect: false
5
+ Categories:
6
+ module_inclusion:
7
+ - extend
8
+ - include
9
+ - prepend
10
+ callbacks:
11
+ - before_validation
12
+ - after_validation
13
+ - before_save
14
+ - around_save
15
+ - before_create
16
+ - around_create
17
+ - after_create
18
+ - before_update
19
+ - around_update
20
+ - after_update
21
+ - after_save
22
+ - before_destroy
23
+ - around_destroy
24
+ - after_destroy
25
+ - after_commit
26
+ - after_rollback
27
+ - after_initialize
28
+ - after_find
29
+ public_attribute_macros:
30
+ - attr_accessor
31
+ - attr_reader
32
+ - attr_writer
33
+ - serialize
34
+ associations:
35
+ - belongs_to
36
+ - has_one
37
+ - has_many
38
+ - has_and_belongs_to_many
39
+ - accepts_nested_attributes_for
40
+ validations:
41
+ - validates
42
+ - validates_associated
43
+ - validates_with
44
+ - validates_each
45
+ scopes:
46
+ - scope
47
+ concerning_blocks:
48
+ - concerning
49
+ ExpectedOrder:
50
+ - constants
51
+ - module_inclusion
52
+ - callbacks
53
+ - associations
54
+ - validations
55
+ - public_delegate
56
+ - scopes
57
+ - public_class_methods
58
+ # - public_attribute_macros
59
+ - initializer
60
+ - public_methods
61
+ - protected_attribute_macros
62
+ - protected_methods
63
+ - private_attribute_macros
64
+ - private_delegate
65
+ - private_methods
66
+ - concerning_blocks
67
+
1
68
  Layout/FirstMethodArgumentLineBreak:
69
+ # Require line break before the first argument in a multi-line method call.
70
+ # Example:
71
+ # my_method(
72
+ # a: 1,
73
+ # # ...
2
74
  Enabled: true
3
75
  AllowMultilineFinalElement: true
4
76
  AllowedMethods:
@@ -6,11 +78,19 @@ Layout/FirstMethodArgumentLineBreak:
6
78
  - safe_join
7
79
 
8
80
  Layout/LineLength:
81
+ # Max 80 chars. See: https://rubystyle.guide/#max-line-length
9
82
  Exclude:
10
83
  - Gemfile
11
84
  - config/environments/*.rb
85
+ - config/routes.rb
12
86
  - db/seeds.rb
13
87
 
14
88
  Layout/MultilineArrayLineBreaks:
89
+ # Require each item in a multi-line Array to start on a separate line.
90
+ # Example:
91
+ # [
92
+ # # ...
93
+ # c
94
+ # ]
15
95
  Exclude:
16
96
  - db/seeds.rb
@@ -1,67 +1,132 @@
1
1
  Layout/ClassStructure:
2
- Enabled: false # Consider implementing on a per-project basis.
2
+ # Establish a convention for code order within classes.
3
+ Enabled: true
4
+ AutoCorrect: false
5
+ Categories:
6
+ module_inclusion:
7
+ - extend
8
+ - include
9
+ - prepend
10
+ concerning_blocks:
11
+ - concerning
12
+ ExpectedOrder:
13
+ - constants
14
+ - module_inclusion
15
+ - public_delegate
16
+ - public_class_methods
17
+ # - public_attribute_macros
18
+ - initializer
19
+ - public_methods
20
+ - protected_attribute_macros
21
+ - protected_methods
22
+ - private_attribute_macros
23
+ - private_methods
24
+ - concerning_blocks
3
25
 
4
26
  Layout/DotPosition:
27
+ # Prefer leading dots for multi-line method chaining. This improves
28
+ # grep-ability of calls to a specific method as it removes variability.
29
+ # # Good
30
+ # my_method
31
+ # .my_other_method # 👀 Can still reliably grep on `.my_other_method`
5
32
  EnforcedStyle: leading
6
33
 
7
- Layout/EmptyLineAfterGuardClause:
8
- Enabled: true
9
-
10
- Layout/EmptyLineAfterMultilineCondition:
11
- Enabled: false
12
-
13
34
  Layout/EndOfLine:
35
+ # Require unix-style line endings.
14
36
  EnforcedStyle: lf
15
37
 
16
- Layout/FirstArgumentIndentation:
17
- EnforcedStyle: consistent_relative_to_receiver
18
-
19
38
  Layout/FirstArrayElementIndentation:
39
+ # Treat Arrays in multi-line method calls the same as multi-line Arrays.
40
+ # and_in_a_method_call([
41
+ # :no_difference
42
+ # ])
20
43
  EnforcedStyle: consistent
21
44
 
22
45
  Layout/FirstArrayElementLineBreak:
46
+ # Example:
47
+ # [
48
+ # :a, # ...
23
49
  Enabled: true
24
50
 
25
51
  Layout/FirstHashElementIndentation:
52
+ # Treat Hash in method call the same as multi-line Arrays.
53
+ # Example:
54
+ # hash = {
55
+ # key: :value
56
+ # }
57
+ # and_in_a_method_call({
58
+ # no: :difference
59
+ # })
26
60
  EnforcedStyle: consistent
27
61
 
28
62
  Layout/FirstHashElementLineBreak:
63
+ # Example:
64
+ # {
65
+ # a: 1, # ...
29
66
  Enabled: true
30
67
 
31
68
  Layout/FirstMethodArgumentLineBreak:
69
+ # Require line break before the first argument in a multi-line method call.
70
+ # Example:
71
+ # my_method(
72
+ # a: 1,
73
+ # # ...
32
74
  Enabled: true
75
+ # Example:
76
+ # my_method(a: 1, {
77
+ # b: 2,
78
+ # # ...
79
+ # })
33
80
  AllowMultilineFinalElement: true
34
81
 
35
82
  Layout/FirstMethodParameterLineBreak:
83
+ # Require a line break before the first parameter in a multi-line method
84
+ # parameter definition.
85
+ # Example:
86
+ # my_method(
87
+ # foo,
88
+ # # ...
89
+ # )
36
90
  Enabled: true
91
+ # Example:
92
+ # my_method(foo, bar = {
93
+ # a: 1,
94
+ # # ...
95
+ # })
96
+ AllowMultilineFinalElement: true
37
97
 
38
98
  Layout/FirstParameterIndentation:
39
99
  # The first parameter should always be indented one step more than the
40
100
  # preceding line. e.g.
41
101
  # def my_method(
42
- # my_arg1 # <- 👀EnforcedStyleForMultiline
102
+ # my_arg1
43
103
  # )
44
104
  Enabled: true
45
105
 
46
106
  Layout/HeredocArgumentClosingParenthesis:
107
+ # Require closing parentheses to be after opening of HEREDOC tags.
108
+ # Example:
109
+ # foo(<<-SQL.squish)
110
+ # bar
111
+ # SQL
47
112
  Enabled: true
48
113
 
49
114
  Layout/LineContinuationSpacing:
115
+ # Don't allow spaces between preceding text and the line continuation
116
+ # character (`\`).
117
+ # Example:
118
+ # "a"\
119
+ # "b"
50
120
  EnforcedStyle: no_space
51
121
 
52
- Layout/LineEndStringConcatenationIndentation:
53
- EnforcedStyle: aligned
54
-
55
122
  Layout/LineLength:
123
+ # Max 80 chars. See: https://rubystyle.guide/#max-line-length
56
124
  Max: 80
57
125
  Exclude:
58
126
  - "*.gemspec"
59
127
  AllowedPatterns:
60
- # Deeply namespaced classes
61
- - !ruby/regexp /\A *# [a-zA-z:]+\z/
62
- # YARD doc `@example` output.
63
- - !ruby/regexp /\A *# \# => /
64
- - !ruby/regexp /\A *# =/
128
+ # Exempt showing example output in comments (e.g. in YARD docs).
129
+ - !ruby/regexp /\A *#.*# => /
65
130
 
66
131
  Layout/MultilineAssignmentLayout:
67
132
  Enabled: true
@@ -74,18 +139,27 @@ Layout/MultilineAssignmentLayout:
74
139
  - module
75
140
 
76
141
  Layout/MultilineArrayLineBreaks:
142
+ # Require each item in a multi-line Array to start on a separate line.
143
+ # Example:
144
+ # [
145
+ # # ...
146
+ # c
147
+ # ]
77
148
  Enabled: true
78
149
 
79
150
  Layout/MultilineHashKeyLineBreaks:
151
+ # Require each key in a multi-line Hash to start on a separate line.
152
+ # Example:
153
+ # {
154
+ # # ...
155
+ # c: 3
156
+ # }
80
157
  Enabled: true
81
158
 
82
- Layout/MultilineMethodArgumentLineBreaks:
83
- Enabled: false
84
-
85
- Layout/MultilineMethodCallBraceLayout:
86
- EnforcedStyle: symmetrical
87
-
88
159
  Layout/MultilineMethodCallIndentation:
160
+ # Example:
161
+ # while my_object
162
+ # .my_method
89
163
  EnforcedStyle: indented_relative_to_receiver
90
164
 
91
165
  Layout/MultilineMethodDefinitionBraceLayout:
@@ -94,17 +168,5 @@ Layout/MultilineMethodDefinitionBraceLayout:
94
168
  # def my_method(
95
169
  # my_arg1,
96
170
  # my_arg2,
97
- # ) # <- 👀
171
+ # )
98
172
  EnforcedStyle: new_line
99
-
100
- Layout/MultilineMethodParameterLineBreaks:
101
- Enabled: false
102
-
103
- Layout/MultilineOperationIndentation:
104
- Enabled: false # Waiting for e.g. `indented_relative_to_receiver`.
105
-
106
- Layout/RedundantLineBreak:
107
- Enabled: false
108
-
109
- Layout/SingleLineBlockChain:
110
- Enabled: false
data/lib/rubocop/lint.yml CHANGED
@@ -1,12 +1,7 @@
1
- Lint/ConstantResolution:
2
- Enabled: false
3
-
4
1
  Lint/HeredocMethodCallPosition:
2
+ # Prefer to locate method calls on the end of the opening heredoc statement.
5
3
  Enabled: true
6
4
 
7
- Lint/NumberConversion:
8
- Enabled: false
9
-
10
5
  Lint/UselessAccessModifier:
11
6
  ContextCreatingMethods:
12
7
  - concerning
@@ -4,13 +4,21 @@ Metrics/AbcSize:
4
4
 
5
5
  Metrics/BlockLength:
6
6
  Exclude:
7
+ - config/initializers/*.rb
7
8
  - config/environments/*.rb
8
9
  - config/routes.rb
9
10
  - db/migrate/*.rb
10
11
  - db/seeds.rb
12
+ - lib/tasks/**/*.rake
11
13
  - test/**/*
12
14
 
15
+ Metrics/CyclomaticComplexity:
16
+ Exclude:
17
+ - db/migrate/*.rb
18
+
13
19
  Metrics/MethodLength:
20
+ # Ignore common sources of false positives. Especially when using multi-line
21
+ # Arrays, Hashes, heredocs, and/or method calls.
14
22
  AllowedMethods:
15
23
  - create
16
24
  - update
@@ -1,20 +1,26 @@
1
1
  Metrics/BlockLength:
2
+ # Ignore common sources of false positives.
2
3
  AllowedMethods:
3
4
  - ips # Benchmarking
4
5
  - new
5
6
  Exclude:
6
- - "test/**/*"
7
+ - rakelib/**
8
+ - test/**/*.rb
7
9
 
8
10
  Metrics/ClassLength:
11
+ # Ignore common sources of false positives. Especially when using multi-line
12
+ # Arrays, Hashes, heredocs, and/or method calls.
9
13
  CountAsOne:
10
14
  - array
11
15
  - hash
12
16
  - heredoc
13
17
  - method_call
14
18
  Exclude:
15
- - "test/**/*"
19
+ - test/**/*.rb
16
20
 
17
21
  Metrics/MethodLength:
22
+ # Ignore common sources of false positives. Especially when using multi-line
23
+ # Arrays, Hashes, heredocs, and/or method calls.
18
24
  CountAsOne:
19
25
  - array
20
26
  - hash
@@ -22,6 +28,8 @@ Metrics/MethodLength:
22
28
  - method_call
23
29
 
24
30
  Metrics/ModuleLength:
31
+ # Ignore common sources of false positives. Especially when using multi-line
32
+ # Arrays, Hashes, heredocs, and/or method calls.
25
33
  CountAsOne:
26
34
  - array
27
35
  - hash
@@ -1,5 +1,128 @@
1
+ Minitest/AssertEmpty:
2
+ # Irrelevant. Use expectations, not assertions.
3
+ Enabled: false
4
+
5
+ Minitest/AssertEmptyLiteral:
6
+ # Irrelevant. Use expectations, not assertions.
7
+ Enabled: false
8
+
9
+ Minitest/AssertEqual:
10
+ # Irrelevant. Use expectations, not assertions.
11
+ Enabled: false
12
+
13
+ Minitest/AssertInDelta:
14
+ # Irrelevant. Use expectations, not assertions.
15
+ Enabled: false
16
+
17
+ Minitest/AssertIncludes:
18
+ # Irrelevant. Use expectations, not assertions.
19
+ Enabled: false
20
+
21
+ Minitest/AssertInstanceOf:
22
+ # Irrelevant. Use expectations, not assertions.
23
+ Enabled: false
24
+
25
+ Minitest/AssertKindOf:
26
+ # Irrelevant. Use expectations, not assertions.
27
+ Enabled: false
28
+
29
+ Minitest/AssertMatch:
30
+ # Irrelevant. Use expectations, not assertions.
31
+ Enabled: false
32
+
33
+ Minitest/AssertOperator:
34
+ # Irrelevant. Use expectations, not assertions.
35
+ Enabled: false
36
+
37
+ Minitest/AssertPathExists:
38
+ # Irrelevant. Use expectations, not assertions.
39
+ Enabled: false
40
+
41
+ Minitest/AssertPredicate:
42
+ # Irrelevant. Use expectations, not assertions.
43
+ Enabled: false
44
+
45
+ Minitest/AssertRaisesCompoundBody:
46
+ # Irrelevant. Use expectations, not assertions.
47
+ Enabled: false
48
+
49
+ Minitest/AssertRespondTo:
50
+ # Irrelevant. Use expectations, not assertions.
51
+ Enabled: false
52
+
53
+ Minitest/AssertTruthy:
54
+ # Irrelevant. Use expectations, not assertions.
55
+ Enabled: false
56
+
57
+ Minitest/AssertWithExpectedArgument:
58
+ # Irrelevant. Use expectations, not assertions.
59
+ Enabled: false
60
+
61
+ Minitest/EmptyLineBeforeAssertionMethods:
62
+ # Let the context determine the best way to tell the story.
63
+ Enabled: false
64
+
65
+ Minitest/LiteralAsActualArgument:
66
+ # Irrelevant. Use expectations, not assertions.
67
+ Enabled: false
68
+
69
+ Minitest/MultipleAssertions:
70
+ # Test examples with many assertions can be trusted to be written as such for
71
+ # a reason. This is not a common habit for this team.
72
+ Enabled: false
73
+
1
74
  Minitest/NoAssertions:
2
- Enabled: false # Incompatible with Spec DSL.
75
+ # Incompatible with Spec DSL, which uses expectations instead of assertions.
76
+ Enabled: false
3
77
 
4
78
  Minitest/NoTestCases:
79
+ # Don't check in a test file if it has no test cases.
5
80
  Enabled: true
81
+
82
+ Minitest/RefuteEmpty:
83
+ # Irrelevant. Use expectations, not assertions.
84
+ Enabled: false
85
+
86
+ Minitest/RefuteEqual:
87
+ # Irrelevant. Use expectations, not assertions.
88
+ Enabled: false
89
+
90
+ Minitest/RefuteFalse:
91
+ # Irrelevant. Use expectations, not assertions.
92
+ Enabled: false
93
+
94
+ Minitest/RefuteInDelta:
95
+ # Irrelevant. Use expectations, not assertions.
96
+ Enabled: false
97
+
98
+ Minitest/RefuteIncludes:
99
+ # Irrelevant. Use expectations, not assertions.
100
+ Enabled: false
101
+
102
+ Minitest/RefuteInstanceOf:
103
+ # Irrelevant. Use expectations, not assertions.
104
+ Enabled: false
105
+
106
+ Minitest/RefuteKindOf:
107
+ # Irrelevant. Use expectations, not assertions.
108
+ Enabled: false
109
+
110
+ Minitest/RefuteMatch:
111
+ # Irrelevant. Use expectations, not assertions.
112
+ Enabled: false
113
+
114
+ Minitest/RefuteOperator:
115
+ # Irrelevant. Use expectations, not assertions.
116
+ Enabled: false
117
+
118
+ Minitest/RefutePathExists:
119
+ # Irrelevant. Use expectations, not assertions.
120
+ Enabled: false
121
+
122
+ Minitest/RefutePredicate:
123
+ # Irrelevant. Use expectations, not assertions.
124
+ Enabled: false
125
+
126
+ Minitest/UnspecifiedException:
127
+ # Irrelevant. Use expectations, not assertions.
128
+ Enabled: false
@@ -0,0 +1,22 @@
1
+ Naming/BlockParameterName:
2
+ MinNameLength: 2
3
+ AllowedNames:
4
+ - f # FormBuilder
5
+ - o # Option (for `with_options` blocks)
6
+ - t # Task
7
+ ForbiddenNames:
8
+ - i # Index
9
+ - x # ? (Too arbitrary)
10
+
11
+ Naming/MethodParameterName:
12
+ AllowedNames:
13
+ - as # Partials
14
+ - db # Database
15
+ - f # Form builders
16
+ - id # Identification
17
+ # Sorting:
18
+ - a
19
+ - b
20
+ # Mailers:
21
+ - cc
22
+ - to
@@ -1,11 +1,19 @@
1
- Naming/InclusiveLanguage:
2
- Enabled: true
1
+ Naming/BlockParameterName:
2
+ MinNameLength: 2
3
+ AllowedNames:
4
+ - o # Option (for `with_options` blocks)
5
+ - t # Task
6
+ ForbiddenNames:
7
+ - i # Index
8
+ - x # ? (Too arbitrary)
3
9
 
4
10
  Naming/MethodParameterName:
5
11
  AllowedNames:
12
+ - id # Identification
13
+ # Sorting:
6
14
  - a
7
15
  - b
8
- - id
9
16
 
10
17
  Naming/RescuedExceptionsVariableName:
18
+ # `ex` is short and simple while also being more grep'able than `e`.
11
19
  PreferredName: ex
@@ -1,17 +1,29 @@
1
1
  Performance/ArraySemiInfiniteRangeSlice:
2
- Enabled: false # Too many false positives with Strings.
2
+ # Too many false positives with Strings. (String#take doesn't exist.)
3
+ Enabled: false
3
4
 
4
5
  Performance/CaseWhenSplat:
6
+ # Can save performance / memory allocation when splatting conditions in `case`
7
+ # statements.
5
8
  Enabled: true
6
9
 
7
10
  Performance/ChainArrayAllocation:
11
+ # Prevent allocating new arrays when in-place modification is possible.
8
12
  Enabled: true
9
13
 
10
14
  Performance/IoReadlines:
15
+ # Prevent use of `readline` for IO when `each_line` is available (which is far
16
+ # more memory efficient).
11
17
  Enabled: true
12
18
 
13
19
  Performance/OpenStruct:
20
+ # Prefer Struct, when possible. Instantiation of an OpenStruct invalidates
21
+ # Ruby global method cache as it causes dynamic method definition during
22
+ # program runtime. This could have an effect on performance, especially in
23
+ # case of single-threaded applications with multiple OpenStruct
24
+ # instantiations.
14
25
  Enabled: true
15
26
 
16
27
  Performance/SelectMap:
28
+ # Prefer single-iteration to multiple interations, where possible.
17
29
  Enabled: true
@@ -1,57 +1,109 @@
1
- # While bulk changes can be useful, they shouldn't be required. Too much work
2
- # for little benefit.
3
1
  Rails/ActionOrder:
2
+ # Prefer Controller actions to be ordered in this way:
4
3
  ExpectedOrder: [index, show, new, create, edit, update, destroy]
5
4
 
6
- Rails/AttributeDefaultBlockValue:
7
- Enabled: true
5
+ Rails/ApplicationController:
6
+ # BaseControllers may rightfully need to inherit from ActionController::Base.
7
+ Exclude:
8
+ - app/controllers/**/base_controller.rb
9
+
10
+ Rails/ApplicationJob:
11
+ Exclude:
12
+ - test/**/* # Allow for defining ActiveJob::Base test doubles.
13
+
14
+ Rails/AssertNot:
15
+ # Prefer expectations over assertions.
16
+ Enabled: false
8
17
 
9
18
  Rails/BulkChangeTable:
19
+ # Prefer ease of programming to optimizing schema migrations performance.
10
20
  Enabled: false
11
21
 
12
22
  Rails/DefaultScope:
23
+ # Never use `default_scope`, it only leads to pain.
13
24
  Enabled: true
14
25
 
15
26
  Rails/Delegate:
16
- Enabled: false # We choose to never use `delegate`, instead.
27
+ # Prefer endless methods over `delegate` for:
28
+ # - Much better "grep-ability"
29
+ # - In-editor "symbol" lookup
30
+ # - More straight forward implementation
31
+ # - Better performance
32
+ Enabled: false
17
33
 
18
34
  Rails/EnvironmentVariableAccess:
35
+ # Accessing ENV variable within the application code can lead to runtime
36
+ # errors due to misconfiguration. Prefer discovering these at boot time,
37
+ # instead, by loading environment variables as part of app initialization
38
+ # (by copying them into the application's configuration or secrets).
19
39
  Enabled: true
20
40
 
21
- Rails/HasManyOrHasOneDependent:
22
- Enabled: false # A :dependent option isn't always needed (e.g. Transactions).
23
-
24
41
  Rails/OrderById:
42
+ # IDs are not guaranteed to be in any particular order, despite often
43
+ # (incidentally) being chronological. Prefer using a timestamp column to order
44
+ # chronologically.
25
45
  Enabled: true
26
46
 
27
- Rails/Output:
28
- Enabled: false
29
-
30
47
  Rails/PluckId:
48
+ # Prefer `MyRecord.ids` to `MyRecord.pluck(:id)`.
31
49
  Enabled: true
32
50
 
51
+ Rails/RefuteMethods:
52
+ # Irrelevant since we prefer expectations over assertions.
53
+ Enabled: false
54
+
33
55
  Rails/RequireDependency:
56
+ # The Zeitwerk code loader makes the need for `require_dependency` obsolete.
34
57
  Enabled: true
35
58
 
36
59
  Rails/ReversibleMigrationMethodDefinition:
60
+ # Ensure all schema migrations are reversible.
37
61
  Enabled: true
38
62
 
39
63
  Rails/SaveBang:
40
- Enabled: false
41
-
42
- Rails/SchemaComment:
43
- Enabled: false
64
+ # Defend against hidden, unhandled ActiveRecord update failures in the test suite.
65
+ Enabled: true
66
+ AllowedReceivers:
67
+ - where
68
+ Include:
69
+ - test/**/*
44
70
 
45
71
  Rails/SkipsModelValidations:
72
+ # Intended to prevent skipping validation on methods that may not seem like
73
+ # they would, such as `increment`, `update_all`, `update_columns`, etc.
74
+ # But, the context is what matters here, so this can't be decided up front.
46
75
  Enabled: false
47
76
 
48
77
  Rails/TableNameAssignment:
78
+ # MyRecord.table_name= should only be used for very good reasons. Override as
79
+ # needed.
49
80
  Enabled: true
50
81
 
51
82
  Rails/UniqBeforePluck:
83
+ # Prefer using `distinct` before `pluck` instead of `uniq` after `pluck`, as
84
+ # the former is executed by the database and is, therefore, more efficient.
52
85
  EnforcedStyle: aggressive
53
86
 
87
+ Rails/UnknownEnv:
88
+ # Consider changing this to an empty Array to prevent use of
89
+ # `Rails.env.<environment>?` entirely, in favor of `App::Env.<environment>?`.
90
+ Environments:
91
+ - development
92
+ - devprod
93
+ - production
94
+ - staging
95
+ - test
96
+
97
+ Rails/UnusedIgnoredColumns:
98
+ # Suggests you remove a column that does not exist in the schema from
99
+ # `ignored_columns`. Not sure we use this, but can't hurt to have this enabled
100
+ # if we do start using it.
101
+ Enabled: true
102
+
54
103
  Rails/WhereExists:
104
+ # Prefer using scopes to filer conditions (`where(...).exists?`) over
105
+ # `exists?(<condition>)`. The latter was all that was possible in older
106
+ # versions of Rails.
55
107
  EnforcedStyle: where
56
108
  Exclude:
57
109
  - test/**/*
@@ -1,4 +1,6 @@
1
1
  Style/Documentation:
2
+ # Require documentation for classes and non-namespace modules. This helps
3
+ # orient devs to the purpose of each model/service in the system.
2
4
  Exclude:
3
5
  - app/controllers/**/*
4
6
  - app/helpers/**/*
@@ -9,10 +11,14 @@ Style/Documentation:
9
11
  - test/**/*
10
12
 
11
13
  Style/FrozenStringLiteralComment:
14
+ # Require `frozen_string_literal` magic comment at top of Ruby files.
12
15
  Exclude:
13
16
  - config.ru
14
17
  - bin/*
15
18
 
19
+ Style/IpAddresses:
20
+ Enabled: true
21
+
16
22
  Style/MultilineBlockChain:
17
23
  Exclude:
18
24
  - db/seeds.rb
@@ -1,20 +1,31 @@
1
1
  Style/Alias:
2
- EnforcedStyle: prefer_alias_method
2
+ # https://rubystyle.guide/#alias-method-lexically
3
+ EnforcedStyle: prefer_alias
3
4
 
4
5
  Style/ArrayFirstLast:
5
- Enabled: false # Too many false positives.
6
-
7
- Style/AsciiComments:
6
+ # Too many false positives.
8
7
  Enabled: false
9
8
 
10
9
  Style/AutoResourceCleanup:
10
+ # Require blocks for auto-cleanup resources when available. e.g.
11
+ # `File.open("my_file") { |file| ... }` over `file = File.open("my_file")`.
11
12
  Enabled: true
12
13
 
13
14
  Style/BlockDelimiters:
15
+ # Prefer `do...end` vs `{...}` based on semantic meaning.
16
+ # - Use `{...}` for functional blocks (where we may care about the return
17
+ # value).
18
+ # - Use `do...end` for procedural blocks (where we don't care about the return
19
+ # value).
14
20
  EnforcedStyle: semantic
21
+ # But always prefer `{...}` for one-liners, even if it's a procedural block.
15
22
  AllowBracesOnProceduralOneLiners: true
23
+ # 👀 `tap` is an exception to the rule. Even though we don't care about the
24
+ # return value of the block, we do care about the return value of the method
25
+ # (for chaining).
16
26
  FunctionalMethods:
17
- # Minitest Spec DSL. (Rubocop defaults.)
27
+ # Rubocop defaults
28
+ # Minitest Spec DSL:
18
29
  - let
19
30
  - let!
20
31
  - subject
@@ -28,7 +39,10 @@ Style/BlockDelimiters:
28
39
  # - tap (Already listed above.)
29
40
  - tap_on_call
30
41
  - with
42
+ # Custom additions
43
+ - catch # Doesn't work... Rubocop allows either style for catch blocks.
31
44
  ProceduralMethods: # Defining this just to remove `tap` from the list.
45
+ # Rubocop defaults
32
46
  - benchmark
33
47
  - bm
34
48
  - bmbm
@@ -37,19 +51,15 @@ Style/BlockDelimiters:
37
51
  - measure
38
52
  - new
39
53
  - realtime
40
- # - tap (Remove from Rubocop defaults.)
54
+ # - tap # Remove from Rubocop defaults, so we can treat `tap` as functional.
41
55
  - with_object
42
56
 
43
57
  Style/ClassAndModuleChildren:
44
- AutoCorrect: true
58
+ # Combine constant definitions as much as possible. e.g. `class Foo::Bar`.
45
59
  EnforcedStyle: compact
46
- Exclude:
47
- - "test/**/*"
48
-
49
- Style/ClassMethodsDefinitions:
50
- Enabled: true
51
60
 
52
61
  Style/CollectionMethods:
62
+ # Enforce the use of consistent method names from the Enumerable module.
53
63
  Enabled: true
54
64
  PreferredMethods:
55
65
  collect: map
@@ -59,142 +69,163 @@ Style/CollectionMethods:
59
69
  inject: inject
60
70
 
61
71
  Style/ConstantVisibility:
62
- Enabled: false
72
+ # Protect the public API by requiring constants visibility.
73
+ Enabled: true
74
+
75
+ Style/ClassMethodsDefinitions:
76
+ # Prefer to define class methods like: `def self.<class_method_name>`.
77
+ Enabled: true
63
78
 
64
79
  Style/Copyright:
80
+ # Don't require a copyright notice in every source file.
65
81
  Enabled: false
66
82
 
67
83
  Style/DateTime:
84
+ # Prefer using `Time` over `DateTime`.
68
85
  Enabled: true
69
86
 
70
- Style/DisableCopsWithinSourceCodeDirective:
71
- Enabled: false
72
-
73
87
  Style/Documentation:
88
+ # Require documentation for classes and non-namespace modules. This helps
89
+ # orient devs to the purpose of each model/service in the system.
74
90
  Exclude:
75
- - "test/**/*"
76
-
77
- Style/DocumentationMethod:
78
- Enabled: false
91
+ - test/**/*
79
92
 
80
93
  Style/EmptyElse:
81
- Enabled: false # Including a comment in an empty else block shows intent.
82
-
83
- Style/EmptyMethod:
84
- EnforcedStyle: expanded
94
+ # Require an explanatory comment if we're otherwise wanting to utilize an
95
+ # empty `else` block.
96
+ AllowComments: true
85
97
 
86
98
  Style/ExpandPathArguments:
87
99
  Exclude:
88
100
  - "*.gemspec"
89
101
 
90
102
  Style/FormatString:
91
- Enabled: false # % notation with an Array just reads better sometimes.
103
+ # Prefer "%{my_value}" % { my_value: "..." }
104
+ # Over:
105
+ # - format("%{my_value}", my_value: "...")
106
+ # - sprintf("%{my_value}", my_value: "...")
107
+ EnforcedStyle: percent
108
+
109
+ Style/FormatStringToken:
110
+ # Prefer "%{my_template_value}" # <- Same style as is used in YAML
111
+ # Over:
112
+ # - "%<my_template_value>"
113
+ # - "%s"
114
+ EnforcedStyle: template
92
115
 
93
116
  Style/GuardClause:
117
+ # If > 1 conditional exists, don't require the 2nd+ to be a guard clause.
118
+ # Better to keep the symmetric logic flow.
94
119
  AllowConsecutiveConditionals: true
95
120
 
96
- Style/HashAsLastArrayItem:
97
- Exclude:
98
- - test/**/*
121
+ Style/HashSyntax:
122
+ # Use Ruby 3.1+'s Hash punning syntax whenever possible. e.g.
123
+ # # Good
124
+ # { foo:, bar:, baz: other }
125
+ # my_method(foo:, bar:, baz: other)
126
+ #
127
+ # # Bad
128
+ # { foo: foo, bar: bar, baz: other }
129
+ # my_method(foo: foo, bar: bar, baz: other)
130
+ EnforcedShorthandSyntax: always
99
131
 
100
132
  Style/ImplicitRuntimeError:
101
- Enabled: false
102
-
103
- Style/InlineComment:
104
- Enabled: false
105
-
106
- Style/InvertibleUnlessCondition:
133
+ # Raising `RuntimeError` is not illuminating. Prefer specifying either a
134
+ # StandardError or a custom-defined `Error` class.
107
135
  Enabled: true
108
136
 
109
- Style/IpAddresses:
137
+ Style/InvertibleUnlessCondition:
138
+ # Prefer positive logic over negative logic in conditionals.
110
139
  Enabled: true
111
140
 
112
141
  Style/Lambda:
142
+ # Always prefer `-> {}` for lambdas, whether for single or multi-line use.
143
+ # # Good
144
+ # ->(x) { x }
145
+ # ->(x) {
146
+ # x
147
+ # }
113
148
  EnforcedStyle: literal
114
149
 
115
150
  Style/LambdaCall:
116
- Enabled: false # Allow ServiceObject.(*). Only use on classes, not instances.
151
+ # Allow `MyObject.(...)` in place of `MyObjecet.call(...)`.
152
+ Enabled: false
117
153
 
118
154
  Style/MethodCallWithArgsParentheses:
155
+ # Omitting parentheses:
156
+ # - Can result in ambiguous code, and
157
+ # - Often results in incidental change as code is updated/augmented/refactored
158
+ # Avoid these issues entirely by just always using parentheses, except for in
159
+ # common, idiomatic places like macros (such as `belongs_to`).
119
160
  Enabled: true
120
161
  AllowedMethods:
121
162
  - add_dependency
122
163
  - add_development_dependency
123
- AllowParenthesesInChaining: true
124
- AllowParenthesesInCamelCaseMethod: true
125
- AllowParenthesesInStringInterpolation: true
164
+ # AllowParenthesesInChaining: true
165
+ # AllowParenthesesInCamelCaseMethod: true
166
+ # AllowParenthesesInStringInterpolation: true
126
167
 
127
168
  Style/MethodCalledOnDoEndBlock:
169
+ # It's easy to miss method calls tacked on to the end of a block. Plus, if
170
+ # this is needed then the block is probably a functional block, in which case
171
+ # we prefer curly brackets anyway.
128
172
  Enabled: true
129
173
 
130
- Style/MissingElse:
131
- Enabled: false
132
-
133
- Style/MultilineMethodSignature:
134
- Enabled: false
135
-
136
- Style/NumericPredicate:
137
- AutoCorrect: true
138
-
139
- Style/OpenStructUse:
140
- Exclude:
141
- - "test/**/*"
142
-
143
174
  Style/OptionHash:
175
+ # Prefer keyword arguments over options hashes whenever possible.
144
176
  Enabled: true
145
177
 
146
178
  Style/RegexpLiteral:
147
179
  EnforcedStyle: mixed
148
180
 
149
- Style/RequireOrder:
150
- Enabled: false
151
-
152
181
  Style/RescueStandardError:
182
+ # Prefer `rescue => ex` over `rescue StandardError => ex`.
153
183
  EnforcedStyle: implicit
154
184
 
155
185
  Style/ReturnNil:
186
+ # Enforce consistency in choosing `return if ...` vs `return nil if ...`.
187
+ # Prefer the former (implicit) style.
156
188
  Enabled: true
157
189
 
158
190
  Style/Send:
191
+ # Require either `public_send` (for calling public methods) or `__send__` (for
192
+ # calling private methods) over just `send`.
159
193
  Enabled: true
160
194
 
161
- Style/SingleLineBlockParams:
162
- Enabled: false
163
-
164
195
  Style/StaticClass:
196
+ # Prefer `module` over `class` whenever object instantiation isn't needed.
165
197
  Enabled: true
166
198
 
167
- Style/StringHashKeys:
168
- Enabled: false
169
-
170
- Style/StringMethods:
171
- Enabled: true
172
-
173
- Style/SingleLineMethods:
174
- Exclude:
175
- - "test/**/*"
176
-
177
199
  Style/StringLiterals:
200
+ # Double quotes minimize incidental change when interpolation becomes needed.
178
201
  EnforcedStyle: double_quotes
179
202
 
180
203
  Style/StringLiteralsInInterpolation:
204
+ # Double quotes minimize incidental change when interpolation becomes needed.
181
205
  EnforcedStyle: double_quotes
182
206
 
207
+ Style/StringMethods:
208
+ # Prefer String#to_sym over String#intern. (Can add other such preferences
209
+ # too, if desired.)
210
+ Enabled: true
211
+
183
212
  Style/SymbolProc:
213
+ # Don't force symbol proc when the method has other arguments.
214
+ # # Good
215
+ # my_object.my_method(&:upcase)
216
+ # my_object.my_method(param1, &:upcase)
217
+ # my_object.my_method(param1) { |my_value| my_value.upcase } # <- 👀
184
218
  AllowMethodsWithArguments: true
185
219
 
186
- Style/TopLevelMethodDefinition:
187
- Enabled: false
188
-
189
220
  Style/TrailingCommaInArguments:
190
- # Requires a comma after the last argument, but only for parenthesized method
221
+ # Require a comma after the last argument, but only for parenthesized method
191
222
  # calls where each argument is on its own line. e.g.
192
223
  # def my_method(
193
224
  # my_arg1,
194
- # my_arg2, # <- 👀 Comma required.
225
+ # my_arg2, # <- 👀 Comma required
195
226
  # )
196
227
  # def my_method(
197
- # my_arg1, my_arg2 # <- 👀 No comma required.
228
+ # my_arg1, my_arg2 # <- 👀 No comma required
198
229
  # )
199
230
  #
200
231
  # NOTE: Prefer `comma` over `consistent` b/c `consistent`:
@@ -214,15 +245,17 @@ Style/TrailingCommaInArguments:
214
245
  EnforcedStyleForMultiline: comma
215
246
 
216
247
  Style/TrailingCommaInArrayLiteral:
248
+ # Require a comma after the last item in an array, but only when each item is
249
+ # on its own line.
217
250
  EnforcedStyleForMultiline: comma
218
251
 
219
- Style/TrailingCommaInBlockArgs:
220
- Enabled: false
221
-
222
252
  Style/TrailingCommaInHashLiteral:
253
+ # Require a comma after the last item in a hash, but only when each item is on
254
+ # its own line.
223
255
  EnforcedStyleForMultiline: comma
224
256
 
225
257
  Style/UnlessLogicalOperators:
258
+ # Prevent tricky logic in `unless` conditions.
226
259
  Enabled: true
227
260
 
228
261
  Style/YodaExpression:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.19
4
+ version: 0.7.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul DobbinSchmaltz
@@ -226,6 +226,7 @@ files:
226
226
  - lib/rubocop/metrics-rails.yml
227
227
  - lib/rubocop/metrics.yml
228
228
  - lib/rubocop/minitest.yml
229
+ - lib/rubocop/naming-rails.yml
229
230
  - lib/rubocop/naming.yml
230
231
  - lib/rubocop/performance.yml
231
232
  - lib/rubocop/rails.yml
@@ -263,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
264
  - !ruby/object:Gem::Version
264
265
  version: '0'
265
266
  requirements: []
266
- rubygems_version: 3.6.9
267
+ rubygems_version: 3.7.2
267
268
  specification_version: 4
268
269
  summary: Common gem framework code used by pdobb's Ruby Gems.
269
270
  test_files: []