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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a22aae83c05b82fd78756d3d69d45c25d71b5a63715831c947239a73a6ce5f1f
4
- data.tar.gz: 1b80addb1d93b9823303e94c0e87b7360bd5d3456af6ab250c4f13a2e3bac625
3
+ metadata.gz: 07e39ffdbd6630e753fcec9c3fd5cb25d0b1d5f071299b8f1f66f252cb76c901
4
+ data.tar.gz: da17e36192a8c847dd1597b48d7f2390ea3c6363563dba286a897f641d1775e7
5
5
  SHA512:
6
- metadata.gz: 95a2bd3580e962c52fab4a4cdb9778137ca3c96506f1dde5e9d8ae69f188364b81930980b68538200aeb9e1bc433a590725370216d239a754f9c8f19e7e055bc
7
- data.tar.gz: e685d82cf02b3065077014c89d44b1bb91aa593a087c4479d29a55aa938f3f7ccf31fa3da5486ccba8a1dbd64ff62bd23246f6e8715232fee785545db518607e
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
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Betterment
6
- class ActiveJobPerformable < Cop
6
+ class ActiveJobPerformable < Base
7
7
  MSG = <<~DOC
8
8
  Classes that are "performable" should be ActiveJobs
9
9
 
@@ -4,8 +4,8 @@
4
4
  module RuboCop
5
5
  module Cop
6
6
  module Betterment
7
- class AllowlistBlocklist < Cop
8
- MSG = <<-DOC
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 < Cop
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(config, options)
38
- config = @config.for_cop(self)
39
- @unsafe_parameters = config.fetch("unsafe_parameters", []).map(&:to_sym)
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
 
@@ -16,6 +16,7 @@ module RuboCop
16
16
  add_offense(node, message: DELAY_MESSAGE) if node.method?(:delay)
17
17
  add_offense(node, message: ENQUEUE_MESSAGE) if enqueue?(node)
18
18
  end
19
+ alias on_csend on_send
19
20
  end
20
21
  end
21
22
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Betterment
6
- class DynamicParams < Cop
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
 
@@ -46,6 +46,7 @@ module RuboCop
46
46
 
47
47
  add_offense(node)
48
48
  end
49
+ alias on_csend on_send
49
50
 
50
51
  private
51
52
 
@@ -44,6 +44,7 @@ module RuboCop
44
44
  end
45
45
  end
46
46
  end
47
+ alias on_csend on_send
47
48
 
48
49
  def on_block(node)
49
50
  on_let_id(node) do |name, value|
@@ -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 < Cop
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
 
@@ -40,6 +40,7 @@ module RuboCop
40
40
  ensure_allowed_reference!(class_name_node, module_path)
41
41
  end
42
42
  end
43
+ alias on_csend on_send
43
44
 
44
45
  private
45
46
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Betterment
6
- class MemoizationWithArguments < Cop
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(node, location: ivar_assign.source_range, message: msg)
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 < Cop
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'] # rubocop:disable InternalAffairs/UndefinedConfig
66
+ @allowed_actions ||= cop_config['StandardActions'] + cop_config['AdditionalAllowedActions']
68
67
  end
69
68
 
70
69
  def allowed_action?(action)
@@ -18,6 +18,7 @@ module RuboCop
18
18
  def on_send(node)
19
19
  resources_with_controller(node) { |option| add_offense(option) }
20
20
  end
21
+ alias on_csend on_send
21
22
  end
22
23
  end
23
24
  end
@@ -29,7 +29,7 @@ module RuboCop
29
29
  #
30
30
  # # good
31
31
  # expect(response).to have_http_status 422
32
- class ServerErrorAssertion < Cop
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 < Cop
6
+ class SitePrismLoaded < Base
7
+ extend AutoCorrector
8
+
7
9
  MSG = 'Use `be_loaded` instead of `be_displayed`'
8
10
 
9
- def_node_matcher :be_displayed_call?, <<-PATTERN
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
- return unless be_displayed_call?(node)
15
-
16
- add_offense(node, location: node.children[2].source_range)
17
- end
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 < Cop
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 < Cop
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 < Cop
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(config, options)
18
- config = @config.for_cop(self)
19
- @sensitive_params = config.fetch("sensitive_params", []).map(&:to_sym)
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 < Cop
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(config, options)
40
- config = @config.for_cop(self)
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
@@ -17,6 +17,7 @@ module RuboCop
17
17
 
18
18
  add_offense(node) if node.arguments.length < 2 || !node.arguments[1].const_type?
19
19
  end
20
+ alias on_csend on_send
20
21
  end
21
22
  end
22
23
  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.17.0
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-25 00:00:00.000000000 Z
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.62.0
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.62.0
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.0
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.0
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.21.0
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.21.0
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.24.0
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.24.0
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.0
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.0
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.28.0
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.28.0
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.17.0
140
- changelog_uri: https://github.com/Betterment/betterlint/blob/v1.17.0/CHANGELOG.md
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.17.0
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: []