Skip to content

Commit 0f1bd87

Browse files
Revert ENV.fetch to ENV[] and create a Rubocop exception
1 parent 59645cb commit 0f1bd87

File tree

9 files changed

+18
-11
lines changed

9 files changed

+18
-11
lines changed

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ Style/AsciiComments:
4949
Style/StringConcatenation:
5050
Enabled: false
5151

52+
# This rule was enforced after upgrading Rubocop from `1.22.1` to `1.50.2`. We are disabling this rule for the
53+
# time being so that we don't see any unexpected behavior when running Release Toolkit actions that could be
54+
# changed by this rule. See https://github.com/wordpress-mobile/release-toolkit/pull/464#pullrequestreview-1396569629
55+
# for more discussion
56+
Style/FetchEnvVar:
57+
Enabled: false
58+
5259
########## Gemspec Rules
5360

5461
# This was turned on by default after updating Rubocop to `1.50.2`. We want to disable this for now because

lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def self.available_options
4848
env_name: 'FL_DOWNLOAD_TRANSLATIONS_RES_DIR',
4949
description: "The path to the Android project's `res` dir (typically the `<project name>/src/main/res` directory) containing the `values-*` subdirs",
5050
type: String,
51-
default_value: "#{ENV.fetch('PROJECT_NAME', nil)}/src/main/res"
51+
default_value: "#{ENV['PROJECT_NAME']}/src/main/res"
5252
),
5353
FastlaneCore::ConfigItem.new(
5454
key: :glotpress_url,

lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def self.commit_version_bump
1616
if File.exist?(Fastlane::Helper::Android::VersionHelper.version_properties_file)
1717
Fastlane::Helper::GitHelper.commit(
1818
message: 'Bump version number',
19-
files: File.join(ENV.fetch('PROJECT_ROOT_FOLDER', nil), 'version.properties'),
19+
files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties'),
2020
push: true
2121
)
2222
else
2323
Fastlane::Helper::GitHelper.commit(
2424
message: 'Bump version number',
25-
files: File.join(ENV.fetch('PROJECT_ROOT_FOLDER', nil), ENV.fetch('PROJECT_NAME', nil), 'build.gradle'),
25+
files: File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle'),
2626
push: true
2727
)
2828
end

lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_tools_path_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ToolsPathHelper
1010
attr_reader :android_home
1111

1212
def initialize(sdk_root: nil)
13-
@android_home = sdk_root || ENV.fetch('ANDROID_HOME', nil) || ENV.fetch('ANDROID_SDK_ROOT', nil) || ENV.fetch('ANDROID_SDK', nil)
13+
@android_home = sdk_root || ENV['ANDROID_HOME'] || ENV['ANDROID_SDK_ROOT'] || ENV['ANDROID_SDK']
1414
end
1515

1616
# @param [String] binary The name of the binary to search for

lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def self.get_keyword_from_gradle_file(file_path, section, keyword)
467467
def self.gradle_path
468468
UI.user_error!("You need to set the `PROJECT_ROOT_FOLDER` environment variable to the path to the project's root") if ENV['PROJECT_ROOT_FOLDER'].nil?
469469
UI.user_error!('You need to set the `PROJECT_NAME` environment variable to the relative path to the project subfolder name') if ENV['PROJECT_NAME'].nil?
470-
File.join(ENV.fetch('PROJECT_ROOT_FOLDER', nil), ENV.fetch('PROJECT_NAME', nil), 'build.gradle')
470+
File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle')
471471
end
472472

473473
# Update both the versionName and versionCode of the build.gradle file to the specified version.

lib/fastlane/plugin/wpmreleasetoolkit/helper/interactive_prompt_reminder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def self.monkey_patch_interactive_prompts_with_reminder(after: DEFAULT_PROMPT_RE
8484

8585
# Apply Monkey patch
8686
unless ENV['FASTLANE_PROMPT_REMINDER_DISABLE_AUTO_PATCH']
87-
message = ENV.fetch('FASTLANE_PROMPT_REMINDER_MESSAGE', nil)
87+
message = ENV['FASTLANE_PROMPT_REMINDER_MESSAGE']
8888
message = FastlaneCore::Shell::DEFAULT_PROMPT_REMINDER_MESSAGE if %w[default true yes 1].include?(message&.downcase)
8989
delays = ENV['FASTLANE_PROMPT_REMINDER_DELAYS']&.split(',')&.map(&:to_i) || FastlaneCore::Shell::DEFAULT_PROMPT_REMINDER_DELAYS
9090

lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ module GitHelper
1818
# @param [Bool] include_metadata If true (the default), includes the `fastlane/download_metadata.swift` file and the `.pot` file (which typically contains an entry or release notes for the new version)
1919
#
2020
def self.commit_version_bump(include_deliverfile: true, include_metadata: true)
21-
files_list = [File.join(ENV.fetch('PROJECT_ROOT_FOLDER', nil), 'config', '.')]
21+
files_list = [File.join(ENV['PROJECT_ROOT_FOLDER'], 'config', '.')]
2222
files_list.append File.join('fastlane', 'Deliverfile') if include_deliverfile
2323
if include_metadata
2424
files_list.append File.join('fastlane', 'download_metadata.swift')
25-
files_list.append File.join(ENV.fetch('PROJECT_ROOT_FOLDER', nil), ENV.fetch('PROJECT_NAME', nil), 'Resources', ENV.fetch('APP_STORE_STRINGS_FILE_NAME', nil))
25+
files_list.append File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'Resources', ENV['APP_STORE_STRINGS_FILE_NAME'])
2626
end
2727

2828
Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list, push: true)

lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def self.update_fastlane_deliver(new_version)
219219
# @param [String] internal_version The new version number to use as `VERSION_LONG` for the interrnal xcconfig file, if it exists
220220
#
221221
def self.update_xc_configs(new_version, new_version_short, internal_version)
222-
update_xc_config(ENV.fetch('PUBLIC_CONFIG_FILE', nil), new_version, new_version_short)
222+
update_xc_config(ENV['PUBLIC_CONFIG_FILE'], new_version, new_version_short)
223223
update_xc_config(ENV['INTERNAL_CONFIG_FILE'], internal_version, new_version_short) unless ENV['INTERNAL_CONFIG_FILE'].nil?
224224
end
225225

@@ -311,7 +311,7 @@ def self.read_from_config_file(key, filePath)
311311
# The second element is the version extracted from the internal config file, only present if one was provided.
312312
def self.get_version_strings
313313
version_strings = []
314-
version_strings << read_long_version_from_config_file(ENV.fetch('PUBLIC_CONFIG_FILE', nil))
314+
version_strings << read_long_version_from_config_file(ENV['PUBLIC_CONFIG_FILE'])
315315
version_strings << read_long_version_from_config_file(ENV['INTERNAL_CONFIG_FILE']) unless ENV['INTERNAL_CONFIG_FILE'].nil?
316316

317317
return version_strings

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Buildkite Test Analytics
1717
WebMock.disable_net_connect!(allow: 'analytics-api.buildkite.com')
18-
RSpec::Buildkite::Analytics.configure(token: ENV.fetch('BUILDKITE_ANALYTICS_TOKEN', nil))
18+
RSpec::Buildkite::Analytics.configure(token: ENV['BUILDKITE_ANALYTICS_TOKEN'])
1919

2020
# This module is only used to check the environment is currently a testing env
2121
module SpecHelper

0 commit comments

Comments
 (0)