rubocop-neeto 0.1.10 → 0.1.12
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 +2 -1
- data/config/default.yml +14 -0
- data/lib/rubocop/cop/neeto/direct_env_access.rb +48 -0
- data/lib/rubocop/cop/neeto_cops.rb +1 -0
- data/lib/rubocop/neeto/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b93018be6b3def6d6c449b2809931330ce9e1bbf05420ce31c8c8a17e958abf
|
|
4
|
+
data.tar.gz: a717e43ba5754ba004d0460e43445d33a9b8ce056b75c16a1a55be0fcea6aed2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ef0c717345ffc75c8a451c6ea80cce118e4f260d36d29c4252cd54f86ac94db385a61b65512c437fd37c1afa0ccf9cd97c8c5aeae16efed937bb036e5447ca7
|
|
7
|
+
data.tar.gz: 7b7d8da23d45418253ced5c59266123bda9e1815ca1b9ee2d515450a4b803b7cd12d30fb6860c2ca5d48ee03b868653bd97cd1ed3e3af817c9a5fabc61d0a6b6
|
data/README.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
1. [Neeto/UnsafeTableDeletion](https://rubocop-neeto.neetodeployapp.com/docs/RuboCop/Cop/Neeto/UnsafeTableDeletion)
|
|
6
6
|
2. [Neeto/UnsafeColumnDeletion](https://rubocop-neeto.neetodeployapp.com/docs/RuboCop/Cop/Neeto/UnsafeColumnDeletion)
|
|
7
|
+
3. [Neeto/DirectEnvAccess](https://rubocop-neeto.neetodeployapp.com/docs/RuboCop/Cop/Neeto/DirectEnvAccess)
|
|
7
8
|
|
|
8
9
|
## Installation
|
|
9
10
|
|
|
@@ -42,7 +43,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
42
43
|
|
|
43
44
|
## Contributing
|
|
44
45
|
|
|
45
|
-
Bug reports and pull requests are welcome
|
|
46
|
+
Bug reports and pull requests are welcome.
|
|
46
47
|
|
|
47
48
|
## License
|
|
48
49
|
|
data/config/default.yml
CHANGED
|
@@ -23,3 +23,17 @@ Neeto/UnsafeColumnDeletion:
|
|
|
23
23
|
VersionAdded: '0.1'
|
|
24
24
|
Include:
|
|
25
25
|
- db/**/*.rb
|
|
26
|
+
|
|
27
|
+
Neeto/DirectEnvAccess:
|
|
28
|
+
Description: >-
|
|
29
|
+
Rails had `secrets.yml` which provided a single source of truth for all
|
|
30
|
+
environment variables and their fallback values. Rails deprecated this in
|
|
31
|
+
favor of encrypted credentials, so we created Secvault to maintain
|
|
32
|
+
centralized configuration. Direct usage of `ENV` bypasses this system,
|
|
33
|
+
making it harder to track what environment variables are being used and
|
|
34
|
+
their defaults. Use `Secvault.secrets` instead.
|
|
35
|
+
Enabled: true
|
|
36
|
+
Severity: refactor
|
|
37
|
+
VersionAdded: '0.1'
|
|
38
|
+
Include:
|
|
39
|
+
- app/**/*.rb
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Neeto
|
|
6
|
+
# Rails had `secrets.yml` which provided a single source of truth for all
|
|
7
|
+
# environment variables and their fallback values. Rails deprecated this in
|
|
8
|
+
# favor of encrypted credentials, so we created Secvault
|
|
9
|
+
# (https://github.com/neetozone/secvault) to maintain centralized configuration.
|
|
10
|
+
# Direct usage of `ENV` bypasses this system, making it harder to track what
|
|
11
|
+
# environment variables are being used and their defaults. This cop enforces
|
|
12
|
+
# that all environment variable access goes through `Secvault.secrets`.
|
|
13
|
+
#
|
|
14
|
+
# @example DirectEnvAccess: true (default)
|
|
15
|
+
# # Enforces the usage of `Secvault.secrets` over direct `ENV` access.
|
|
16
|
+
#
|
|
17
|
+
# # bad
|
|
18
|
+
# api_key = ENV['STRIPE_API_KEY']
|
|
19
|
+
#
|
|
20
|
+
# # bad
|
|
21
|
+
# default_timezone = ENV['DEFAULT_TIMEZONE'] || 'UTC'
|
|
22
|
+
#
|
|
23
|
+
# # good
|
|
24
|
+
# api_key = Secvault.secrets.stripe_api_key
|
|
25
|
+
#
|
|
26
|
+
# # good
|
|
27
|
+
# default_timezone = Secvault.secrets.default_timezone
|
|
28
|
+
#
|
|
29
|
+
# # good (ENV access is permitted in directories other than the app directory)
|
|
30
|
+
# config.log_level = ENV.fetch('LOG_LEVEL', 'info')
|
|
31
|
+
#
|
|
32
|
+
class DirectEnvAccess < Base
|
|
33
|
+
MSG = "Do not use ENV directly. " \
|
|
34
|
+
"Use Secvault.secrets to maintain a single source of truth for configuration."
|
|
35
|
+
|
|
36
|
+
def_node_matcher :env_access?, <<~PATTERN
|
|
37
|
+
(const {nil? cbase} :ENV)
|
|
38
|
+
PATTERN
|
|
39
|
+
|
|
40
|
+
def on_const(node)
|
|
41
|
+
return unless env_access?(node)
|
|
42
|
+
|
|
43
|
+
add_offense(node)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-neeto
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Abhay V Ashokan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -35,17 +35,18 @@ files:
|
|
|
35
35
|
- Rakefile
|
|
36
36
|
- config/default.yml
|
|
37
37
|
- lib/rubocop-neeto.rb
|
|
38
|
+
- lib/rubocop/cop/neeto/direct_env_access.rb
|
|
38
39
|
- lib/rubocop/cop/neeto/unsafe_column_deletion.rb
|
|
39
40
|
- lib/rubocop/cop/neeto/unsafe_table_deletion.rb
|
|
40
41
|
- lib/rubocop/cop/neeto_cops.rb
|
|
41
42
|
- lib/rubocop/neeto.rb
|
|
42
43
|
- lib/rubocop/neeto/inject.rb
|
|
43
44
|
- lib/rubocop/neeto/version.rb
|
|
44
|
-
homepage: https://github.com/
|
|
45
|
+
homepage: https://github.com/neetozone/rubocop-neeto
|
|
45
46
|
licenses: []
|
|
46
47
|
metadata:
|
|
47
|
-
homepage_uri: https://github.com/
|
|
48
|
-
source_code_uri: https://github.com/
|
|
48
|
+
homepage_uri: https://github.com/neetozone/rubocop-neeto
|
|
49
|
+
source_code_uri: https://github.com/neetozone/rubocop-neeto
|
|
49
50
|
post_install_message:
|
|
50
51
|
rdoc_options: []
|
|
51
52
|
require_paths:
|