get_env 0.2.1 → 0.2.2
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/lib/get_env/version.rb +1 -1
- data/lib/rubocop/cop/lint/no_env.rb +4 -6
- data/spec/rubocop/cop/lint/no_env_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 573449592055de9a5cf540a80ac3bcf9cf37c30c8a8270d0a354d382dadec9a6
|
|
4
|
+
data.tar.gz: fe49d463cecf35f961809aa7c6e2ea71cabcf846b36e7d5bde33fd12577e3e20
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c1c7974ef31f6b82e9bb6d3acfcb7cf77eed8303662d808740195b800a695f8149a99321c90c6d04836880889b93cb690094b8904d820786597b436747818b3
|
|
7
|
+
data.tar.gz: 7e4fe1661df9f16f37d2c4184348223852bb7f91fdced7ad729d0eb6fb698f1555d91546b84be4f9b6b44e9597150264ebdf728e03d5fc9db4f76998e7e62fb8
|
data/lib/get_env/version.rb
CHANGED
|
@@ -15,7 +15,9 @@ module RuboCop
|
|
|
15
15
|
#
|
|
16
16
|
# # good
|
|
17
17
|
# GetEnv.fetch(...)
|
|
18
|
-
class NoENV <
|
|
18
|
+
class NoENV < Base
|
|
19
|
+
extend AutoCorrector
|
|
20
|
+
|
|
19
21
|
MSG = 'Use `GetEnv` instead of `ENV`.'
|
|
20
22
|
|
|
21
23
|
def_node_matcher :is_ENV_index?, '(send (const nil? :ENV) :[] _key)'
|
|
@@ -25,11 +27,7 @@ module RuboCop
|
|
|
25
27
|
parent = node.parent
|
|
26
28
|
return unless is_ENV_index?(parent) || is_ENV_fetch?(parent)
|
|
27
29
|
|
|
28
|
-
add_offense(node)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def autocorrect(node)
|
|
32
|
-
lambda do |corrector|
|
|
30
|
+
add_offense(node) do |corrector|
|
|
33
31
|
if Gem::Version.new(RuboCop::Version.version) >= Gem::Version.new('0.82.0')
|
|
34
32
|
corrector.replace(node, 'GetEnv')
|
|
35
33
|
else
|
|
@@ -15,7 +15,7 @@ RSpec.describe RuboCop::Cop::Lint::NoENV do
|
|
|
15
15
|
it 'registers an offense when using `ENV`' do
|
|
16
16
|
expect_offense(<<~RUBY)
|
|
17
17
|
FOO = ENV['FOO']
|
|
18
|
-
^^^ Use `GetEnv` instead of `ENV`.
|
|
18
|
+
^^^ Lint/NoENV: Use `GetEnv` instead of `ENV`.
|
|
19
19
|
RUBY
|
|
20
20
|
|
|
21
21
|
expect_correction(<<~RUBY)
|
|
@@ -34,7 +34,7 @@ RSpec.describe RuboCop::Cop::Lint::NoENV do
|
|
|
34
34
|
it 'registers an offense when using `ENV`' do
|
|
35
35
|
expect_offense(<<~RUBY)
|
|
36
36
|
do_the_thing(ENV.fetch('FOO'))
|
|
37
|
-
^^^ Use `GetEnv` instead of `ENV`.
|
|
37
|
+
^^^ Lint/NoENV: Use `GetEnv` instead of `ENV`.
|
|
38
38
|
RUBY
|
|
39
39
|
|
|
40
40
|
expect_correction(<<~RUBY)
|
|
@@ -45,7 +45,7 @@ RSpec.describe RuboCop::Cop::Lint::NoENV do
|
|
|
45
45
|
it 'registers an offense when using `ENV` with a default value' do
|
|
46
46
|
expect_offense(<<~RUBY)
|
|
47
47
|
a = x + ENV.fetch('FOO', 42)
|
|
48
|
-
^^^ Use `GetEnv` instead of `ENV`.
|
|
48
|
+
^^^ Lint/NoENV: Use `GetEnv` instead of `ENV`.
|
|
49
49
|
RUBY
|
|
50
50
|
|
|
51
51
|
expect_correction(<<~RUBY)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: get_env
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simon Mathieu
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date:
|
|
14
|
+
date: 2025-01-22 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: bundler
|