betterlint 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/config/default.yml +7 -0
- data/lib/rubocop/cop/betterment/environment_configuration.rb +20 -0
- data/lib/rubocop/cop/betterment.rb +1 -0
- metadata +7 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0adfef8c242987ffe23f5281c1bf5adceefbe66b1d21e4720cc3eecb5a11f7ef
|
4
|
+
data.tar.gz: 824104f6bbba860b30dcc6231935774307c238ef96d077a50a7f30faf79fab27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71e15b73154d81aef392ee4acefb64548ed6c51ce0789ee7d74fb9010077cb91361752faeed7d45331ea0311ac934073f5ba924cf2f887e77702ed863dbd1b25
|
7
|
+
data.tar.gz: 944e4b25de84d12030f27c1346e79311906426216bd45ae7a6431aa6341c2d51828b601d16ed0ae2b6ddc9d03a08ea102f405c0a613b58300e3cc78825b3a0fe
|
data/README.md
CHANGED
@@ -130,6 +130,27 @@ end
|
|
130
130
|
```
|
131
131
|
|
132
132
|
All three `params.permit` calls will be flagged.
|
133
|
+
|
134
|
+
### Betterment/EnvironmentConfiguration
|
135
|
+
|
136
|
+
This cop identifies references to `ENV` outside of the config directory.
|
137
|
+
|
138
|
+
Environment variables should be parsed at boot time. If an environment variable is missing or invalid,
|
139
|
+
the application should fail to boot.
|
140
|
+
|
141
|
+
If there isn't a better place to assign your environment variable, Rails provides the `config.x` namespace
|
142
|
+
for [custom configuration](https://guides.rubyonrails.org/configuring.html#custom-configuration):
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
config.x.whatever = ENV.fetch('WHATEVER')
|
146
|
+
```
|
147
|
+
|
148
|
+
Here's how you'd reference this configuration parameter at runtime:
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
Rails.configuration.x.whatever
|
152
|
+
```
|
153
|
+
|
133
154
|
### Betterment/InternalsProtection
|
134
155
|
|
135
156
|
This cop is not enabled by default, and must be enabled from your `.rubocop.yml` file:
|
data/config/default.yml
CHANGED
@@ -39,6 +39,13 @@ Betterment/DirectDelayedEnqueue:
|
|
39
39
|
|
40
40
|
Betterment/DynamicParams:
|
41
41
|
StyleGuide: '#bettermentdynamicparams'
|
42
|
+
|
43
|
+
Betterment/EnvironmentConfiguration:
|
44
|
+
StyleGuide: '#bettermentenvironmentconfiguration'
|
45
|
+
Exclude:
|
46
|
+
- config/**/*.rb
|
47
|
+
- spec/**/*.rb
|
48
|
+
- test/**/*.rb
|
42
49
|
|
43
50
|
Betterment/HardcodedID:
|
44
51
|
AutoCorrect: false
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Betterment
|
6
|
+
class EnvironmentConfiguration < Base
|
7
|
+
MSG =
|
8
|
+
"Environment variables should be parsed at boot time and assigned " \
|
9
|
+
"to `Rails.configuration` or some other configurable object."
|
10
|
+
|
11
|
+
# @!method env?(node)
|
12
|
+
def_node_matcher :env?, '(const nil? :ENV)'
|
13
|
+
|
14
|
+
def on_const(node)
|
15
|
+
add_offense(node) if env?(node)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,6 +6,7 @@ require 'rubocop/cop/betterment/allowlist_blocklist'
|
|
6
6
|
require 'rubocop/cop/betterment/authorization_in_controller'
|
7
7
|
require 'rubocop/cop/betterment/direct_delayed_enqueue'
|
8
8
|
require 'rubocop/cop/betterment/dynamic_params'
|
9
|
+
require 'rubocop/cop/betterment/environment_configuration'
|
9
10
|
require 'rubocop/cop/betterment/fetch_boolean'
|
10
11
|
require 'rubocop/cop/betterment/hardcoded_id'
|
11
12
|
require 'rubocop/cop/betterment/implicit_redirect_type'
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Development
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-03-26 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rubocop
|
@@ -110,6 +109,7 @@ files:
|
|
110
109
|
- lib/rubocop/cop/betterment/authorization_in_controller.rb
|
111
110
|
- lib/rubocop/cop/betterment/direct_delayed_enqueue.rb
|
112
111
|
- lib/rubocop/cop/betterment/dynamic_params.rb
|
112
|
+
- lib/rubocop/cop/betterment/environment_configuration.rb
|
113
113
|
- lib/rubocop/cop/betterment/fetch_boolean.rb
|
114
114
|
- lib/rubocop/cop/betterment/hardcoded_id.rb
|
115
115
|
- lib/rubocop/cop/betterment/implicit_redirect_type.rb
|
@@ -136,12 +136,11 @@ 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.19.0
|
140
|
+
changelog_uri: https://github.com/Betterment/betterlint/blob/v1.19.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.19.0
|
143
143
|
rubygems_mfa_required: 'true'
|
144
|
-
post_install_message:
|
145
144
|
rdoc_options: []
|
146
145
|
require_paths:
|
147
146
|
- lib
|
@@ -156,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
155
|
- !ruby/object:Gem::Version
|
157
156
|
version: '0'
|
158
157
|
requirements: []
|
159
|
-
rubygems_version: 3.5
|
160
|
-
signing_key:
|
158
|
+
rubygems_version: 3.6.5
|
161
159
|
specification_version: 4
|
162
160
|
summary: Betterment rubocop configuration
|
163
161
|
test_files: []
|