Skip to content

Commit d79cafd

Browse files
committed
Fix Style/FetchEnvVar rubocop violations
The latest version of rubocop as of this commit (v1.28.1) was reporting these three violations: ``` Rakefile:15:19: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch('EXAMPLE_APP') or ENV.fetch('EXAMPLE_APP', nil) instead of ENV['EXAMPLE_APP']. example_app = ENV['EXAMPLE_APP'] || 'demo_app' ^^^^^^^^^^^^^^^^^^ Rakefile:58:21: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch('INTEGRATION_BUNDLE_ARGS') or ENV.fetch('INTEGRATION_BUNDLE_ARGS', nil) instead of ENV['INTEGRATION_BUNDLE_ARGS']. bundle_args = ENV['INTEGRATION_BUNDLE_ARGS'] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/external_asset_pipeline/dev_server_test.rb:16:21: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch('DEV_SERVER_HOST') or ENV.fetch('DEV_SERVER_HOST', nil) instead of ENV['DEV_SERVER_HOST']. config.host = ENV['DEV_SERVER_HOST'] || 'localhost' ^^^^^^^^^^^^^^^^^^^^^^ test/external_asset_pipeline/dev_server_test.rb:32:21: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch('DEV_SERVER_HOST') or ENV.fetch('DEV_SERVER_HOST', nil) instead of ENV['DEV_SERVER_HOST']. config.host = ENV['DEV_SERVER_HOST'] || 'localhost' ^^^^^^^^^^^^^^^^^^^^^^ test/external_asset_pipeline/dev_server_test.rb:50:21: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch('DEV_SERVER_HOST') or ENV.fetch('DEV_SERVER_HOST', nil) instead of ENV['DEV_SERVER_HOST']. config.host = ENV['DEV_SERVER_HOST'] || 'localhost' ^^^^^^^^^^^^^^^^^^^^^^ test/integration/external_asset_pipeline_integration_test.rb:29:23: C: [Correctable] Style/FetchEnvVar: Use ENV.fetch('DEV_SERVER_HOST') or ENV.fetch('DEV_SERVER_HOST', nil) instead of ENV['DEV_SERVER_HOST']. dev_server_host = ENV['DEV_SERVER_HOST'] || 'localhost' ^^^^^^^^^^^^^^^^^^^^^^ ```
1 parent 781e523 commit d79cafd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ExampleAppCommand
1212

1313
def initialize(command)
1414
@command = command
15-
example_app = ENV['EXAMPLE_APP'] || 'demo_app'
15+
example_app = ENV.fetch('EXAMPLE_APP', 'demo_app')
1616
@example_app_path = File.expand_path("./examples/#{example_app}", __dir__)
1717
@gemfile_path = File.join(@example_app_path, 'Gemfile')
1818
end
@@ -55,7 +55,7 @@ namespace :test do
5555
namespace :integration do
5656
desc 'Resolve and install dependencies and build assets in example app'
5757
task :prepare do
58-
bundle_args = ENV['INTEGRATION_BUNDLE_ARGS']
58+
bundle_args = ENV.fetch('INTEGRATION_BUNDLE_ARGS', '')
5959
ExampleAppCommand.run(
6060
"bundle check #{bundle_args} || bundle install #{bundle_args}"
6161
)

test/external_asset_pipeline/dev_server_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module ExternalAssetPipeline
1313
class DevServerTest < Minitest::Test
1414
def test_get
1515
config = Configuration::DevServerSettings.new
16-
config.host = ENV['DEV_SERVER_HOST'] || 'localhost'
16+
config.host = ENV.fetch('DEV_SERVER_HOST', 'localhost')
1717
config.port = 9555
1818

1919
dev_server = DevServer.new(config)
@@ -29,7 +29,7 @@ def test_get
2929

3030
def test_origin
3131
config = Configuration::DevServerSettings.new
32-
config.host = ENV['DEV_SERVER_HOST'] || 'localhost'
32+
config.host = ENV.fetch('DEV_SERVER_HOST', 'localhost')
3333
config.port = 9666
3434

3535
dev_server = DevServer.new(config)
@@ -47,7 +47,7 @@ def test_origin
4747

4848
def test_running
4949
config = Configuration::DevServerSettings.new
50-
config.host = ENV['DEV_SERVER_HOST'] || 'localhost'
50+
config.host = ENV.fetch('DEV_SERVER_HOST', 'localhost')
5151
config.port = 9777
5252

5353
dev_server = DevServer.new(config)

test/integration/external_asset_pipeline_integration_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ExternalAssetPipelineIntegrationTest < ActionDispatch::IntegrationTest
2626

2727
Rails.application.config.external_asset_pipeline.cache_manifest = false
2828
dev_server_thread = create_server_thread(9000)
29-
dev_server_host = ENV['DEV_SERVER_HOST'] || 'localhost'
29+
dev_server_host = ENV.fetch('DEV_SERVER_HOST', 'localhost')
3030
wait_for_server(dev_server_host, 9000)
3131

3232
get root_url

0 commit comments

Comments
 (0)