Skip to content

Fix Rubocop violations #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 40 additions & 228 deletions .rubocop_todo.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ def self.available_options
description: 'The path of the .po file to update',
type: String,
verify_block: proc do |value|
UI.user_error!("No .po file path for UpdateMetadataSourceAction given, pass using `po_file_path: 'file path'`") unless value && (!value.empty?)
UI.user_error!("No .po file path for UpdateMetadataSourceAction given, pass using `po_file_path: 'file path'`") unless value && !value.empty?
UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :release_version,
env_name: 'FL_UPDATE_METADATA_SOURCE_RELEASE_VERSION',
description: 'The release version of the app (to use to mark the release notes)',
verify_block: proc do |value|
UI.user_error!("No relase version for UpdateMetadataSourceAction given, pass using `release_version: 'version'`") unless value && (!value.empty?)
UI.user_error!("No relase version for UpdateMetadataSourceAction given, pass using `release_version: 'version'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :source_files,
env_name: 'FL_UPDATE_METADATA_SOURCE_SOURCE_FILES',
description: 'The hash with the path to the source files and the key to use to include their content',
type: Hash,
verify_block: proc do |value|
UI.user_error!("No source file hash for UpdateMetadataSourceAction given, pass using `source_files: 'source file hash'`") unless value && (!value.empty?)
UI.user_error!("No source file hash for UpdateMetadataSourceAction given, pass using `source_files: 'source file hash'`") unless value && !value.empty?
end),
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.run(params)
source_diff = nil
if diff_url.nil? == false
data = open(params[:diff_url])
source_diff = data.read()
source_diff = data.read
end

any_error = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.run(params)
end

# Check local repo status
other_action.ensure_git_status_clean()
other_action.ensure_git_status_clean

# Return the current version
[next_beta_version, next_alpha_version]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def self.run(params)

UI.user_error!("Can't build beta and final at the same time!") if params[:final] && params[:beta]

Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci()
Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci

message = ''
beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version unless !params[:beta] && !params[:final]
Expand All @@ -26,7 +26,7 @@ def self.run(params)
end

# Check local repo status
other_action.ensure_git_status_clean() unless other_action.is_ci()
other_action.ensure_git_status_clean unless other_action.is_ci
end

#####################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def self.run(params)
Fastlane::Helper::Android::VersionHelper.update_versions(new_version_beta, new_version_alpha)
UI.message 'Done!'

Fastlane::Helper::Android::GitHelper.commit_version_bump()
Fastlane::Helper::Android::GitHelper.commit_version_bump
end

#####################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.run(params)
Fastlane::Helper::Android::VersionHelper.update_versions(final_version, current_version_alpha)
UI.message 'Done!'

Fastlane::Helper::Android::GitHelper.commit_version_bump()
Fastlane::Helper::Android::GitHelper.commit_version_bump
end

#####################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.run(params)
Fastlane::Helper::Android::VersionHelper.update_versions(new_version, nil)
UI.message 'Done!'

Fastlane::Helper::Android::GitHelper.commit_version_bump()
Fastlane::Helper::Android::GitHelper.commit_version_bump

UI.message 'Done.'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.run(params)

UI.message 'Updating app version...'
Fastlane::Helper::Android::VersionHelper.update_versions(new_version_beta, new_version_alpha)
Fastlane::Helper::Android::GitHelper.commit_version_bump()
Fastlane::Helper::Android::GitHelper.commit_version_bump
UI.message 'Done.'
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Fastlane
module Actions
class AndroidCodefreezePrechecksAction < Action
VERSION_RELEASE = 'release'
VERSION_ALPHA = 'alpha'
VERSION_RELEASE = 'release'.freeze
VERSION_ALPHA = 'alpha'.freeze

def self.run(params)
# fastlane will take care of reading in the parameter and fetching the environment variable:
Expand Down Expand Up @@ -33,7 +33,7 @@ def self.run(params)
end

# Check local repo status
other_action.ensure_git_status_clean()
other_action.ensure_git_status_clean

# Return the current version
Fastlane::Helper::Android::VersionHelper.get_public_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def self.run(params)

version = Fastlane::Helper::Android::VersionHelper.get_public_version
message = "Completing code freeze for: #{version}\n"
unless params[:skip_confirm]
UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?")
else
if params[:skip_confirm]
UI.message(message)
else
UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?")
end

# Check local repo status
other_action.ensure_git_status_clean()
other_action.ensure_git_status_clean

