Skip to content

Commit

Permalink
Update Rubocop to not allow Ruby 3.1 hash values and value arguments …
Browse files Browse the repository at this point in the history
…omission
  • Loading branch information
iangmaia committed Jan 30, 2024
1 parent 1269fc2 commit 2210f47
Show file tree
Hide file tree
Showing 79 changed files with 270 additions and 265 deletions.
7 changes: 6 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ Style/StringConcatenation:
# for more discussion
Style/FetchEnvVar:
Enabled: false


# Rule enforced after migrating to Ruby 3, to prevent the new syntax which allows for hash values and keyword arguments
# omission, such as `myMethod(x:, y:)` and `h = { a:, b: }`.
Style/HashSyntax:
EnforcedShorthandSyntax: never

########## Gemspec Rules

# This was turned on by default after updating Rubocop to `1.50.2`. We want to disable this for now because
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ task :new_release do
Console.header 'Update `VERSION` constant in `version.rb`...'
update_version_constant(VERSION_FILE, new_version)
Console.header 'Updating CHANGELOG...'
parser.update_for_new_release(new_version:)
parser.update_for_new_release(new_version: new_version)

# Commit and push
Console.header 'Commit and push changes...'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.run(params)

# Check user overwrite
unless params[:base_version].nil?
overwrite_version = get_user_build_version(version: params[:base_version], message:)
overwrite_version = get_user_build_version(version: params[:base_version], message: message)
release_version = overwrite_version[0]
alpha_release_version = overwrite_version[1]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def self.run(params)
helper.create_avd(
api: api_level,
device: device_model,
system_image:,
system_image: system_image,
name: avd_name,
sdcard:
sdcard: sdcard
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def self.run(params)
res_dir = File.join(project_root_folder || '.', params[:res_dir])

Fastlane::Helper::Android::LocalizeHelper.create_available_languages_file(
res_dir:,
res_dir: res_dir,
locale_codes: [params[:source_locale]] + params[:locales].map { |h| h[:android] }
)
Fastlane::Helper::Android::LocalizeHelper.download_from_glotpress(
res_dir:,
res_dir: res_dir,
glotpress_project_url: params[:glotpress_url],
glotpress_filters: params[:status_filter].map { |s| { status: s } },
locales_map: params[:locales]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def self.run(params)
project_id: params[:project_id],
apk_path: params[:apk_path],
test_apk_path: params[:test_apk_path],
device:,
device: device,
test_targets: params[:test_targets],
type: params[:type]
)

# Download all of the outputs from the job to the local machine
FirebaseTestRunner.download_result_files(
result:,
result: result,
destination: test_dir,
project_id: params[:project_id],
key_file_path: params[:key_file]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ def self.run(params)
unless params[:aab_path].nil?
generate_split_apks(aab_path: params[:aab_path]) do |apk|
split_name = File.basename(apk, '.apk')
add_apk_size_metrics(helper: metrics_helper, apkanalyzer_bin:, apk:, split_name:)
add_apk_size_metrics(helper: metrics_helper, apkanalyzer_bin: apkanalyzer_bin, apk: apk, split_name: split_name)
end
end
unless params[:universal_apk_path].nil?
add_apk_size_metrics(helper: metrics_helper, apkanalyzer_bin:, apk: params[:universal_apk_path], split_name: UNIVERSAL_APK_SPLIT_NAME)
add_apk_size_metrics(helper: metrics_helper, apkanalyzer_bin: apkanalyzer_bin, apk: params[:universal_apk_path], split_name: UNIVERSAL_APK_SPLIT_NAME)
end
end

# Send the payload
metrics_helper.send_metrics(
to: api_url,
api_token:,
api_token: api_token,
use_gzip: params[:use_gzip_content_encoding]
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.run(params)
path = params[:release_notes_file_path]
next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_short_version(params[:new_version])

Fastlane::Helper::ReleaseNotesHelper.add_new_section(path:, section_title: next_version)
Fastlane::Helper::ReleaseNotesHelper.add_new_section(path: path, section_title: next_version)
Fastlane::Helper::GitHelper.commit(message: "Release Notes: add new section for next version (#{next_version})", files: path)

UI.message 'Done.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def self.run(params)
else
# Add new annotation using `buildkite-agent`
extra_params = {
context:,
style:
context: context,
style: style
}.compact.flat_map { |k, v| ["--#{k}", v] }
sh('buildkite-agent', 'annotate', *extra_params, params[:message])
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.run(params)

unless under_threshold_langs.empty?
check_results(
under_threshold_langs:,
under_threshold_langs: under_threshold_langs,
threshold: params[:min_acceptable_translation_percentage],
skip_confirm: params[:skip_confirm]
)
Expand All @@ -37,7 +37,7 @@ def self.check_translations(glotpress_url:, language_codes:, abort_on_violations
under_threshold_langs = []

data = begin
Fastlane::Helper::GlotPressHelper.get_translation_status_data(glotpress_url:)
Fastlane::Helper::GlotPressHelper.get_translation_status_data(glotpress_url: glotpress_url)
rescue StandardError
nil
end
Expand All @@ -47,8 +47,8 @@ def self.check_translations(glotpress_url:, language_codes:, abort_on_violations
UI.message("> Getting translation status for #{language_code}")
progress = begin
Fastlane::Helper::GlotPressHelper.get_translation_status(
data:,
language_code:
data: data,
language_code: language_code
)
rescue StandardError
-1
Expand All @@ -60,7 +60,7 @@ def self.check_translations(glotpress_url:, language_codes:, abort_on_violations
end

UI.message("Language #{language_code} is #{progress}% translated.")
under_threshold_langs.push({ lang: language_code, progress: }) if progress < threshold
under_threshold_langs.push({ lang: language_code, progress: progress }) if progress < threshold
end

under_threshold_langs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.run(params)

UI.user_error!("Milestone #{milestone_title} not found.") if milestone.nil?

github_helper.update_milestone(repository:, number: milestone[:number], state: 'closed')
github_helper.update_milestone(repository: repository, number: milestone[:number], state: 'closed')
end

def self.description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.run(params)

response = begin
github_helper.get_branch_protection(
repository:,
repository: repository,
branch: from_branch
)
rescue Octokit::NotFound
Expand All @@ -24,7 +24,7 @@ def self.run(params)

response = begin
github_helper.set_branch_protection(
repository:,
repository: repository,
branch: to_branch,
**settings
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def self.run(params)
UI.message("Next milestone: #{newmilestone_number} due on #{newmilestone_duedate}.")

github_helper.create_milestone(
repository:,
repository: repository,
title: newmilestone_number,
due_date: newmilestone_duedate,
days_until_submission:,
days_until_submission: days_until_submission,
days_until_release: number_of_days_from_code_freeze_to_release
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def self.run(params)

github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
url = github_helper.create_release(
repository:,
version:,
repository: repository,
version: version,
target: params[:target],
description: release_notes,
assets:,
prerelease:,
is_draft:
assets: assets,
prerelease: prerelease,
is_draft: is_draft
)
UI.success("Successfully created GitHub Release. You can see it at '#{url}'")
url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def self.run(params)
github_helper = Fastlane::Helper::GithubHelper.new(github_token: gh_token)
changelog = begin
github_helper.generate_release_notes(
repository:,
tag_name:,
previous_tag:,
target_commitish:,
config_file_path:
repository: repository,
tag_name: tag_name,
previous_tag: previous_tag,
target_commitish: target_commitish,
config_file_path: config_file_path
)
rescue StandardError => e
error_msg = "❌ Error computing the list of PRs since #{previous_tag || 'last release'}: `#{e.message}`"
Expand All @@ -31,7 +31,7 @@ def self.run(params)
previous_release_link = if previous_tag.nil?
'last release'
else
link = github_helper.get_release_url(repository:, tag_name: previous_tag)
link = github_helper.get_release_url(repository: repository, tag_name: previous_tag)
"[#{previous_tag}](#{link})"
end
changelog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.run(params)

config = helper.read_config(params[:config_file])

helper.check_fonts_installed!(config:) unless params[:skip_font_check]
helper.check_fonts_installed!(config: config) unless params[:skip_font_check]

translation_directories = subdirectories_for_path(params[:metadata_folder])
image_directories = subdirectories_for_path(params[:orig_folder])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.run(params)

github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
github_helper.remove_branch_protection(
repository:,
repository: repository,
branch: branch_name
)
rescue Octokit::NotFound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.run(params)

settings = if params[:keep_existing_settings_unchanged]
Fastlane::Helper::GithubHelper.branch_protection_api_response_to_normalized_hash(
github_helper.get_branch_protection(repository:, branch: branch_name)
github_helper.get_branch_protection(repository: repository, branch: branch_name)
)
else
{}
Expand Down Expand Up @@ -58,7 +58,7 @@ def self.run(params)

# API Call - See https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection
response = github_helper.set_branch_protection(
repository:,
repository: repository,
branch: branch_name,
**settings
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.run(params)
end

UI.message("New milestone: #{mile_title}")
github_helper.update_milestone(repository:, number: milestone[:number], title: mile_title)
github_helper.update_milestone(repository: repository, number: milestone[:number], title: mile_title)
end

def self.is_frozen(milestone)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def self.run(params)
File.open(file_path, 'rb') do |file|
Aws::S3::Client.new.put_object(
body: file,
bucket:,
key:
bucket: bucket,
key: key
)
rescue Aws::S3::Errors::ServiceError => e
UI.crash!("Unable to upload file to S3: #{e.message}")
Expand All @@ -58,8 +58,8 @@ def self.run(params)

def self.file_is_already_uploaded?(bucket, key)
response = Aws::S3::Client.new.head_object(
bucket:,
key:
bucket: bucket,
key: key
)
response[:content_length].positive?
rescue Aws::S3::Errors::NotFound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def self.add_file

encrypt = UI.confirm('Encrypt file?:')

Fastlane::Helper::ConfigureHelper.add_file(source:, destination:, encrypt:)
Fastlane::Helper::ConfigureHelper.add_file(source: source, destination: destination, encrypt: encrypt)
end

def self.secret_store_dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.run(params)
project_url: params[:project_url],
locale: glotpress_locale,
filters: params[:filters],
destination:
destination: destination
)
# Do a quick check of the downloaded `.strings` file to ensure it looks valid
validate_strings_file(destination) unless params[:skip_file_validation]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.run(params)

Fastlane::Helper::GitHelper.create_tag(version)

other_action.ios_clear_intermediate_tags(version:)
other_action.ios_clear_intermediate_tags(version: version)
end

#####################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def self.run(params)

case params[:format]
when 'csv'
csv = Helper.format_csv(app_sizes, devices:)
csv = Helper.format_csv(app_sizes, devices: devices)
UI.message "Result (CSV)\n\n#{csv}\n"
when 'markdown'
tables = Helper.format_markdown(app_sizes, devices:)
tables = Helper.format_markdown(app_sizes, devices: devices)
tables.each do |table|
UI.message "Result (Markdown)\n\n#{table}\n"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.run(params)
end
end

report(violations:, base_lang: params[:base_lang])
report(violations: violations, base_lang: params[:base_lang])
break unless !violations.empty? && params[:allow_retry] && UI.confirm(RETRY_MESSAGE)
end

Expand Down Expand Up @@ -53,7 +53,7 @@ def self.find_duplicated_keys(params)
language = File.basename(File.dirname(file), '.lproj')
path = File.join(params[:input_dir], file)

file_type = Fastlane::Helper::Ios::L10nHelper.strings_file_type(path:)
file_type = Fastlane::Helper::Ios::L10nHelper.strings_file_type(path: path)
if file_type == :text
duplicates = Fastlane::Helper::Ios::StringsFileValidationHelper.find_duplicated_keys(file: path)
duplicate_keys[language] = duplicates.map { |key, value| "`#{key}` was found at multiple lines: #{value.join(', ')}" } unless duplicates.empty?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.run(params)
# Send the payload
metrics_helper.send_metrics(
to: api_url,
api_token:,
api_token: api_token,
use_gzip: params[:use_gzip_content_encoding]
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.run(params)
path = params[:release_notes_file_path]
next_version = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(params[:new_version])

Fastlane::Helper::ReleaseNotesHelper.add_new_section(path:, section_title: next_version)
Fastlane::Helper::ReleaseNotesHelper.add_new_section(path: path, section_title: next_version)
Fastlane::Helper::GitHelper.commit(message: "Release Notes: add new section for next version (#{next_version})", files: path)

UI.message 'Done.'
Expand Down
Loading

0 comments on commit 2210f47

Please sign in to comment.