betterlint 1.18.0 → 1.20.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: a8373ada8389173714d5f6086fd98f64e056340b8ddbd6c3b7e9cb78a3143b1f
4
+ data.tar.gz: bf710724c7163b0ef355cecfaad17bcf6af70c58fa50cdb81fd7d691d1e6e269
5
5
  SHA512:
6
- metadata.gz: dfe7759c87fe74850dade98e961d7d36f4656500a91c9327612d778cae5953bb07d5daa56d448b1ed2e0c9140df799340c901cb086925b00275cd7b0d8a90e2f
7
- data.tar.gz: 101ce64b3692608b1a7e92000e03c94f4c4f2b14548e4ae6aaa9139dfb925cd2ca304cc1d5df53a512fb74a740adbb92186dc25f3acb937df81535379d68ef2a
6
+ metadata.gz: 991c3a041583443b9e53e0c3baa7ace7354b76a5a07e322d85e82f73bea4a01b7252f203ccbbac1e6947675eb20940777cc4f6df72132ba40f64aab265fbbbf3
7
+ data.tar.gz: c52af40049be9780cbd719df55e3747902f5c51d7e0136340140aaecc1bab53b8a17f5ecc9f84843dc43e066a9a7df90b02ce751d46c8784d2b0f77baba6e47f
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
@@ -40,6 +40,13 @@ Betterment/DirectDelayedEnqueue:
40
40
  Betterment/DynamicParams:
41
41
  StyleGuide: '#bettermentdynamicparams'
42
42
 
43
+ Betterment/EnvironmentConfiguration:
44
+ StyleGuide: '#bettermentenvironmentconfiguration'
45
+ Exclude:
46
+ - config/**/*.rb
47
+ - spec/**/*.rb
48
+ - test/**/*.rb
49
+
43
50
  Betterment/HardcodedID:
44
51
  AutoCorrect: false
45
52
  Description: Detects hardcoded IDs in specs
@@ -371,6 +378,9 @@ Style/GuardClause:
371
378
  Style/IfUnlessModifier:
372
379
  Enabled: false
373
380
 
381
+ Style/HashSyntax:
382
+ EnforcedShorthandSyntax: always
383
+
374
384
  Style/Lambda:
375
385
  Enabled: false
376
386
 
@@ -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.20.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-05-28 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.20.0
140
+ changelog_uri: https://github.com/Betterment/betterlint/blob/v1.20.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.20.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.6
161
159
  specification_version: 4
162
160
  summary: Betterment rubocop configuration
163
161
  test_files: []