version
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def self.available_options
description: 'The download folder',
type: String,
optional: true,
default_value: Dir.tmpdir()),
default_value: Dir.tmpdir),
FastlaneCore::ConfigItem.new(key: :github_release_prefix,
description: 'The prefix which is used in the GitHub release title',
type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.run(params)

# Update submodules then lint translations
unless params[:lint_task].nil? || params[:lint_task].empty?
Fastlane::Helper::GitHelper.update_submodules()
Fastlane::Helper::GitHelper.update_submodules
Action.sh('./gradlew', params[:lint_task])
end

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

# Check local repo status
other_action.ensure_git_status_clean()
other_action.ensure_git_status_clean

version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.run(params)

# Log in to Firebase (and validate credentials)
run_uuid = params[:test_run_id] || SecureRandom.uuid
test_dir = params[:results_output_dir] || File.join(Dir.tmpdir(), run_uuid)
test_dir = params[:results_output_dir] || File.join(Dir.tmpdir, run_uuid)

# Set up the log file and output directory
FileUtils.mkdir_p(test_dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.run(params)
UI.crash!("Version #{prev_ver} is not tagged! Can't branch. Abort!") unless other_action.git_tag_exists(tag: prev_ver)

# Check local repo status
other_action.ensure_git_status_clean()
other_action.ensure_git_status_clean

# Return the current version
prev_ver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def self.available_options
type: Array,
optional: true,
# Default to Mag16.
default_value: 'ar de es fr he id it ja ko nl pt-br ru sv tr zh-cn zh-tw'.split()),
default_value: 'ar de es fr he id it ja ko nl pt-br ru sv tr zh-cn zh-tw'.split),
FastlaneCore::ConfigItem.new(key: :min_acceptable_translation_percentage,
env_name: 'FL_CHECK_TRANSLATION_PROGRESS_MIN_ACCEPTABLE_TRANSLATION_PERCENTAGE',
description: 'The threshold under which an error is raised',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.run(params)

milestone_duedate = last_stone[:due_on]
milestone_duration = params[:milestone_duration]
newmilestone_duedate = (milestone_duedate.to_datetime.next_day(milestone_duration).to_time).utc
newmilestone_duedate = milestone_duedate.to_datetime.next_day(milestone_duration).to_time.utc
newmilestone_number = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(last_stone[:title])
number_of_days_from_code_freeze_to_release = params[:number_of_days_from_code_freeze_to_release]
# Because of the app stores review process, we submit the binary 3 days before the intended release date.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.run(params)
end

unless extracted_notes_file.nil?
extracted_notes_file.close()
extracted_notes_file.close
check_and_commit_extracted_notes_file(extracted_notes_file_path, version)
end
end
Expand All @@ -25,9 +25,9 @@ def self.extract_notes(release_notes_file_path, version)
File.open(release_notes_file_path).each do |line|
case state
when :discarding
state = :evaluating if (line.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/)) && (line.strip() == version)
state = :evaluating if line.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/) && (line.strip == version)
when :evaluating
state = (line.match(/-/)) ? :extracting : :discarding
state = line.match(/-/) ? :extracting : :discarding
when :extracting
if line.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/)
state = :discarding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def self.run(params)
downloader.download(loc[1], complete_url, loc[1] == params[:source_locale])
end

if loc.is_a?(String)
UI.message "Downloading language: #{loc}"
complete_url = "#{params[:project_url]}#{loc}/default/export-translations/?filters[status]=current&format=json"
downloader.download(loc, complete_url, loc == params[:source_locale])
end
next unless loc.is_a?(String)

UI.message "Downloading language: #{loc}"
complete_url = "#{params[:project_url]}#{loc}/default/export-translations/?filters[status]=current&format=json"
downloader.download(loc, complete_url, loc == params[:source_locale])
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ def self.available_options
description: 'The path of the .po file to update',
type: String,
verify_block: proc do |value|
UI.user_error!("No .po file path for UpdateMetadataSourceAction given, pass using `po_file_path: 'file path'`") unless value && (!value.empty?)
UI.user_error!("No .po file path for UpdateMetadataSourceAction given, pass using `po_file_path: 'file path'`") unless value && !value.empty?
UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :release_version,
env_name: 'FL_UPDATE_METADATA_SOURCE_RELEASE_VERSION',
description: 'The release version of the app (to use to mark the release notes)',
verify_block: proc do |value|
UI.user_error!("No relase version for UpdateMetadataSourceAction given, pass using `release_version: 'version'`") unless value && (!value.empty?)
UI.user_error!("No relase version for UpdateMetadataSourceAction given, pass using `release_version: 'version'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :source_files,
env_name: 'FL_UPDATE_METADATA_SOURCE_SOURCE_FILES',
description: 'The hash with the path to the source files and the key to use to include their content',
type: Hash,
verify_block: proc do |value|
UI.user_error!("No source file hash for UpdateMetadataSourceAction given, pass using `source_files: 'source file hash'`") unless value && (!value.empty?)
UI.user_error!("No source file hash for UpdateMetadataSourceAction given, pass using `source_files: 'source file hash'`") unless value && !value.empty?
end),
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ def self.run(params)

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

