betterlint 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/config/default.yml +35 -4
- data/lib/rubocop/cop/betterment/direct_delayed_enqueue.rb +22 -0
- data/lib/rubocop/cop/betterment/non_standard_actions.rb +4 -4
- data/lib/rubocop/cop/betterment/render_status.rb +4 -4
- data/lib/rubocop/cop/betterment/utils/parser.rb +18 -18
- data/lib/rubocop/cop/betterment.rb +1 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba1c8a88e6cefd6fc8db168dfe4b9f41f30989c4716fdc0338e99614a40315d
|
4
|
+
data.tar.gz: 9b176cbf47cf1f1d65547624b44531dcb0328832a1dfc62c12b3f33c0222f1e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b1ed1bdec96493c6c9332228a2cff4a1134926c27d72ea0c13439f454af5668258a1722ef53520ffa2786472c59b1c09e12ee5abdce8e7fdc1d1d91ecb09df
|
7
|
+
data.tar.gz: 7d159d6ee74e8a6f5b30f3e922e9d13ae1d5a26c779c12df0750daad6e82b68d2caecda1a8e473c7b983af45d96aca3635239906d03592e3e790fbf09952dec5
|
data/README.md
CHANGED
@@ -101,6 +101,15 @@ Betterment/UnscopedFind:
|
|
101
101
|
- ZipCode
|
102
102
|
```
|
103
103
|
|
104
|
+
### Betterment/DirectDelayedEnqueue
|
105
|
+
|
106
|
+
This cop flags code that uses `Object#delay` or `Delayed::Job.enqueue`. Please use `ActiveJob` instead.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
user.delay.save!
|
110
|
+
Delayed::Job.enqueue(MyJob.new)
|
111
|
+
```
|
112
|
+
|
104
113
|
### Betterment/DynamicParams
|
105
114
|
|
106
115
|
This cop flags code that accesses parameters whose names may be dynamically generated, such as a list of parameters in an a global variable or a return value from a method. In some cases, dynamically accessing parameter names can obscure what the client is expected to send and may make it difficult to reason about the code, both manually and programmatically. For example:
|
data/config/default.yml
CHANGED
@@ -32,6 +32,9 @@ Betterment/AuthorizationInController:
|
|
32
32
|
Enabled: false
|
33
33
|
StyleGuide: '#bettermentauthorizationincontroller'
|
34
34
|
|
35
|
+
Betterment/DirectDelayedEnqueue:
|
36
|
+
StyleGuide: '#bettermentdirectdelayedenqueue'
|
37
|
+
|
35
38
|
Betterment/DynamicParams:
|
36
39
|
StyleGuide: '#bettermentdynamicparams'
|
37
40
|
|
@@ -98,15 +101,43 @@ FactoryBot/ConsistentParenthesesStyle:
|
|
98
101
|
FactoryBot/SyntaxMethods:
|
99
102
|
Enabled: false
|
100
103
|
|
104
|
+
Layout/ArgumentAlignment:
|
105
|
+
EnforcedStyle: with_fixed_indentation
|
106
|
+
|
107
|
+
Layout/ArrayAlignment:
|
108
|
+
EnforcedStyle: with_fixed_indentation
|
109
|
+
|
101
110
|
Layout/CaseIndentation:
|
102
|
-
|
111
|
+
EnforcedStyle: end
|
112
|
+
IndentOneStep: false
|
103
113
|
|
104
114
|
Layout/ClosingParenthesisIndentation:
|
105
115
|
Enabled: true
|
106
116
|
|
117
|
+
Layout/EndAlignment:
|
118
|
+
EnforcedStyleAlignWith: variable
|
119
|
+
|
120
|
+
Layout/FirstArgumentIndentation:
|
121
|
+
EnforcedStyle: consistent
|
122
|
+
|
107
123
|
Layout/FirstArrayElementIndentation:
|
108
124
|
EnforcedStyle: consistent
|
109
125
|
|
126
|
+
Layout/FirstHashElementIndentation:
|
127
|
+
EnforcedStyle: consistent
|
128
|
+
|
129
|
+
Layout/FirstParameterIndentation:
|
130
|
+
Enabled: false
|
131
|
+
|
132
|
+
Layout/LineContinuationLeadingSpace:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
Layout/LineContinuationSpacing:
|
136
|
+
Enabled: true
|
137
|
+
|
138
|
+
Layout/LineEndStringConcatenationIndentation:
|
139
|
+
Enabled: false
|
140
|
+
|
110
141
|
Layout/LineLength:
|
111
142
|
Max: 140
|
112
143
|
|
@@ -117,11 +148,11 @@ Layout/MultilineOperationIndentation:
|
|
117
148
|
EnforcedStyle: indented
|
118
149
|
|
119
150
|
Layout/ParameterAlignment:
|
120
|
-
Enabled:
|
151
|
+
Enabled: true
|
152
|
+
EnforcedStyle: with_fixed_indentation
|
121
153
|
|
122
|
-
# Disabling because of a bug in rubocop: https://github.com/rubocop-hq/rubocop/issues/6918
|
123
154
|
Layout/RescueEnsureAlignment:
|
124
|
-
Enabled:
|
155
|
+
Enabled: true
|
125
156
|
|
126
157
|
Lint/AmbiguousBlockAssociation:
|
127
158
|
Exclude:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Betterment
|
6
|
+
class DirectDelayedEnqueue < Base
|
7
|
+
DELAY_MESSAGE = 'Please use Active Job instead of using `Object#delay`'
|
8
|
+
ENQUEUE_MESSAGE = 'Please use Active Job instead of using `Delayed::Job.enqueue`'
|
9
|
+
|
10
|
+
# @!method enqueue?(node)
|
11
|
+
def_node_matcher :enqueue?, <<-PATTERN
|
12
|
+
(send (const (const nil? :Delayed) :Job) :enqueue ...)
|
13
|
+
PATTERN
|
14
|
+
|
15
|
+
def on_send(node)
|
16
|
+
add_offense(node, message: DELAY_MESSAGE) if node.method?(:delay)
|
17
|
+
add_offense(node, message: ENQUEUE_MESSAGE) if enqueue?(node)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -53,10 +53,10 @@ module RuboCop
|
|
53
53
|
if route
|
54
54
|
(path, param, value) = route
|
55
55
|
action = case param
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
when :to then value.first.split('#').last
|
57
|
+
when :action then value.first
|
58
|
+
else path
|
59
|
+
end
|
60
60
|
add_offense(node, message: MSG_ROUTE_TO) unless allowed_action?(action)
|
61
61
|
true
|
62
62
|
end
|
@@ -39,25 +39,25 @@ module RuboCop
|
|
39
39
|
return [node] if node.literal? || node.variable?
|
40
40
|
|
41
41
|
case node.type
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
42
|
+
when :begin
|
43
|
+
get_return_values(node.children.last)
|
44
|
+
when :block
|
45
|
+
get_return_values(node.body)
|
46
|
+
when :if
|
47
|
+
if_rets = get_return_values(node.if_branch)
|
48
|
+
else_rets = get_return_values(node.else_branch)
|
49
|
+
if_rets + else_rets
|
50
|
+
when :case
|
51
|
+
cases = []
|
52
|
+
node.each_when do |block|
|
53
|
+
cases += get_return_values(block.body)
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
cases + get_return_values(node.else_branch)
|
57
|
+
when :send
|
58
|
+
[node]
|
59
|
+
else
|
60
|
+
[]
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -5,6 +5,7 @@ require 'rubocop/cop/betterment/utils/parser'
|
|
5
5
|
require 'rubocop/cop/betterment/utils/method_return_table'
|
6
6
|
require 'rubocop/cop/betterment/utils/hardcoded_attribute'
|
7
7
|
require 'rubocop/cop/betterment/authorization_in_controller'
|
8
|
+
require 'rubocop/cop/betterment/direct_delayed_enqueue'
|
8
9
|
require 'rubocop/cop/betterment/dynamic_params'
|
9
10
|
require 'rubocop/cop/betterment/unscoped_find'
|
10
11
|
require 'rubocop/cop/betterment/unsafe_job'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Development
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/rubocop/cop/betterment/active_job_performable.rb
|
109
109
|
- lib/rubocop/cop/betterment/allowlist_blocklist.rb
|
110
110
|
- lib/rubocop/cop/betterment/authorization_in_controller.rb
|
111
|
+
- lib/rubocop/cop/betterment/direct_delayed_enqueue.rb
|
111
112
|
- lib/rubocop/cop/betterment/dynamic_params.rb
|
112
113
|
- lib/rubocop/cop/betterment/fetch_boolean.rb
|
113
114
|
- lib/rubocop/cop/betterment/hardcoded_id.rb
|
@@ -132,10 +133,10 @@ licenses:
|
|
132
133
|
- MIT
|
133
134
|
metadata:
|
134
135
|
homepage_uri: https://github.com/Betterment/betterlint
|
135
|
-
source_code_uri: https://github.com/Betterment/betterlint/tree/v1.
|
136
|
-
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.
|
136
|
+
source_code_uri: https://github.com/Betterment/betterlint/tree/v1.14.0
|
137
|
+
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.14.0/CHANGELOG.md
|
137
138
|
bug_tracker_uri: https://github.com/Betterment/betterlint/issues
|
138
|
-
documentation_uri: https://www.rubydoc.info/gems/betterlint/1.
|
139
|
+
documentation_uri: https://www.rubydoc.info/gems/betterlint/1.14.0
|
139
140
|
rubygems_mfa_required: 'true'
|
140
141
|
post_install_message:
|
141
142
|
rdoc_options: []
|
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
153
|
- !ruby/object:Gem::Version
|
153
154
|
version: '0'
|
154
155
|
requirements: []
|
155
|
-
rubygems_version: 3.5.
|
156
|
+
rubygems_version: 3.5.18
|
156
157
|
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Betterment rubocop configuration
|