betterlint 1.5.0 → 1.7.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 +2 -2
- data/lib/rubocop/cop/betterment/active_job_performable.rb +3 -1
- data/lib/rubocop/cop/betterment/allowlist_blocklist.rb +3 -1
- data/lib/rubocop/cop/betterment/authorization_in_controller.rb +3 -1
- data/lib/rubocop/cop/betterment/dynamic_params.rb +3 -1
- data/lib/rubocop/cop/betterment/hardcoded_id.rb +3 -1
- data/lib/rubocop/cop/betterment/implicit_redirect_type.rb +4 -2
- data/lib/rubocop/cop/betterment/memoization_with_arguments.rb +3 -1
- data/lib/rubocop/cop/betterment/non_standard_actions.rb +3 -1
- data/lib/rubocop/cop/betterment/site_prism_loaded.rb +3 -1
- data/lib/rubocop/cop/betterment/spec_helper_required_outside_spec_dir.rb +3 -1
- data/lib/rubocop/cop/betterment/timeout.rb +3 -1
- data/lib/rubocop/cop/betterment/unsafe_job.rb +3 -1
- data/lib/rubocop/cop/betterment/unscoped_find.rb +22 -5
- data/lib/rubocop/cop/betterment/utils/hardcoded_attribute.rb +2 -0
- data/lib/rubocop/cop/betterment/utils/method_return_table.rb +2 -0
- data/lib/rubocop/cop/betterment/utils/parser.rb +2 -0
- data/lib/rubocop/cop/betterment/vague_serialize.rb +3 -1
- data/lib/rubocop/cop/betterment.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec284b88f4606e1f10bb1a7e0c26794135b2f605077ac2ef472c9fff8ae1d80f
|
4
|
+
data.tar.gz: 25e9df31ca75903e469dadb172847f992b2bf4005679f76cc15343850697c5c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56be31837c8216b387b4ad5baa0fb4362152354bb5b5c71ccd95f2cf49d58da5c3499f6765a3509b8773b585bd6a0df22d4092dbeefb2152011ec095520a2293
|
7
|
+
data.tar.gz: c0b3a8a0fde1eae38420afe105cba2a5f9b3ac9d5704695c45337a6ba78ddcd04b8642ba701d610ea2434fb3814459fc810e9e877839c06bb69194bbfabaa564
|
data/config/default.yml
CHANGED
@@ -86,7 +86,7 @@ Layout/CaseIndentation:
|
|
86
86
|
IndentOneStep: true
|
87
87
|
|
88
88
|
Layout/ClosingParenthesisIndentation:
|
89
|
-
Enabled:
|
89
|
+
Enabled: true
|
90
90
|
|
91
91
|
Layout/FirstArrayElementIndentation:
|
92
92
|
EnforcedStyle: consistent
|
@@ -292,7 +292,7 @@ Style/Documentation:
|
|
292
292
|
Enabled: false
|
293
293
|
|
294
294
|
Style/FrozenStringLiteralComment:
|
295
|
-
Enabled:
|
295
|
+
Enabled: true
|
296
296
|
|
297
297
|
Style/GuardClause:
|
298
298
|
Enabled: false
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# rubocop:disable Betterment/AllowlistBlocklist
|
2
4
|
module RuboCop
|
3
5
|
module Cop
|
4
6
|
module Betterment
|
5
7
|
class AllowlistBlocklist < Cop
|
6
|
-
MSG = <<-DOC
|
8
|
+
MSG = <<-DOC
|
7
9
|
Avoid usages of whitelist & blacklist, in favor of more inclusive and descriptive language.
|
8
10
|
For consistency, favor 'allowlist' and 'blocklist' where possible, but other terms (such as
|
9
11
|
denylist, ignorelist, warnlist, safelist, etc) may be appropriate, depending on the use case.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
@@ -5,7 +7,7 @@ module RuboCop
|
|
5
7
|
attr_accessor :unsafe_parameters, :unsafe_regex
|
6
8
|
|
7
9
|
# MSG_UNSAFE_CREATE = 'Model created/updated using unsafe parameters'.freeze
|
8
|
-
MSG_UNSAFE_CREATE = <<~MSG
|
10
|
+
MSG_UNSAFE_CREATE = <<~MSG
|
9
11
|
Model created/updated using unsafe parameters.
|
10
12
|
Please query for the associated record in a way that enforces authorization (e.g. "trust-root chaining"),
|
11
13
|
and then pass the resulting object into your model instead of the unsafe parameter.
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class DynamicParams < Cop
|
5
|
-
MSG_DYNAMIC_PARAMS = <<~MSG
|
7
|
+
MSG_DYNAMIC_PARAMS = <<~MSG
|
6
8
|
Parameter names accessed dynamically, cannot determine safeness. Please inline the keys explicitly when calling `permit` or when accessing `params` like a hash.
|
7
9
|
|
8
10
|
See here for more information on this error:
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
@@ -5,7 +7,7 @@ module RuboCop
|
|
5
7
|
include RangeHelp
|
6
8
|
extend AutoCorrector
|
7
9
|
|
8
|
-
MSG = 'Hardcoded IDs cause flaky tests. Use a sequence instead.'
|
10
|
+
MSG = 'Hardcoded IDs cause flaky tests. Use a sequence instead.'
|
9
11
|
|
10
12
|
# @!method key(node)
|
11
13
|
def_node_matcher :key, '/^id$|_id$/'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
@@ -13,10 +15,10 @@ module RuboCop
|
|
13
15
|
# get '/', redirect('/dashboard', status: 301)
|
14
16
|
# get(status: 302) { |params, request| '/dashboard' }
|
15
17
|
class ImplicitRedirectType < Cop
|
16
|
-
ROUTES_FILE_NAME = 'routes.rb'
|
18
|
+
ROUTES_FILE_NAME = 'routes.rb'
|
17
19
|
MSG =
|
18
20
|
'Rails will create a permanent (301) redirect, which is dangerous. ' \
|
19
|
-
'Please specify your desired status, e.g. redirect(..., status: 302)'
|
21
|
+
'Please specify your desired status, e.g. redirect(..., status: 302)'
|
20
22
|
|
21
23
|
# redirect('/')
|
22
24
|
def_node_matcher :arg_form_without_options?, <<-PATTERN
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class MemoizationWithArguments < Cop
|
5
7
|
MSG = 'Memoized method `%<method>s` accepts arguments, ' \
|
6
8
|
'which may cause it to return a stale result. ' \
|
7
|
-
'Remove memoization or refactor to remove arguments.'
|
9
|
+
'Remove memoization or refactor to remove arguments.'
|
8
10
|
|
9
11
|
def self.node_pattern
|
10
12
|
memo_assign = '(or_asgn $(ivasgn _) _)'
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class NonStandardActions < Cop
|
5
|
-
MSG_GENERAL = 'Use a new controller instead of custom actions.'
|
7
|
+
MSG_GENERAL = 'Use a new controller instead of custom actions.'
|
6
8
|
MSG_RESOURCE_ONLY = "Resource route refers to a non-standard action in it's 'only:' param. #{MSG_GENERAL}".freeze
|
7
9
|
MSG_ROUTE_TO = "Route goes to a non-standard controller action. #{MSG_GENERAL}".freeze
|
8
10
|
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class SitePrismLoaded < Cop
|
5
|
-
MSG = 'Use `be_loaded` instead of `be_displayed`'
|
7
|
+
MSG = 'Use `be_loaded` instead of `be_displayed`'
|
6
8
|
|
7
9
|
def_node_matcher :be_displayed_call?, <<-PATTERN
|
8
10
|
(send (send nil? :expect _) _ (send nil? :be_displayed))
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
@@ -13,7 +15,7 @@ module RuboCop
|
|
13
15
|
# spec/models/my_class_spec.rb
|
14
16
|
# require 'rails_helper'
|
15
17
|
class SpecHelperRequiredOutsideSpecDir < Cop
|
16
|
-
MSG = 'Spec helper required outside of a spec/ directory.'
|
18
|
+
MSG = 'Spec helper required outside of a spec/ directory.'
|
17
19
|
|
18
20
|
def_node_matcher :requires_spec_helper?, <<-PATTERN
|
19
21
|
(send nil? :require
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class Timeout < Cop
|
5
|
-
MSG = 'Using Timeout.timeout without a custom exception can prevent rescue blocks from executing'
|
7
|
+
MSG = 'Using Timeout.timeout without a custom exception can prevent rescue blocks from executing'
|
6
8
|
|
7
9
|
def_node_matcher :timeout_call?, <<-PATTERN
|
8
10
|
(send (const nil? :Timeout) :timeout _)
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class UnsafeJob < Cop
|
5
7
|
attr_accessor :sensitive_params, :class_regex
|
6
8
|
|
7
|
-
MSG = <<~MSG
|
9
|
+
MSG = <<~MSG
|
8
10
|
This job takes a parameter that will end up serialized in plaintext. Do not pass sensitive data as bare arguments into jobs.
|
9
11
|
|
10
12
|
See here for more information on this error:
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class UnscopedFind < Cop
|
5
7
|
attr_accessor :unauthenticated_models
|
6
8
|
|
7
|
-
MSG = <<~MSG
|
9
|
+
MSG = <<~MSG
|
8
10
|
Records are being retrieved directly using user input.
|
9
11
|
Please query for the associated record in a way that enforces authorization (e.g. "trust-root chaining").
|
10
12
|
|
@@ -19,6 +21,7 @@ module RuboCop
|
|
19
21
|
MSG
|
20
22
|
METHOD_PATTERN = /^find_by_(.+?)(!)?$/
|
21
23
|
FINDS = %i(find find_by find_by! where).freeze
|
24
|
+
GRAPHQL_PATTERN = /\bGraphQL\b/i
|
22
25
|
|
23
26
|
def_node_matcher :custom_scope_find?, <<-PATTERN
|
24
27
|
(send (send (const ... _) ...) {#{FINDS.map(&:inspect).join(' ')}} ...)
|
@@ -28,6 +31,10 @@ module RuboCop
|
|
28
31
|
(send (const ... _) {#{FINDS.map(&:inspect).join(' ')}} ...)
|
29
32
|
PATTERN
|
30
33
|
|
34
|
+
def_node_search :find_graphql_namespace_nodes, <<~PATTERN, name: GRAPHQL_PATTERN
|
35
|
+
(const _ %name)
|
36
|
+
PATTERN
|
37
|
+
|
31
38
|
def initialize(config = nil, options = nil)
|
32
39
|
super(config, options)
|
33
40
|
config = @config.for_cop(self)
|
@@ -42,16 +49,26 @@ module RuboCop
|
|
42
49
|
_, _, *arg_nodes = *node # rubocop:disable InternalAffairs/NodeDestructuring
|
43
50
|
return unless
|
44
51
|
(
|
45
|
-
|
46
|
-
|
47
|
-
|
52
|
+
find?(node) ||
|
53
|
+
custom_scope_find?(node) ||
|
54
|
+
static_method_name(node.method_name)
|
48
55
|
) && !@unauthenticated_models.include?(Utils::Parser.get_root_token(node))
|
49
56
|
|
50
|
-
add_offense(node) if find_param_arg(arg_nodes)
|
57
|
+
add_offense(node) if find_param_arg(arg_nodes) || graphql_file? || graphql_namespace?(node)
|
51
58
|
end
|
52
59
|
|
53
60
|
private
|
54
61
|
|
62
|
+
def graphql_file?
|
63
|
+
processed_source.path&.match?(GRAPHQL_PATTERN)
|
64
|
+
end
|
65
|
+
|
66
|
+
def graphql_namespace?(node)
|
67
|
+
node
|
68
|
+
.each_ancestor(:class, :module)
|
69
|
+
.any? { |ancestor| find_graphql_namespace_nodes(ancestor).any? }
|
70
|
+
end
|
71
|
+
|
55
72
|
def find_param_arg(arg_nodes)
|
56
73
|
return unless arg_nodes
|
57
74
|
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Cop
|
3
5
|
module Betterment
|
4
6
|
class VagueSerialize < Base
|
5
7
|
MSG = 'Active Record models with serialized columns should specify which ' \
|
6
|
-
'deserializer to use instead of falling back to the default.'
|
8
|
+
'deserializer to use instead of falling back to the default.'
|
7
9
|
|
8
10
|
# @!method serialize?(node)
|
9
11
|
def_node_matcher :serialize?, <<-PATTERN
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Development
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
rubygems_version: 3.4.
|
132
|
+
rubygems_version: 3.4.22
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Betterment rubocop configuration
|