translationDirectories = subdirectories_for_path(params[:metadata_folder])
imageDirectories = subdirectories_for_path(params[:orig_folder])
translation_directories = subdirectories_for_path(params[:metadata_folder])
image_directories = subdirectories_for_path(params[:orig_folder])

unless helper.can_resolve_path(params[:output_folder])
if helper.can_resolve_path(params[:output_folder])
UI.message "#{self.check_path(params[:output_folder])} Output Folder: #{params[:output_folder]}"
else
UI.message "✅ Created Output Folder: #{params[:output_folder]}"
FileUtils.mkdir_p(params[:output_folder])
else
UI.message "#{self.check_path(params[:output_folder])} Output Folder: #{params[:output_folder]}"
end

outputDirectory = helper.resolve_path(params[:output_folder])
output_directory = helper.resolve_path(params[:output_folder])

## If there are no translated screenshot images (whether it's because they haven't been generated yet,
## or because we aren't using them), just use the translated directories.
languages = if imageDirectories == []
translationDirectories
languages = if image_directories == []
translation_directories
## And vice-versa.
elsif translationDirectories == []
imageDirectories
elsif translation_directories == []
image_directories
## If there are original screenshots and translations available, use only locales that exist in both.
else
imageDirectories & translationDirectories
image_directories & translation_directories
end

UI.message("💙 Creating Promo Screenshots for: #{languages.join(', ')}")
Expand All @@ -49,7 +49,7 @@ def self.run(params)

stylesheet_path = config['stylesheet']

entries = build_entries(config['entries'], languages, outputDirectory, params)
entries = build_entries(config['entries'], languages, output_directory, params)

bar = ProgressBar.new(entries.count, :bar, :counter, :eta, :rate)

Expand Down Expand Up @@ -183,32 +183,32 @@ def self.build_entries(config_entries, languages, output_directory, params)
config_entries
.flat_map do |entry|
languages.map do |language|
newEntry = entry.deep_dup
new_entry = entry.deep_dup

# Not every output file will have a screenshot, so handle cases where no
# screenshot file is defined
if !entry['screenshot'].nil? && !entry['filename'].nil?
newEntry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
newEntry['filename'] = output_directory + language + entry['filename']
new_entry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
new_entry['filename'] = output_directory + language + entry['filename']
elsif !entry['screenshot'].nil? && entry['filename'].nil?
newEntry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
newEntry['filename'] = output_directory + language + entry['screenshot']
new_entry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
new_entry['filename'] = output_directory + language + entry['screenshot']
elsif entry['screenshot'].nil? && !entry['filename'].nil?
newEntry['filename'] = output_directory + language + entry['filename']
new_entry['filename'] = output_directory + language + entry['filename']
else
puts newEntry
puts new_entry
abort 'Unable to find output file names'
end

newEntry['locale'] = language
new_entry['locale'] = language

# Localize file paths for text
newEntry['text'].sub!('{locale}', language.dup) unless entry['text'].nil?
new_entry['text'].sub!('{locale}', language.dup) unless entry['text'].nil?

# Map attachments paths to their localized versions
newEntry['attachments'] = [] if newEntry['attachments'].nil?
new_entry['attachments'] = [] if new_entry['attachments'].nil?

newEntry['attachments'].each do |attachment|
new_entry['attachments'].each do |attachment|
## If there are no translated screenshot images (whether it's because they haven't been generated yet,
## or because we aren't using them), just use the translated directories.
## And vice-versa.
Expand Down Expand Up @@ -240,7 +240,7 @@ def self.build_entries(config_entries, languages, output_directory, params)
attachment['text']&.sub!('{locale}', language.dup)
end

newEntry
new_entry
end
end
.sort do |x, y|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def self.run(params)
UI.message("Uploading #{file_path} to: #{key}")

File.open(file_path, 'rb') do |file|
Aws::S3::Client.new().put_object(
Aws::S3::Client.new.put_object(
body: file,
bucket: bucket,
key: key
Expand All @@ -50,7 +50,7 @@ def self.run(params)
end

def self.file_is_already_uploaded?(bucket, key)
response = Aws::S3::Client.new().head_object(
response = Aws::S3::Client.new.head_object(
bucket: bucket,
key: key
)
Expand Down
Loading