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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07e39ffdbd6630e753fcec9c3fd5cb25d0b1d5f071299b8f1f66f252cb76c901
4
- data.tar.gz: da17e36192a8c847dd1597b48d7f2390ea3c6363563dba286a897f641d1775e7
3
+ metadata.gz: 0adfef8c242987ffe23f5281c1bf5adceefbe66b1d21e4720cc3eecb5a11f7ef
4
+ data.tar.gz: 824104f6bbba860b30dcc6231935774307c238ef96d077a50a7f30faf79fab27
5
5
  SHA512:
6
- metadata.gz: dfe7759c87fe74850dade98e961d7d36f4656500a91c9327612d778cae5953bb07d5daa56d448b1ed2e0c9140df799340c901cb086925b00275cd7b0d8a90e2f
7
- data.tar.gz: 101ce64b3692608b1a7e92000e03c94f4c4f2b14548e4ae6aaa9139dfb925cd2ca304cc1d5df53a512fb74a740adbb92186dc25f3acb937df81535379d68ef2a
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.18.0
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-01-28 00:00:00.000000000 Z
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.18.0
140
- changelog_uri: https://github.com/Betterment/betterlint/blob/v1.18.0/CHANGELOG.md
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.18.0
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.23
160
- signing_key:
158
+ rubygems_version: 3.6.5
161
159
  specification_version: 4
162
160
  summary: Betterment rubocop configuration
163
161
  test_files: []