betterlint 1.7.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/betterment/fetch_boolean.rb +61 -0
- data/lib/rubocop/cop/betterment.rb +1 -0
- metadata +24 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1491e20e0716813156b261f5cd5a9cf253455c004fc1bd19b6b76145519a63ac
|
4
|
+
data.tar.gz: 235b8423ef33fa88e926e6ff174d179649d4a15b737a4dc3757a97e919267223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70410f02798546b16ec349134e18397794f52ba01341f7d5023514c9fdc6a6c52b2aa579c811d6cb66a0955e93f08330398c4b5846a89434464c72b9122f55b9
|
7
|
+
data.tar.gz: 9773586040f235b40766bccd931e7dcc14e0d9d6297f56e5bce6a155aaa0854cdb1f289dc4667cea0459007663c301bc12e00ca11a5682f0f517188e2c838e08
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Betterment
|
6
|
+
class FetchBoolean < Base
|
7
|
+
MSG = <<~MSG
|
8
|
+
A boolean fetched from query params or ENV will never be false when
|
9
|
+
explicitly specified on the request or env var. Please use a model
|
10
|
+
with a boolean attribute, or cast the value.
|
11
|
+
MSG
|
12
|
+
|
13
|
+
# @!method fetch_boolean?(node)
|
14
|
+
def_node_matcher :fetch_boolean?, <<-PATTERN
|
15
|
+
(send _ :fetch _ (boolean))
|
16
|
+
PATTERN
|
17
|
+
|
18
|
+
# @!method fetch_env_boolean?(node)
|
19
|
+
def_node_matcher :fetch_env_boolean?, <<-PATTERN
|
20
|
+
(send (const nil? :ENV) :fetch _ (boolean))
|
21
|
+
PATTERN
|
22
|
+
|
23
|
+
# @!method boolean_cast?(node)
|
24
|
+
def_node_search :boolean_cast?, <<-PATTERN
|
25
|
+
(send
|
26
|
+
(send
|
27
|
+
(const
|
28
|
+
(const
|
29
|
+
(const nil? :ActiveModel) :Type) :Boolean) :new) :cast
|
30
|
+
...)
|
31
|
+
PATTERN
|
32
|
+
|
33
|
+
# @!method action_controller?(node)
|
34
|
+
def_node_search :action_controller?, <<~PATTERN
|
35
|
+
{
|
36
|
+
(const {nil? cbase} :ApplicationController)
|
37
|
+
(const (const {nil? cbase} :ActionController) :Base)
|
38
|
+
}
|
39
|
+
PATTERN
|
40
|
+
|
41
|
+
def on_send(node)
|
42
|
+
return unless fetch_env_boolean?(node) ||
|
43
|
+
(fetch_boolean?(node) && inherit_action_controller_base?(node))
|
44
|
+
|
45
|
+
return if node.each_ancestor(:send).any? { |ancestor| boolean_cast?(ancestor) }
|
46
|
+
|
47
|
+
add_offense(node)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def inherit_action_controller_base?(node)
|
53
|
+
class_node = node.each_ancestor(:class).first
|
54
|
+
return false unless class_node
|
55
|
+
|
56
|
+
action_controller?(class_node)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Development
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.62.0
|
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:
|
26
|
+
version: 1.62.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-performance
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.21.0
|
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:
|
40
|
+
version: 1.21.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.24.0
|
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:
|
54
|
+
version: 2.24.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop-rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.6.0
|
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:
|
68
|
+
version: 0.6.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.28.0
|
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:
|
82
|
+
version: 2.28.0
|
83
83
|
description: Betterment rubocop configuration
|
84
84
|
email:
|
85
85
|
- development@betterment.com
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/rubocop/cop/betterment/allowlist_blocklist.rb
|
96
96
|
- lib/rubocop/cop/betterment/authorization_in_controller.rb
|
97
97
|
- lib/rubocop/cop/betterment/dynamic_params.rb
|
98
|
+
- lib/rubocop/cop/betterment/fetch_boolean.rb
|
98
99
|
- lib/rubocop/cop/betterment/hardcoded_id.rb
|
99
100
|
- lib/rubocop/cop/betterment/implicit_redirect_type.rb
|
100
101
|
- lib/rubocop/cop/betterment/memoization_with_arguments.rb
|
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
130
|
- !ruby/object:Gem::Version
|
130
131
|
version: '0'
|
131
132
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
133
|
+
rubygems_version: 3.5.7
|
133
134
|
signing_key:
|
134
135
|
specification_version: 4
|
135
136
|
summary: Betterment rubocop configuration
|