betterlint 1.17.0 → 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +4 -0
- data/lib/rubocop/cop/betterment/active_job_performable.rb +1 -1
- data/lib/rubocop/cop/betterment/allowlist_blocklist.rb +2 -2
- data/lib/rubocop/cop/betterment/authorization_in_controller.rb +5 -5
- data/lib/rubocop/cop/betterment/direct_delayed_enqueue.rb +1 -0
- data/lib/rubocop/cop/betterment/dynamic_params.rb +2 -1
- data/lib/rubocop/cop/betterment/fetch_boolean.rb +1 -0
- data/lib/rubocop/cop/betterment/hardcoded_id.rb +1 -0
- data/lib/rubocop/cop/betterment/implicit_redirect_type.rb +2 -1
- data/lib/rubocop/cop/betterment/internals_protection.rb +1 -0
- data/lib/rubocop/cop/betterment/memoization_with_arguments.rb +2 -2
- data/lib/rubocop/cop/betterment/non_standard_actions.rb +2 -3
- data/lib/rubocop/cop/betterment/non_standard_controller.rb +1 -0
- data/lib/rubocop/cop/betterment/server_error_assertion.rb +2 -1
- data/lib/rubocop/cop/betterment/site_prism_loaded.rb +10 -11
- data/lib/rubocop/cop/betterment/spec_helper_required_outside_spec_dir.rb +2 -1
- data/lib/rubocop/cop/betterment/timeout.rb +2 -1
- data/lib/rubocop/cop/betterment/unsafe_job.rb +4 -5
- data/lib/rubocop/cop/betterment/unscoped_find.rb +4 -4
- data/lib/rubocop/cop/betterment/use_global_strict_loading.rb +2 -0
- data/lib/rubocop/cop/betterment/vague_serialize.rb +1 -0
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07e39ffdbd6630e753fcec9c3fd5cb25d0b1d5f071299b8f1f66f252cb76c901
|
4
|
+
data.tar.gz: da17e36192a8c847dd1597b48d7f2390ea3c6363563dba286a897f641d1775e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfe7759c87fe74850dade98e961d7d36f4656500a91c9327612d778cae5953bb07d5daa56d448b1ed2e0c9140df799340c901cb086925b00275cd7b0d8a90e2f
|
7
|
+
data.tar.gz: 101ce64b3692608b1a7e92000e03c94f4c4f2b14548e4ae6aaa9139dfb925cd2ca304cc1d5df53a512fb74a740adbb92186dc25f3acb937df81535379d68ef2a
|
data/config/default.yml
CHANGED
@@ -31,6 +31,8 @@ Betterment/AuthorizationInController:
|
|
31
31
|
Description: Detects unsafe handling of id-like parameters in controllers.
|
32
32
|
Enabled: false
|
33
33
|
StyleGuide: '#bettermentauthorizationincontroller'
|
34
|
+
unsafe_regex: ".*_id$"
|
35
|
+
unsafe_parameters: []
|
34
36
|
|
35
37
|
Betterment/DirectDelayedEnqueue:
|
36
38
|
StyleGuide: '#bettermentdirectdelayedenqueue'
|
@@ -94,6 +96,7 @@ Betterment/SitePrismLoaded:
|
|
94
96
|
Betterment/UnsafeJob:
|
95
97
|
Enabled: false
|
96
98
|
StyleGuide: '#bettermentunsafejob'
|
99
|
+
class_regex: ".*Job$"
|
97
100
|
sensitive_params:
|
98
101
|
- password
|
99
102
|
- social_security_number
|
@@ -101,6 +104,7 @@ Betterment/UnsafeJob:
|
|
101
104
|
|
102
105
|
Betterment/UnscopedFind:
|
103
106
|
StyleGuide: '#bettermentunscopedfind'
|
107
|
+
unauthenticated_models: []
|
104
108
|
|
105
109
|
Betterment/UseGlobalStrictLoading/ByDefaultForModels:
|
106
110
|
Enabled: true
|
@@ -4,8 +4,8 @@
|
|
4
4
|
module RuboCop
|
5
5
|
module Cop
|
6
6
|
module Betterment
|
7
|
-
class AllowlistBlocklist <
|
8
|
-
MSG =
|
7
|
+
class AllowlistBlocklist < Base
|
8
|
+
MSG = <<~DOC
|
9
9
|
Avoid usages of whitelist & blacklist, in favor of more inclusive and descriptive language.
|
10
10
|
For consistency, favor 'allowlist' and 'blocklist' where possible, but other terms (such as
|
11
11
|
denylist, ignorelist, warnlist, safelist, etc) may be appropriate, depending on the use case.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class AuthorizationInController <
|
6
|
+
class AuthorizationInController < Base
|
7
7
|
attr_accessor :unsafe_parameters, :unsafe_regex
|
8
8
|
|
9
9
|
# MSG_UNSAFE_CREATE = 'Model created/updated using unsafe parameters'.freeze
|
@@ -34,10 +34,9 @@ module RuboCop
|
|
34
34
|
PATTERN
|
35
35
|
|
36
36
|
def initialize(config = nil, options = nil)
|
37
|
-
super
|
38
|
-
|
39
|
-
@
|
40
|
-
@unsafe_regex = Regexp.new config.fetch("unsafe_regex", ".*_id$")
|
37
|
+
super
|
38
|
+
@unsafe_parameters = cop_config.fetch("unsafe_parameters").map(&:to_sym)
|
39
|
+
@unsafe_regex = Regexp.new cop_config.fetch("unsafe_regex")
|
41
40
|
@param_wrappers = []
|
42
41
|
end
|
43
42
|
|
@@ -67,6 +66,7 @@ module RuboCop
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
end
|
69
|
+
alias on_csend on_send
|
70
70
|
|
71
71
|
private
|
72
72
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class DynamicParams <
|
6
|
+
class DynamicParams < Base
|
7
7
|
MSG_DYNAMIC_PARAMS = <<~MSG
|
8
8
|
Parameter names accessed dynamically, cannot determine safeness. Please inline the keys explicitly when calling `permit` or when accessing `params` like a hash.
|
9
9
|
|
@@ -22,6 +22,7 @@ module RuboCop
|
|
22
22
|
dynamic_param = find_dynamic_param(arg_nodes)
|
23
23
|
add_offense(dynamic_param, message: MSG_DYNAMIC_PARAMS) if dynamic_param
|
24
24
|
end
|
25
|
+
alias on_csend on_send
|
25
26
|
|
26
27
|
private
|
27
28
|
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
# # good
|
15
15
|
# get '/', redirect('/dashboard', status: 301)
|
16
16
|
# get(status: 302) { |params, request| '/dashboard' }
|
17
|
-
class ImplicitRedirectType <
|
17
|
+
class ImplicitRedirectType < Base
|
18
18
|
ROUTES_FILE_NAME = 'routes.rb'
|
19
19
|
MSG =
|
20
20
|
'Rails will create a permanent (301) redirect, which is dangerous. ' \
|
@@ -60,6 +60,7 @@ module RuboCop
|
|
60
60
|
add_offense(node)
|
61
61
|
end
|
62
62
|
end
|
63
|
+
alias on_csend on_send
|
63
64
|
|
64
65
|
private
|
65
66
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class MemoizationWithArguments <
|
6
|
+
class MemoizationWithArguments < Base
|
7
7
|
MSG = 'Memoized method `%<method>s` accepts arguments, ' \
|
8
8
|
'which may cause it to return a stale result. ' \
|
9
9
|
'Remove memoization or refactor to remove arguments.'
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
return if ivar_assign.nil? || node.arguments.empty? || method_name == :initialize
|
27
27
|
|
28
28
|
msg = format(MSG, method: method_name)
|
29
|
-
add_offense(
|
29
|
+
add_offense(ivar_assign, message: msg)
|
30
30
|
end
|
31
31
|
alias on_defs on_def
|
32
32
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class NonStandardActions <
|
6
|
+
class NonStandardActions < Base
|
7
7
|
MSG_GENERAL = 'Use a new controller instead of custom actions.'
|
8
8
|
MSG_RESOURCE_ONLY = "Resource route refers to a non-standard action in it's 'only:' param. #{MSG_GENERAL}".freeze
|
9
9
|
MSG_ROUTE_TO = "Route goes to a non-standard controller action. #{MSG_GENERAL}".freeze
|
@@ -62,9 +62,8 @@ module RuboCop
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
# NOTE: The InternalAffairs/UndefinedConfig rule seems to have a bug where it can't fine these configs in config/default.yml
|
66
65
|
def allowed_actions
|
67
|
-
@allowed_actions ||= cop_config['StandardActions'] + cop_config['AdditionalAllowedActions']
|
66
|
+
@allowed_actions ||= cop_config['StandardActions'] + cop_config['AdditionalAllowedActions']
|
68
67
|
end
|
69
68
|
|
70
69
|
def allowed_action?(action)
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
#
|
30
30
|
# # good
|
31
31
|
# expect(response).to have_http_status 422
|
32
|
-
class ServerErrorAssertion <
|
32
|
+
class ServerErrorAssertion < Base
|
33
33
|
MSG = 'Do not assert on 5XX statuses. Use a semantic status (e.g., 403, 422, etc.) or treat them as bugs (omit tests).'
|
34
34
|
BAD_STATUSES = %i(
|
35
35
|
internal_server_error
|
@@ -57,6 +57,7 @@ module RuboCop
|
|
57
57
|
|
58
58
|
add_offense(node)
|
59
59
|
end
|
60
|
+
alias on_csend on_send
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
@@ -3,24 +3,23 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class SitePrismLoaded <
|
6
|
+
class SitePrismLoaded < Base
|
7
|
+
extend AutoCorrector
|
8
|
+
|
7
9
|
MSG = 'Use `be_loaded` instead of `be_displayed`'
|
8
10
|
|
9
|
-
def_node_matcher :
|
10
|
-
(send (send nil? :expect _) _ (send nil? :be_displayed))
|
11
|
+
def_node_matcher :on_be_displayed, <<-PATTERN
|
12
|
+
(send (send nil? :expect _) _ $(send nil? :be_displayed))
|
11
13
|
PATTERN
|
12
14
|
|
13
15
|
def on_send(node)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def autocorrect(node)
|
20
|
-
lambda do |corrector|
|
21
|
-
corrector.replace(node.children[2], 'be_loaded')
|
16
|
+
on_be_displayed(node) do |be_displayed|
|
17
|
+
add_offense(be_displayed) do |corrector|
|
18
|
+
corrector.replace(be_displayed, 'be_loaded')
|
19
|
+
end
|
22
20
|
end
|
23
21
|
end
|
22
|
+
alias on_csend on_send
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
# # good
|
15
15
|
# spec/models/my_class_spec.rb
|
16
16
|
# require 'rails_helper'
|
17
|
-
class SpecHelperRequiredOutsideSpecDir <
|
17
|
+
class SpecHelperRequiredOutsideSpecDir < Base
|
18
18
|
MSG = 'Spec helper required outside of a spec/ directory.'
|
19
19
|
|
20
20
|
def_node_matcher :requires_spec_helper?, <<-PATTERN
|
@@ -25,6 +25,7 @@ module RuboCop
|
|
25
25
|
def on_send(node)
|
26
26
|
add_offense(node) if requires_spec_helper?(node) && !spec_directory?
|
27
27
|
end
|
28
|
+
alias on_csend on_send
|
28
29
|
|
29
30
|
private
|
30
31
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class Timeout <
|
6
|
+
class Timeout < Base
|
7
7
|
MSG = 'Using Timeout.timeout without a custom exception can prevent rescue blocks from executing'
|
8
8
|
|
9
9
|
def_node_matcher :timeout_call?, <<-PATTERN
|
@@ -15,6 +15,7 @@ module RuboCop
|
|
15
15
|
|
16
16
|
add_offense(node)
|
17
17
|
end
|
18
|
+
alias on_csend on_send
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class UnsafeJob <
|
6
|
+
class UnsafeJob < Base
|
7
7
|
attr_accessor :sensitive_params, :class_regex
|
8
8
|
|
9
9
|
MSG = <<~MSG
|
@@ -14,10 +14,9 @@ module RuboCop
|
|
14
14
|
MSG
|
15
15
|
|
16
16
|
def initialize(config = nil, options = nil)
|
17
|
-
super
|
18
|
-
|
19
|
-
@
|
20
|
-
@class_regex = Regexp.new config.fetch("class_regex", ".*Job$")
|
17
|
+
super
|
18
|
+
@sensitive_params = cop_config.fetch("sensitive_params").map(&:to_sym)
|
19
|
+
@class_regex = Regexp.new cop_config.fetch("class_regex")
|
21
20
|
end
|
22
21
|
|
23
22
|
def on_def(node)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Betterment
|
6
|
-
class UnscopedFind <
|
6
|
+
class UnscopedFind < Base
|
7
7
|
attr_accessor :unauthenticated_models
|
8
8
|
|
9
9
|
MSG = <<~MSG
|
@@ -36,9 +36,8 @@ module RuboCop
|
|
36
36
|
PATTERN
|
37
37
|
|
38
38
|
def initialize(config = nil, options = nil)
|
39
|
-
super
|
40
|
-
|
41
|
-
@unauthenticated_models = config.fetch("unauthenticated_models", []).map(&:to_sym)
|
39
|
+
super
|
40
|
+
@unauthenticated_models = cop_config.fetch("unauthenticated_models").map(&:to_sym)
|
42
41
|
end
|
43
42
|
|
44
43
|
def on_class(node)
|
@@ -56,6 +55,7 @@ module RuboCop
|
|
56
55
|
|
57
56
|
add_offense(node) if find_param_arg(arg_nodes) || graphql_file? || graphql_namespace?(node)
|
58
57
|
end
|
58
|
+
alias on_csend on_send
|
59
59
|
|
60
60
|
private
|
61
61
|
|
@@ -23,6 +23,7 @@ module RuboCop
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
+
alias on_csend on_send
|
26
27
|
end
|
27
28
|
|
28
29
|
# This cop ensures that `strict_loading: <any value>` is not set in ActiveRecord associations.
|
@@ -46,6 +47,7 @@ module RuboCop
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
50
|
+
alias on_csend on_send
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
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.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Development
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,84 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: '1.71'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: '1.71'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-graphql
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.5
|
33
|
+
version: '1.5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.5
|
40
|
+
version: '1.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-performance
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: '1.23'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: '1.23'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: '2.29'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: '2.29'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.6
|
75
|
+
version: '0.6'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.6
|
82
|
+
version: '0.6'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop-rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.
|
89
|
+
version: '2.29'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.
|
96
|
+
version: '2.29'
|
97
97
|
description: Betterment rubocop configuration
|
98
98
|
email:
|
99
99
|
- development@betterment.com
|
@@ -136,10 +136,10 @@ licenses:
|
|
136
136
|
- MIT
|
137
137
|
metadata:
|
138
138
|
homepage_uri: https://github.com/Betterment/betterlint
|
139
|
-
source_code_uri: https://github.com/Betterment/betterlint/tree/v1.
|
140
|
-
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.
|
139
|
+
source_code_uri: https://github.com/Betterment/betterlint/tree/v1.18.0
|
140
|
+
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.18.0/CHANGELOG.md
|
141
141
|
bug_tracker_uri: https://github.com/Betterment/betterlint/issues
|
142
|
-
documentation_uri: https://www.rubydoc.info/gems/betterlint/1.
|
142
|
+
documentation_uri: https://www.rubydoc.info/gems/betterlint/1.18.0
|
143
143
|
rubygems_mfa_required: 'true'
|
144
144
|
post_install_message:
|
145
145
|
rdoc_options: []
|