diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3028fd84b..1815e4a30 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,65 +1,35 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-06-02 19:47:56 UTC using RuboCop version 1.15.0. +# on 2023-06-14 05:10:53 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 32 -Lint/IneffectiveAccessModifier: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb' - # Offense count: 3 Lint/NonLocalExitFromIterator: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb' -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. -Lint/UselessAccessModifier: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb' - -# Offense count: 6 +# Offense count: 5 Lint/UselessAssignment: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' -# Offense count: 9 +# Offense count: 8 Naming/AccessorMethodName: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb' - - 'spec/spec_helper.rb' # Offense count: 19 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb' @@ -69,7 +39,7 @@ Naming/MethodParameterName: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' -# Offense count: 95 +# Offense count: 111 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. # NamePrefix: is_, has_, have_ # ForbiddenPrefixes: is_, has_, have_ @@ -78,23 +48,10 @@ Naming/MethodParameterName: Naming/PredicateName: Enabled: false -# Offense count: 78 -# Configuration parameters: EnforcedStyle, AllowedIdentifiers. -# SupportedStyles: snake_case, camelCase -Naming/VariableName: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' - - 'spec/android_merge_translators_strings_spec.rb' - - 'spec/ios_merge_translators_strings_spec.rb' - # Offense count: 2 -# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer -# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 Naming/VariableNumber: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb' @@ -108,28 +65,14 @@ RSpec/ContextWording: - 'spec/git_helper_spec.rb' - 'spec/ios_lint_localizations_spec.rb' -# Offense count: 35 -# Cop supports --auto-correct. -# Configuration parameters: SkipBlocks, EnforcedStyle. -# SupportedStyles: described_class, explicit -RSpec/DescribedClass: - Exclude: - - 'spec/ci_helper_spec.rb' - - 'spec/configuration_spec.rb' - - 'spec/encryption_helper_spec.rb' - - 'spec/file_reference_spec.rb' - - 'spec/git_helper_spec.rb' - - 'spec/ios_lint_localizations_spec.rb' - -# Offense count: 12 +# Offense count: 39 # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. # Include: **/*_spec*rb*, **/spec/**/* RSpec/FilePath: - Exclude: - - 'spec/*_spec.rb' + Enabled: false # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example RSpec/HookArgument: @@ -140,40 +83,24 @@ RSpec/HookArgument: - 'spec/git_helper_spec.rb' - 'spec/ios_lint_localizations_spec.rb' -# Offense count: 3 -# Cop supports --auto-correct. -RSpec/HooksBeforeExamples: - Exclude: - - 'spec/android_merge_translators_strings_spec.rb' - - 'spec/ios_lint_localizations_spec.rb' - - 'spec/ios_merge_translators_strings_spec.rb' - # Offense count: 25 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: - - 'spec/android_merge_translators_strings_spec.rb' - 'spec/git_helper_spec.rb' - 'spec/ios_lint_localizations_spec.rb' - - 'spec/ios_merge_translators_strings_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -RSpec/LeadingSubject: - Exclude: - - 'spec/configuration_spec.rb' - -# Offense count: 24 +# Offense count: 89 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 26 +# Offense count: 88 RSpec/MultipleExpectations: Max: 7 -# Offense count: 43 +# Offense count: 48 # Configuration parameters: IgnoreSharedExamples. RSpec/NamedSubject: Exclude: @@ -182,7 +109,7 @@ RSpec/NamedSubject: - 'spec/configuration_spec.rb' - 'spec/file_reference_spec.rb' -# Offense count: 6 +# Offense count: 8 RSpec/NestedGroups: Max: 5 @@ -204,16 +131,13 @@ RSpec/VerifiedDoubles: - 'spec/encryption_helper_spec.rb' - 'spec/spec_helper.rb' -# Offense count: 5 +# Offense count: 2 Security/Open: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_xml_release_notes.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' - - 'spec/android_merge_translators_strings_spec.rb' - - 'spec/ios_merge_translators_strings_spec.rb' -# Offense count: 102 +# Offense count: 126 # Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false @@ -224,8 +148,9 @@ Style/GlobalVars: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' -# Offense count: 11 -# Configuration parameters: MinBodyLength. +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb' @@ -234,39 +159,6 @@ Style/GuardClause: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowIfModifier. -Style/IfInsideElse: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -Style/KeywordParametersOrder: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb' - - 'rakelib/changelog_parser.rake' - -# Offense count: 92 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -Style/MethodCallWithoutArgsParentheses: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline -Style/MethodDefParentheses: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb' # Offense count: 1 Style/MixinUsage: @@ -280,35 +172,9 @@ Style/MultilineBlockChain: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb' -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: literals, strict -Style/MutableConstant: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/version.rb' - - 'spec/release_notes_helper_spec.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinBodyLength. -# SupportedStyles: skip_modifier_ifs, always -Style/Next: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_merge_translators_strings.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_merge_translators_strings.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb' - # Offense count: 23 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IgnoredMethods. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: @@ -326,32 +192,19 @@ Style/NumericPredicate: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' -# Offense count: 15 -# Cop supports --auto-correct. -Style/RedundantParentheses: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb' - -# Offense count: 49 -# Cop supports --auto-correct. +# Offense count: 54 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Enabled: false -# Offense count: 39 -# Cop supports --auto-correct. +# Offense count: 37 +# This cop supports safe autocorrection (--autocorrect). Style/RedundantSelf: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb' @@ -362,11 +215,9 @@ Style/RedundantSelf: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/models/configuration.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb' - - 'spec/android_merge_translators_strings_spec.rb' - - 'spec/ios_merge_translators_strings_spec.rb' # Offense count: 6 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RescueModifier: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb' @@ -376,8 +227,8 @@ Style/RescueModifier: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb' -# Offense count: 12 -# Cop supports --auto-correct. +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit Style/RescueStandardError: @@ -391,24 +242,15 @@ Style/RescueStandardError: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb' # Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb' -# Offense count: 9 -# Cop supports --auto-correct. -Style/SelfAssignment: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb' - # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: only_raise, only_fail, semantic Style/SignalException: @@ -416,15 +258,15 @@ Style/SignalException: - 'Dangerfile' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: use_perl_names, use_english_names +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: RequireEnglish, EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names Style/SpecialGlobalVars: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb' -# Offense count: 4 -# Cop supports --auto-correct. +# Offense count: 28 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: . # SupportedStyles: percent, brackets Style/SymbolArray: @@ -432,9 +274,9 @@ Style/SymbolArray: MinSize: 3 # Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods. -# IgnoredMethods: respond_to, define_method +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. +# AllowedMethods: define_method Style/SymbolProc: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb' @@ -442,33 +284,3 @@ Style/SymbolProc: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/models/configuration.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex -Style/TernaryParentheses: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Style/UnlessElse: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -Style/ZeroLengthPredicate: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb' - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb' - -Style/ClassVars: - Exclude: - - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb index dce29cd73..7f2e7cc85 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb index 528b6e64c..c94e7ff8f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index 0fc2ee3dc..c2ab05d83 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -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] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 972db99e2..c0252445f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -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] @@ -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 ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 7e11f6d47..253c49551 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -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 ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index a208fbabc..a48f02844 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -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 ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 389feaad1..d007a5c17 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 000fb8ea9..2cc4ca59c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index 2cc6d28bf..061e8e397 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -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: @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index bfdeed586..e14be6396 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb index 6dbbc8762..10b5e04f3 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb @@ -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, diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb index 23840ae33..49bbf81b4 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index 3d67342f2..9100cbd10 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb index 0b0bb5998..2aa2c98c5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb @@ -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) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb index 6f22e6fae..11a697319 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb index 059d31398..ff0a092b4 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb @@ -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', diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb index d981603f6..505814e22 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb @@ -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. diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb index 2b3e6a003..9659a6611 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb @@ -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 @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb index 2de44300b..746423d0e 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb index d1d6bb24a..b3e6663f6 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb index 7c12920ba..4488ee69b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb @@ -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(', ')}") @@ -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) @@ -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. @@ -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| diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb index b249ad18a..a7871ee83 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb @@ -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 @@ -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 ) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb index 51bed164f..dd2a44ecc 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb @@ -40,13 +40,13 @@ def self.add_file UI.message 'Example: google-services.json' source = UI.input('Source File Path:') - sourcePath = absolute_secret_store_path(source) # Transform the relative path into an absolute path. + source_path = absolute_secret_store_path(source) # Transform the relative path into an absolute path. # Don't allow the developer to accidentally specify an invalid file, otherwise validation will never succeed. - if File.file?(sourcePath) + if File.file?(source_path) invalid_file = false else - UI.error "There is no file at #{sourcePath}." + UI.error "There is no file at #{source_path}." end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb index 5bb9fdd57..d91aef04f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb @@ -9,10 +9,10 @@ def self.run(params = {}) UI.message 'Running Configure Download' # If the `~/.mobile-secrets` repository doesn't exist - unless File.directory?(secrets_dir) - UI.user_error!("The local secrets store does not exist. Please clone it to #{secrets_dir} before continuing.") - else + if File.directory?(secrets_dir) update_repository # If the repo already exists, just update it + else + UI.user_error!("The local secrets store does not exist. Please clone it to #{secrets_dir} before continuing.") end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb index 97a6a45c7..2ec745ca8 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb @@ -50,8 +50,8 @@ def self.prompt_to_switch_branches new_branch = UI.select("Select the branch you'd like to switch to: ", get_branches) checkout_branch(new_branch) update_configure_file - else - UI.user_error!('The local secrets store is in a deatched HEAD state. Please check out a branch and try again.') if current_branch.nil? + elsif current_branch.nil? + UI.user_error!('The local secrets store is in a deatched HEAD state. Please check out a branch and try again.') end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb index aa6efebd4..02139bea7 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb @@ -91,10 +91,10 @@ def self.validate_that_all_copied_files_match source = absolute_secret_store_path(x.file) destination = absolute_project_path(x.destination) - sourceHash = file_hash(source) - destinationHash = file_hash(destination) + source_hash = file_hash(source) + destination_hash = file_hash(destination) - UI.user_error!("`#{x.destination} doesn't match the file in the secrets repository (#{x.file}) – unable to continue") unless sourceHash == destinationHash + UI.user_error!("`#{x.destination} doesn't match the file in the secrets repository (#{x.file}) – unable to continue") unless source_hash == destination_hash end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb index 5da8a9be6..21e72331a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb @@ -17,7 +17,7 @@ def self.run(params) profile.is_a? Spaceship::Portal::ProvisioningProfile::Development end .tap do |profiles| - UI.important "Warning: Unable to find any profiles associated with #{identifier}" unless profiles.length > 0 + UI.important "Warning: Unable to find any profiles associated with #{identifier}" if profiles.empty? end .each do |profile| profile.certificates = all_certificates @@ -51,7 +51,7 @@ def self.available_options description: 'The team_id for the provisioning profiles', type: String, verify_block: proc do |value| - UI.user_error!('You must provide a team ID in `team_id`') unless value && (!value.empty?) + UI.user_error!('You must provide a team ID in `team_id`') unless value && !value.empty? end), ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb index 2390b4308..f3613fef0 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb @@ -15,7 +15,7 @@ def self.run(params) profile.is_a? Spaceship::Portal::ProvisioningProfile::Development end .tap do |profiles| - UI.important "Warning: Unable to find any profiles associated with #{identifier}" unless profiles.length > 0 + UI.important "Warning: Unable to find any profiles associated with #{identifier}" if profiles.empty? end .each do |profile| profile.devices = devices @@ -52,7 +52,7 @@ def self.available_options description: 'The team_id for the provisioning profiles', type: String, verify_block: proc do |value| - UI.user_error!('You must provide a team ID in `team_id`') unless value && (!value.empty?) + UI.user_error!('You must provide a team ID in `team_id`') unless value && !value.empty? end ), ] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb index 41f0f9379..30aad64a6 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb @@ -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 build_version diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb index b05d93cbe..c259c93e5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb @@ -5,9 +5,9 @@ def self.run(params) require_relative '../../helper/ios/ios_version_helper' message = '' - message << "Building version #{Fastlane::Helper::Ios::VersionHelper.get_internal_version()} and uploading to App Center\n" if params[:internal] - message << "Building version #{Fastlane::Helper::Ios::VersionHelper.get_build_version()} and uploading to App Center\n" if params[:internal_on_single_version] - message << "Building version #{Fastlane::Helper::Ios::VersionHelper.get_build_version()} and uploading to TestFlight\n" if params[:external] + message << "Building version #{Fastlane::Helper::Ios::VersionHelper.get_internal_version} and uploading to App Center\n" if params[:internal] + message << "Building version #{Fastlane::Helper::Ios::VersionHelper.get_build_version} and uploading to App Center\n" if params[:internal_on_single_version] + message << "Building version #{Fastlane::Helper::Ios::VersionHelper.get_build_version} and uploading to TestFlight\n" if params[:external] if params[:skip_confirm] UI.message(message) @@ -16,7 +16,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 ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb index 7a28fdd3d..a11b8abf3 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb @@ -33,7 +33,7 @@ def self.run(params) raise end - other_action.cocoapods() + other_action.cocoapods end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb index f6228c9f9..35901dd76 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb @@ -8,8 +8,8 @@ def self.run(params) require_relative '../../helper/ios/ios_version_helper' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - create_config() - show_config() + create_config + show_config UI.message 'Updating XcConfig...' Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_beta_version, @short_version, @new_internal_version) @@ -47,11 +47,9 @@ def self.is_supported?(platform) [:ios, :mac].include?(platform) end - private - def self.create_config - @current_version = Fastlane::Helper::Ios::VersionHelper.get_build_version() - @current_version_internal = Fastlane::Helper::Ios::VersionHelper.get_internal_version() unless ENV['INTERNAL_CONFIG_FILE'].nil? + @current_version = Fastlane::Helper::Ios::VersionHelper.get_build_version + @current_version_internal = Fastlane::Helper::Ios::VersionHelper.get_internal_version unless ENV['INTERNAL_CONFIG_FILE'].nil? @new_internal_version = Fastlane::Helper::Ios::VersionHelper.create_internal_version(@current_version) unless ENV['INTERNAL_CONFIG_FILE'].nil? @new_beta_version = Fastlane::Helper::Ios::VersionHelper.calc_next_build_version(@current_version) @short_version = Fastlane::Helper::Ios::VersionHelper.get_short_version_string(@new_beta_version) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb index d185b919c..6bea893e7 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb @@ -7,7 +7,7 @@ def self.run(params) require_relative '../../helper/ios/ios_git_helper' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version]}", from: params[:previous_version]) create_config(params[:previous_version], params[:version]) - show_config() + show_config update_deliverfile = params[:skip_deliver] == false if update_deliverfile @@ -78,11 +78,9 @@ def self.is_supported?(platform) [:ios, :mac].include?(platform) end - private - def self.create_config(previous_version, new_short_version) @current_version = previous_version - @current_version_internal = Fastlane::Helper::Ios::VersionHelper.get_internal_version() unless ENV['INTERNAL_CONFIG_FILE'].nil? + @current_version_internal = Fastlane::Helper::Ios::VersionHelper.get_internal_version unless ENV['INTERNAL_CONFIG_FILE'].nil? @new_version = "#{new_short_version}.0" @new_version_internal = Fastlane::Helper::Ios::VersionHelper.create_internal_version(@new_version) unless ENV['INTERNAL_CONFIG_FILE'].nil? @new_short_version = new_short_version diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb index 2cddf478f..fb70e44dc 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb @@ -12,9 +12,9 @@ def self.run(params) other_action.ensure_git_branch(branch: default_branch) # Create new configuration - @new_version = Fastlane::Helper::Ios::VersionHelper.bump_version_release() - create_config() - show_config() + @new_version = Fastlane::Helper::Ios::VersionHelper.bump_version_release + create_config + show_config # Update local default branch and create branch from it Fastlane::Helper::GitHelper.checkout_and_pull(default_branch) @@ -78,11 +78,9 @@ def self.is_supported?(platform) [:ios, :mac].include?(platform) end - private - def self.create_config - @current_version = Fastlane::Helper::Ios::VersionHelper.get_build_version() - @current_version_internal = Fastlane::Helper::Ios::VersionHelper.get_internal_version() unless ENV['INTERNAL_CONFIG_FILE'].nil? + @current_version = Fastlane::Helper::Ios::VersionHelper.get_build_version + @current_version_internal = Fastlane::Helper::Ios::VersionHelper.get_internal_version unless ENV['INTERNAL_CONFIG_FILE'].nil? @new_version_internal = Fastlane::Helper::Ios::VersionHelper.create_internal_version(@new_version) unless ENV['INTERNAL_CONFIG_FILE'].nil? @new_short_version = Fastlane::Helper::Ios::VersionHelper.get_short_version_string(@new_version) @new_release_branch = "release/#{@new_short_version}" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb index 3c7102542..292610d7c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb @@ -23,7 +23,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 current_version diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb index cefefc1cd..f294aafdd 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb @@ -20,7 +20,7 @@ def self.run(params) end # Check local repo status - other_action.ensure_git_status_clean() + other_action.ensure_git_status_clean version end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb index 5309b8254..a1168b257 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb @@ -20,7 +20,7 @@ def self.run(params) end # Check local repo status - other_action.ensure_git_status_clean() + other_action.ensure_git_status_clean version end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb index d93a86b1a..ca13b32c9 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb @@ -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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb index c8e43a910..25d8b8a49 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb @@ -68,7 +68,7 @@ def self.find_duplicated_keys(params) duplicate_keys end - RETRY_MESSAGE = <<~MSG + RETRY_MESSAGE = <<~MSG.freeze Inconsistencies found during Localization linting. You need to fix them before continuing. From this point on, you should either: @@ -91,7 +91,7 @@ def self.find_duplicated_keys(params) Did you fix the `.strings` files locally and want to lint them again? MSG - ABORT_MESSAGE = <<~MSG + ABORT_MESSAGE = <<~MSG.freeze Inconsistencies found during Localization linting. Aborting. MSG diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb index 4c30e07c3..d5259b89c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb @@ -5,8 +5,8 @@ def self.run(params) UI.message 'Updating project localisation...' require_relative '../../helper/ios/ios_git_helper' - other_action.cocoapods() - Fastlane::Helper::Ios::GitHelper.localize_project() + other_action.cocoapods + Fastlane::Helper::Ios::GitHelper.localize_project UI.message 'Done.' end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb index 4c427426a..0a662059b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb @@ -5,8 +5,8 @@ def self.run(params) require_relative '../../helper/ios/ios_version_helper' require_relative '../../helper/ios/ios_git_helper' - itc_ver = Fastlane::Helper::Ios::VersionHelper.get_build_version() - int_ver = Fastlane::Helper::Ios::VersionHelper.get_internal_version() unless ENV['INTERNAL_CONFIG_FILE'].nil? + itc_ver = Fastlane::Helper::Ios::VersionHelper.get_build_version + int_ver = Fastlane::Helper::Ios::VersionHelper.get_internal_version unless ENV['INTERNAL_CONFIG_FILE'].nil? Fastlane::Helper::GitHelper.create_tag(itc_ver) Fastlane::Helper::GitHelper.create_tag(int_ver) unless int_ver.nil? end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb index 996671246..f6a27d9b2 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb @@ -4,7 +4,7 @@ class IosUpdateMetadataAction < Action def self.run(params) require_relative '../../helper/ios/ios_git_helper' - Fastlane::Helper::Ios::GitHelper.update_metadata() + Fastlane::Helper::Ios::GitHelper.update_metadata end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb index 69f50bc77..988d01e93 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb @@ -3,7 +3,7 @@ module Actions class IosUpdateMetadataSourceAction < Action def self.run(params) # Check local repo status - other_action.ensure_git_status_clean() + other_action.ensure_git_status_clean other_action.gp_update_metadata_source(po_file_path: params[:po_file_path], source_files: params[:source_files], @@ -43,21 +43,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_IOS_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_IOS_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 diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb index 998f9757d..d6e5dfa90 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb @@ -5,8 +5,8 @@ def self.run(params) require_relative '../../helper/ios/ios_git_helper' require_relative '../../helper/ios/ios_version_helper' - version = Fastlane::Helper::Ios::VersionHelper.get_public_version() - head_tags = Fastlane::Helper::GitHelper.list_tags_on_current_commit() + version = Fastlane::Helper::Ios::VersionHelper.get_public_version + head_tags = Fastlane::Helper::GitHelper.list_tags_on_current_commit UI.user_error!('HEAD is not on tag. Aborting!') if head_tags.empty? return head_tags.include?(version) # Current commit is tagged with "version" tag diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb index 253b6a339..cb9b5630a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb @@ -83,7 +83,7 @@ def generate_keys(release_version) version_minor = Integer(values[1]) @new_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}" - version_major = version_major - 1 if version_minor == 0 + version_major -= 1 if version_minor == 0 version_minor = version_minor == 0 ? 9 : version_minor - 1 @keep_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb index a9261b7fc..035c6ffa9 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb @@ -54,30 +54,29 @@ def self.merge_string_node(main_strings_xml, library, lib_string_node) # Search for the string in the main file result = :added main_strings_xml.xpath('//string').each do |main_string_node| - if main_string_node.attr('name') == string_name - # Skip if the string has the content_override tag - return :skipped if skip_string_by_tag?(main_string_node) - - # If nodes are equivalent, skip - return :found if lib_string_node =~ main_string_node - - # The string needs an update - if main_string_node.attr('tools:ignore').nil? - # No `tools:ignore` attribute; completely replace existing main string node with lib's one - add_xml_attributes!(lib_string_node, library) - main_string_node.replace lib_string_node - else - # Has the `tools:ignore` flag; update the content without touching the other existing attributes - add_xml_attributes!(main_string_node, library) - main_string_node.content = string_content - end - return :updated + next unless main_string_node.attr('name') == string_name + # Skip if the string has the content_override tag + return :skipped if skip_string_by_tag?(main_string_node) + + # If nodes are equivalent, skip + return :found if lib_string_node =~ main_string_node + + # The string needs an update + if main_string_node.attr('tools:ignore').nil? + # No `tools:ignore` attribute; completely replace existing main string node with lib's one + add_xml_attributes!(lib_string_node, library) + main_string_node.replace lib_string_node + else + # Has the `tools:ignore` flag; update the content without touching the other existing attributes + add_xml_attributes!(main_string_node, library) + main_string_node.content = string_content end + return :updated end # String not found, or removed because needing update and not in the exclusion list: add to the main file add_xml_attributes!(lib_string_node, library) - main_strings_xml.xpath('//string').last().add_next_sibling("\n#{' ' * 4}#{lib_string_node.to_xml().strip}") + main_strings_xml.xpath('//string').last.add_next_sibling("\n#{' ' * 4}#{lib_string_node.to_xml.strip}") return result end @@ -91,14 +90,13 @@ def self.verify_string(main_strings_xml, library, lib_string_node) # Search for the string in the main file main_strings_xml.xpath('//string').each do |main_string_node| - if main_string_node.attr('name') == string_name - # Skip if the string has the content_override tag - return if skip_string_by_tag?(main_string_node) + next unless main_string_node.attr('name') == string_name + # Skip if the string has the content_override tag + return if skip_string_by_tag?(main_string_node) - # Check if up-to-date - UI.user_error!("String #{string_name} [#{string_content}] has been updated in the main file but not in the library #{library[:library]}.") if main_string_node.content != string_content - return - end + # Check if up-to-date + UI.user_error!("String #{string_name} [#{string_content}] has been updated in the main file but not in the library #{library[:library]}.") if main_string_node.content != string_content + return end # String not found and not in the exclusion list @@ -133,14 +131,14 @@ def self.merge_lib(main, library) case res when :updated UI.verbose "#{string_node.attr('name')} updated." - updated_count = updated_count + 1 + updated_count += 1 when :found - untouched_count = untouched_count + 1 + untouched_count += 1 when :added UI.verbose "#{string_node.attr('name')} added." - added_count = added_count + 1 + added_count += 1 when :skipped - skipped_count = skipped_count + 1 + skipped_count += 1 else UI.user_error!("Internal Error! #{res}") end @@ -180,22 +178,22 @@ def self.verify_lib(main, library, source_diff) def self.verify_local_diff(main, library, main_strings, lib_strings) `git diff #{main}`.each_line do |line| - if line.start_with?('+ ') || line.start_with?('- ') - diffs = line.gsub(/\s+/m, ' ').strip.split - diffs.each do |diff| - verify_diff(diff, main_strings, lib_strings, library) - end + next unless line.start_with?('+ ') || line.start_with?('- ') + + diffs = line.gsub(/\s+/m, ' ').strip.split + diffs.each do |diff| + verify_diff(diff, main_strings, lib_strings, library) end end end def self.verify_pr_diff(main, library, main_strings, lib_strings, source_diff) source_diff.each_line do |line| - if line.start_with?('+ ') || line.start_with?('- ') - diffs = line.gsub(/\s+/m, ' ').strip.split - diffs.each do |diff| - verify_diff(diff, main_strings, lib_strings, library) - end + next unless line.start_with?('+ ') || line.start_with?('- ') + + diffs = line.gsub(/\s+/m, ' ').strip.split + diffs.each do |diff| + verify_diff(diff, main_strings, lib_strings, library) end end end @@ -234,7 +232,7 @@ def self.create_available_languages_file(res_dir:, locale_codes:) # An array of locales to download. Each item in the array must be a Hash # with keys `:glotpress` and `:android` containing the respective locale codes. # - def self.download_from_glotpress(res_dir:, glotpress_project_url:, glotpress_filters: { status: 'current' }, locales_map:) + def self.download_from_glotpress(res_dir:, glotpress_project_url:, locales_map:, glotpress_filters: { status: 'current' }) glotpress_filters = [glotpress_filters] unless glotpress_filters.is_a?(Array) attributes_to_copy = %w[formatted] # Attributes that we want to replicate into translated `string.xml` files diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 8c0802a5b..f65c1ed76 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -5,9 +5,9 @@ module Android # module VersionHelper # The key used in internal version Hash objects to hold the versionName value - VERSION_NAME = 'name' + VERSION_NAME = 'name'.freeze # The key used in internal version Hash objects to hold the versionCode value - VERSION_CODE = 'code' + VERSION_CODE = 'code'.freeze # The index for the major version number part MAJOR_NUMBER = 0 # The index for the minor version number part @@ -15,9 +15,9 @@ module VersionHelper # The index for the hotfix version number part HOTFIX_NUMBER = 2 # The prefix used in front of the versionName for alpha versions - ALPHA_PREFIX = 'alpha-' + ALPHA_PREFIX = 'alpha-'.freeze # The suffix used in the versionName for RC (beta) versions - RC_SUFFIX = '-rc' + RC_SUFFIX = '-rc'.freeze # Returns the public-facing version string. # @@ -43,7 +43,7 @@ def self.get_public_version # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version - return get_version_from_properties() if File.exist?(version_properties_file) + return get_version_from_properties if File.exist?(version_properties_file) section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' gradle_path = self.gradle_path @@ -145,7 +145,7 @@ def self.calc_final_release_version(beta_version, alpha_version) def self.calc_next_alpha_version(version, alpha_version) # Bump alpha name alpha_number = alpha_version[VERSION_NAME].sub(ALPHA_PREFIX, '') - alpha_name = "#{ALPHA_PREFIX}#{alpha_number.to_i() + 1}" + alpha_name = "#{ALPHA_PREFIX}#{alpha_number.to_i + 1}" # Bump alpha code alpha_code = version[VERSION_CODE] + 1 @@ -349,7 +349,6 @@ def self.get_library_version_from_gradle_config(import_key:) end #---------------------------------------- - private # Remove the beta suffix (part after the `-`) from a version string # @@ -449,8 +448,8 @@ def self.get_keyword_from_gradle_file(file_path, section, keyword) file.each_line do |line| if found_section return line.split[1] if line.include?(keyword) && !line.include?("\"#{keyword}\"") && !line.include?("P#{keyword}") - else - found_section = true if line.include?(section) + elsif line.include?(section) + found_section = true end end end @@ -490,13 +489,13 @@ def self.update_version(version, section) if line.include?('versionName') && !line.include?('"versionName"') && !line.include?('PversionName') version_name = line.split[1].tr('\"', '') line.sub!(version_name, version[VERSION_NAME].to_s) - version_updated = version_updated + 1 + version_updated += 1 end if line.include? 'versionCode' version_code = line.split[1] line.sub!(version_code, version[VERSION_CODE].to_s) - version_updated = version_updated + 1 + version_updated += 1 end end temp_file.puts line diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb index caf0a3493..0ab9c6ef1 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb @@ -72,7 +72,7 @@ def self.update_configure_file_commit_hash(new_hash) ### NB: Returns nil if the repo is in a detached HEAD state. def self.repo_branch_name result = `cd #{repository_path} && git rev-parse --abbrev-ref HEAD`.strip - (result == 'HEAD') ? nil : result + result == 'HEAD' ? nil : result end ### Returns the most recent commit hash in the `~/.mobile-secrets` repository. diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb index 95f3aa8cd..d3126025a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb @@ -47,7 +47,7 @@ def self.first_existing_ancestor_of(path:) def self.has_git_lfs? return false unless is_git_repo? - `git config --get-regex lfs`.length > 0 + !`git config --get-regex lfs`.empty? end # Switch to the given branch and pull its latest commits. diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb index e09bf55c8..e680b65fb 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb @@ -121,7 +121,7 @@ def create_milestone(repository:, title:, due_date:, days_until_submission:, day # @param [TrueClass|FalseClass] prerelease Indicates if this should be created as a pre-release (i.e. for alpha/beta) # @param [TrueClass|FalseClass] is_draft Indicates if this should be created as a draft release # - def create_release(repository:, version:, target: nil, description:, assets:, prerelease:, is_draft:) + def create_release(repository:, version:, description:, assets:, prerelease:, is_draft:, target: nil) release = client.create_release( repository, version, # tag name diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb index 45103705f..9cfd94399 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb @@ -4,7 +4,7 @@ module Fastlane module Helper module Ios module ADCAppSizesHelper - DEFAULT_DEVICES = ['Universal', 'iPhone 8', 'iPhone X'] + DEFAULT_DEVICES = ['Universal', 'iPhone 8', 'iPhone X'].freeze # Fetch the App Sizes stats from ADC # @@ -13,7 +13,7 @@ module ADCAppSizesHelper # Value for key `sizeInBytes` is itself a Hash with one entry per device name (including special name "Universal") # whose value is a Hash with keys `compressed` and `uncompressed` # - def self.get_adc_sizes(adc_user:, adc_team: 'Automattic, Inc.', bundle_id:, only_version: nil, limit: 10) + def self.get_adc_sizes(adc_user:, bundle_id:, adc_team: 'Automattic, Inc.', only_version: nil, limit: 10) UI.message 'Connecting to ADC...' Spaceship::ConnectAPI.login(adc_user, team_name: adc_team) app = Spaceship::ConnectAPI::App.find(bundle_id) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb index e28722000..54b02e6ae 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb @@ -5,9 +5,9 @@ module Fastlane module Helper module Ios class L10nLinterHelper - SWIFTGEN_VERSION = '6.4.0' - DEFAULT_BASE_LANG = 'en' - CONFIG_FILE_NAME = 'swiftgen-stringtypes.yml' + SWIFTGEN_VERSION = '6.4.0'.freeze + DEFAULT_BASE_LANG = 'en'.freeze + CONFIG_FILE_NAME = 'swiftgen-stringtypes.yml'.freeze attr_reader :install_path, :version diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb index 16059c4b4..7abdf69dd 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb @@ -139,8 +139,8 @@ def self.calc_prev_hotfix_version(version) def self.create_internal_version(version) vp = get_version_parts(version) d = DateTime.now - todayDate = d.strftime('%Y%m%d') - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{todayDate}" + today_date = d.strftime('%Y%m%d') + "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{today_date}" end # Return the build number value incremented by one. @@ -169,7 +169,7 @@ def self.is_hotfix?(version) # @return [String] The current version according to the public xcconfig file. # def self.get_build_version - versions = get_version_strings()[0] + versions = get_version_strings[0] end # Returns the current value of the `VERSION_LONG` key from the internal xcconfig file @@ -177,7 +177,7 @@ def self.get_build_version # @return [String] The current version according to the internal xcconfig file. # def self.get_internal_version - get_version_strings()[1] + get_version_strings[1] end # Prints the current and next release version numbers to stdout, then return the next release version @@ -186,7 +186,7 @@ def self.get_internal_version # def self.bump_version_release # Bump release - current_version = get_public_version() + current_version = get_public_version UI.message("Current version: #{current_version}") new_version = calc_next_release_version(current_version) UI.message("New version: #{new_version}") @@ -248,7 +248,6 @@ def self.update_xc_config(file_path, new_version, new_version_short) end #---------------------------------------- - private # Split a version string into its 4 parts, ensuring its parts count is valid # @@ -267,33 +266,33 @@ def self.get_version_parts(version) # Extract the VERSION_LONG entry from an `xcconfig` file # - # @param [String] filePath The path to the `.xcconfig` file to read the value from + # @param [String] file_path The path to the `.xcconfig` file to read the value from # @return [String] The long version found in said xcconfig file, or nil if not found # - def self.read_long_version_from_config_file(filePath) - read_from_config_file('VERSION_LONG', filePath) + def self.read_long_version_from_config_file(file_path) + read_from_config_file('VERSION_LONG', file_path) end # Extract the BUILD_NUMBER entry from an `xcconfig` file # - # @param [String] filePath The path to the `.xcconfig` file to read the value from + # @param [String] file_path The path to the `.xcconfig` file to read the value from # @return [String] The build number found in said xcconfig file, or nil if not found # - def self.read_build_number_from_config_file(filePath) - read_from_config_file('BUILD_NUMBER', filePath) + def self.read_build_number_from_config_file(file_path) + read_from_config_file('BUILD_NUMBER', file_path) end # Read the value of a given key from an `.xcconfig` file. # # @param [String] key The xcconfig key to get the value for - # @param [String] filePath The path to the `.xcconfig` file to read the value from + # @param [String] file_path The path to the `.xcconfig` file to read the value from # # @return [String] The value for the given key, or `nil` if the key was not found. # - def self.read_from_config_file(key, filePath) - File.open(filePath, 'r') do |f| + def self.read_from_config_file(key, file_path) + File.open(file_path, 'r') do |f| f.each_line do |line| - line = line.strip() + line = line.strip return line.split('=')[1] if line.start_with?("#{key}=") end end @@ -339,7 +338,7 @@ def self.verify_version(version) # # @return [Bool] true if the string is representing an integer value, false if not # - def self.is_int? string + def self.is_int?(string) true if Integer(string) rescue false end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb index bdae83c68..9745306d1 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb @@ -38,11 +38,11 @@ def parse_data(target_locale, loc_data, is_source) source = d[0].split(/\u0004/).last target_files.each do |file| - if file[0].to_s == key - data = file[1] - msg = is_source ? source : d[1].first || '' # In the JSON, each Hash value is an array, with zero or one entry - update_key(target_locale, key, file, data, msg) - end + next unless file[0].to_s == key + + data = file[1] + msg = is_source ? source : d[1].first || '' # In the JSON, each Hash value is an array, with zero or one entry + update_key(target_locale, key, file, data, msg) end end end @@ -55,19 +55,19 @@ def reparse_alternates(target_locale, loc_data, is_source) @alternates.each do |file| puts "Data: #{file[0]} - key: #{key}" - if file[0].to_s == key - puts "Alternate: #{key}" - data = file[1] - msg = is_source ? source : d[1].first || '' # In the JSON, each Hash value is an array, with zero or one entry - update_key(target_locale, key, file, data, msg) - end + next unless file[0].to_s == key + + puts "Alternate: #{key}" + data = file[1] + msg = is_source ? source : d[1].first || '' # In the JSON, each Hash value is an array, with zero or one entry + update_key(target_locale, key, file, data, msg) end end end def update_key(target_locale, key, file, data, msg) message_len = msg.length - if (data.key?(:max_size)) && (data[:max_size] != 0) && ((message_len) > data[:max_size]) + if data.key?(:max_size) && (data[:max_size] != 0) && (message_len > data[:max_size]) if data.key?(:alternate_key) UI.message("#{target_locale} translation for #{key} exceeds maximum length (#{message_len}). Switching to the alternate translation.") @alternates[data[:alternate_key]] = { desc: data[:desc], max_size: 0 } @@ -111,7 +111,7 @@ def handle_glotpress_download(response:, locale:, is_source:) @alternates.clear loc_data = JSON.parse(response.body) rescue loc_data = nil parse_data(locale, loc_data, is_source) - reparse_alternates(target_locale, loc_data, is_source) unless @alternates.length == 0 + reparse_alternates(target_locale, loc_data, is_source) unless @alternates.empty? when '301' # Follow the redirect UI.message("Received 301 for `#{locale}`. Following redirect...") diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb index 0a3dd6ec9..8116a4659 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb @@ -87,7 +87,7 @@ def generate_keys(release_version) version_minor = Integer(values[1]) @new_key = "#{@rel_note_key}_#{version_major}#{version_minor}" - version_major = version_major - 1 if version_minor == 0 + version_major -= 1 if version_minor == 0 version_minor = version_minor == 0 ? 9 : version_minor - 1 @keep_key = "#{@rel_note_key}_#{version_major}#{version_minor}" @@ -147,7 +147,7 @@ def generate_keys(release_version) version_minor = Integer(values[1]) @new_key = "v#{release_version}-whats-new" - version_major = version_major - 1 if version_minor == 0 + version_major -= 1 if version_minor == 0 version_minor = version_minor == 0 ? 9 : version_minor - 1 @old_key = "v#{version_major}.#{version_minor}-whats-new" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb index 39a30c0e1..1d79ff15e 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb @@ -32,14 +32,14 @@ def initialize UI.user_error!('`drawText` not found – install it using `brew install automattic/build-tools/drawText`.') unless system('command -v drawText') end - def read_config(configFilePath) - configFilePath = resolve_path(configFilePath) + def read_config(config_file_path) + config_file_path = resolve_path(config_file_path) begin # NOTE: While JSON is a subset of YAML and thus YAML.load_file would technically cover both cases at once, in practice # `JSON.parse` is more lenient with JSON files than `YAML.load_file` is — especially, it accepts `// comments` in the # JSON file, despite this not being allowed in the spec — hence why we still try with `JSON.parse` for `.json` files. - return File.extname(configFilePath) == '.json' ? JSON.parse(File.read(configFilePath)) : YAML.load_file(configFilePath) + return File.extname(config_file_path) == '.json' ? JSON.parse(File.read(config_file_path)) : YAML.load_file(config_file_path) rescue StandardError => e UI.error(e) UI.user_error!('Invalid JSON/YAML configuration. Please lint your config file to check for syntax errors.') @@ -280,7 +280,7 @@ def apply_operation(image, operation, canvas) def draw_text_to_canvas(canvas, text, width, height, x_position, y_position, font_size, stylesheet_path, position = 'center') begin - tempTextFile = Tempfile.new() + temp_text_file = Tempfile.new Action.sh('drawText', "html=#{text}", "maxWidth=#{width}", "maxHeight=#{height}", "output=#{tempTextFile.path}", "fontSize=#{font_size}", "stylesheet=#{stylesheet_path}", "alignment=#{position}") @@ -292,8 +292,8 @@ def draw_text_to_canvas(canvas, text, width, height, x_position, y_position, fon when 'top' then composite_image_top(text_frame, text_content, 0, 0) end ensure - tempTextFile.close - tempTextFile.unlink + temp_text_file.close + temp_text_file.unlink end composite_image(canvas, text_frame, x_position, y_position) @@ -431,12 +431,12 @@ def resolve_path(path) end def resolve_text_into_path(text, locale) - localizedFile = format(text, locale) + localized_file = format(text, locale) - text = if File.exist?(localizedFile) - localizedFile - elsif can_resolve_path(localizedFile) - resolve_path(localizedFile).realpath.to_s + text = if File.exist?(localized_file) + localized_file + elsif can_resolve_path(localized_file) + resolve_path(localized_file).realpath.to_s else format(text, 'source') end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/version.rb index e432de359..3f551e304 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/version.rb @@ -1,5 +1,5 @@ module Fastlane module Wpmreleasetoolkit - VERSION = '8.1.0' + VERSION = '8.1.0'.freeze end end diff --git a/rakelib/changelog_parser.rake b/rakelib/changelog_parser.rake index ae50df7af..551958e0c 100644 --- a/rakelib/changelog_parser.rake +++ b/rakelib/changelog_parser.rake @@ -44,7 +44,7 @@ class ChangelogParser comps.join('.') end - def update_for_new_release(new_file: 'CHANGELOG.md', new_version:) + def update_for_new_release(new_version:, new_file: 'CHANGELOG.md') raise 'You need to call #parse_pending_section first' if @pending_section.nil? File.open(new_file, 'w') do |f| diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index ca04f1928..2f4211fca 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -15,7 +15,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:read).with('./version.properties').and_return(test_file_content) - expect(subject.get_version_from_properties()).to eq('name' => '17.0', 'code' => 123) + expect(subject.get_version_from_properties).to eq('name' => '17.0', 'code' => 123) end it 'returns alpha version name and code when present' do diff --git a/spec/check_localization_progress_spec.rb b/spec/check_localization_progress_spec.rb index e91bd8c01..d9275d98d 100644 --- a/spec/check_localization_progress_spec.rb +++ b/spec/check_localization_progress_spec.rb @@ -58,7 +58,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', # Invoke with 'es' which is not in the mocked message - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: true, skip_confirm: true @@ -84,7 +84,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', # Invoke with 'es' which is not in the mocked message - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: true, skip_confirm: true @@ -113,7 +113,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: true, skip_confirm: true @@ -142,7 +142,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: true, skip_confirm: true @@ -178,7 +178,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: false, skip_confirm: false @@ -215,7 +215,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: false, skip_confirm: false @@ -251,7 +251,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: false, skip_confirm: true @@ -286,7 +286,7 @@ described_class.run( glotpress_url: 'https://translate.wordpress.org/projects/apps/my-test-project/dev', - language_codes: 'ar de es'.split(), + language_codes: 'ar de es'.split, min_acceptable_translation_percentage: 99, abort_on_violations: false, skip_confirm: true @@ -298,7 +298,7 @@ def generate_glotpress_response_body(languages:) response = '' - response << generate_glotpress_response_header() + response << generate_glotpress_response_header languages.each do |language| response << generate_glotpress_response_for_language( lang: language[:lang_name], @@ -311,7 +311,7 @@ def generate_glotpress_response_body(languages:) ) end - response << generate_glotpress_response_footer() + response << generate_glotpress_response_footer response end diff --git a/spec/ci_helper_spec.rb b/spec/ci_helper_spec.rb index f2c5125ab..c42598942 100644 --- a/spec/ci_helper_spec.rb +++ b/spec/ci_helper_spec.rb @@ -12,21 +12,21 @@ describe Fastlane::Helper::CircleCIHelper do it_behaves_like 'a CI provider' do - let(:model) { Fastlane::Helper::CircleCIHelper.new(login: 'my_circleci_token', repository: 'test_repo') } + let(:model) { described_class.new(login: 'my_circleci_token', repository: 'test_repo') } end context 'initialization' do - describe Fastlane::Helper::CircleCIHelper.new(login: 'my_circleci_token', repository: 'test_repo') do + describe described_class.new(login: 'my_circleci_token', repository: 'test_repo') do it { is_expected.to have_attributes(:organization => 'wordpress-mobile', 'repository' => 'test_repo', 'command_uri' => URI.parse('https://circleci.com/api/v2/project/github/wordpress-mobile/test_repo/pipeline')) } end - describe Fastlane::Helper::CircleCIHelper.new(login: 'my_circleci_token', repository: 'test_repo', organization: 'my_org') do + describe described_class.new(login: 'my_circleci_token', repository: 'test_repo', organization: 'my_org') do it { is_expected.to have_attributes(:organization => 'my_org', 'repository' => 'test_repo', 'command_uri' => URI.parse('https://circleci.com/api/v2/project/github/my_org/test_repo/pipeline')) } end end context 'Main Commands' do - describe Fastlane::Helper::CircleCIHelper.new(login: 'my_circleci_token', repository: 'test_repo') do + describe described_class.new(login: 'my_circleci_token', repository: 'test_repo') do it 'triggers a job' do stub = stub_request(:post, 'https://circleci.com/api/v2/project/github/wordpress-mobile/test_repo/pipeline').with( body: { branch: 'trunk', parameters: nil }, diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index 947868e8f..648fc1565 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -12,6 +12,8 @@ end describe 'file reading/writing' do + subject { described_class.from_file(configure_path) } + let(:configure_path) { 'path/to/.configure' } let(:configure_json) do @@ -25,8 +27,6 @@ end let(:configure_json_string) { JSON.pretty_generate(configure_json) } - subject { Fastlane::Configuration.from_file(configure_path) } - before(:each) do allow(File).to receive(:read).with(configure_path).and_return(configure_json_string) allow(File).to receive(:write).with(configure_path, configure_json_string) diff --git a/spec/encryption_helper_spec.rb b/spec/encryption_helper_spec.rb index 827cb0ec6..5f2ae9292 100644 --- a/spec/encryption_helper_spec.rb +++ b/spec/encryption_helper_spec.rb @@ -14,7 +14,7 @@ expect(cipher).to receive(:update).with('plain text').and_return('encrypted') expect(cipher).to receive(:final).and_return('!') - expect(Fastlane::Helper::EncryptionHelper.encrypt('plain text', 'key')).to eq('encrypted!') + expect(described_class.encrypt('plain text', 'key')).to eq('encrypted!') end it 'decrypts the input' do @@ -24,13 +24,13 @@ expect(cipher).to receive(:update).with('encrypted').and_return('plain text') expect(cipher).to receive(:final).and_return('!') - expect(Fastlane::Helper::EncryptionHelper.decrypt('encrypted', 'key')).to eq('plain text!') + expect(described_class.decrypt('encrypted', 'key')).to eq('plain text!') end it 'generates a random key' do expect(cipher).to receive(:encrypt) expect(cipher).to receive(:random_key).and_return('random key') - expect(Fastlane::Helper::EncryptionHelper.generate_key).to eq('random key') + expect(described_class.generate_key).to eq('random key') end end diff --git a/spec/file_reference_spec.rb b/spec/file_reference_spec.rb index 357f97325..3c8392272 100644 --- a/spec/file_reference_spec.rb +++ b/spec/file_reference_spec.rb @@ -63,7 +63,7 @@ end describe 'without encryption' do - let(:subject) { Fastlane::Configuration::FileReference.new(file: 'path/to/file', destination: 'destination', encrypt: false) } + let(:subject) { described_class.new(file: 'path/to/file', destination: 'destination', encrypt: false) } include_examples 'shared examples' @@ -92,7 +92,7 @@ end describe 'with encryption' do - let(:subject) { Fastlane::Configuration::FileReference.new(file: 'path/to/file', destination: 'destination', encrypt: true) } + let(:subject) { described_class.new(file: 'path/to/file', destination: 'destination', encrypt: true) } before(:each) do allow(Fastlane::Helper::ConfigureHelper).to receive(:encryption_key).and_return('key') diff --git a/spec/firebase_test_runner_spec.rb b/spec/firebase_test_runner_spec.rb index 55efa1656..92ebcfcdd 100644 --- a/spec/firebase_test_runner_spec.rb +++ b/spec/firebase_test_runner_spec.rb @@ -39,8 +39,8 @@ end it 'properly escapes the app path' do - temp_file_path = File.join(Dir.tmpdir(), 'path with spaces.txt') - expected_temp_file_path = File.join(Dir.tmpdir(), 'path\ with\ spaces.txt') + temp_file_path = File.join(Dir.tmpdir, 'path with spaces.txt') + expected_temp_file_path = File.join(Dir.tmpdir, 'path\ with\ spaces.txt') File.write(temp_file_path, '') allow(Fastlane::Action).to receive('sh').with("gcloud firebase test android run --project foo-bar-baz --type instrumentation --app #{expected_temp_file_path} --test #{default_file} --device device --verbosity info 2>&1 | tee #{runner_temp_file}") @@ -48,8 +48,8 @@ end it 'properly escapes the test path' do - temp_file_path = File.join(Dir.tmpdir(), 'path with spaces.txt') - expected_temp_file_path = File.join(Dir.tmpdir(), 'path\ with\ spaces.txt') + temp_file_path = File.join(Dir.tmpdir, 'path with spaces.txt') + expected_temp_file_path = File.join(Dir.tmpdir, 'path\ with\ spaces.txt') File.write(temp_file_path, '') allow(Fastlane::Action).to receive('sh').with("gcloud firebase test android run --project foo-bar-baz --type instrumentation --app #{default_file} --test #{expected_temp_file_path} --device device --verbosity info 2>&1 | tee #{runner_temp_file}") diff --git a/spec/git_helper_spec.rb b/spec/git_helper_spec.rb index 44f3f6d5a..b2ca50d4f 100644 --- a/spec/git_helper_spec.rb +++ b/spec/git_helper_spec.rb @@ -16,31 +16,31 @@ end it 'can detect a missing git repository' do - expect(Fastlane::Helper::GitHelper.is_git_repo?).to be false + expect(described_class.is_git_repo?).to be false end it 'can detect a missing git repository when given a path' do Dir.mktmpdir do |dir| - expect(Fastlane::Helper::GitHelper.is_git_repo?(path: dir)).to be false + expect(described_class.is_git_repo?(path: dir)).to be false end end it 'can detect a valid git repository' do `git init --initial-branch main || git init` - expect(Fastlane::Helper::GitHelper.is_git_repo?).to be true + expect(described_class.is_git_repo?).to be true end it 'can detect a valid git repository from a child folder' do `git init --initial-branch main || git init` `mkdir -p a/b` Dir.chdir('./a/b') - expect(Fastlane::Helper::GitHelper.is_git_repo?).to be true + expect(described_class.is_git_repo?).to be true end it 'can detect a valid git repository when given a path' do Dir.mktmpdir do |dir| `git -C #{dir} init --initial-branch main || git -C #{dir} init` - expect(Fastlane::Helper::GitHelper.is_git_repo?(path: dir)).to be true + expect(described_class.is_git_repo?(path: dir)).to be true end end @@ -49,64 +49,64 @@ `git -C #{dir} init --initial-branch main || git -C #{dir} init` path = File.join(dir, 'a', 'b') `mkdir -p #{path}` - expect(Fastlane::Helper::GitHelper.is_git_repo?(path: path)).to be true + expect(described_class.is_git_repo?(path: path)).to be true end end it 'can detect a repository with Git-lfs enabled' do `git init --initial-branch main || git init` `git lfs install` - expect(Fastlane::Helper::GitHelper.has_git_lfs?).to be true + expect(described_class.has_git_lfs?).to be true end it 'can detect a repository without Git-lfs enabled' do `git init --initial-branch main || git init` `git lfs uninstall &>/dev/null` - expect(Fastlane::Helper::GitHelper.is_git_repo?).to be true - expect(Fastlane::Helper::GitHelper.has_git_lfs?).to be false + expect(described_class.is_git_repo?).to be true + expect(described_class.has_git_lfs?).to be false end context('commit(message:, files:)') do before(:each) do - allow_fastlane_action_sh() + allow_fastlane_action_sh @message = 'Some commit message with spaces' end it 'commits without adding any file if none are provided' do expect_shell_command('git', 'add', any_args).never expect_shell_command('git', 'commit', '-m', @message) - Fastlane::Helper::GitHelper.commit(message: @message) + described_class.commit(message: @message) end it 'commits without adding any file if nil is provided' do expect_shell_command('git', 'add', any_args).never expect_shell_command('git', 'commit', '-m', @message) - Fastlane::Helper::GitHelper.commit(message: @message, files: nil) + described_class.commit(message: @message, files: nil) end it 'commits without adding any file if an empty list of files is provided' do expect_shell_command('git', 'add', any_args).never expect_shell_command('git', 'commit', '-m', @message) - Fastlane::Helper::GitHelper.commit(message: @message, files: []) + described_class.commit(message: @message, files: []) end it 'adds a single file before commit if a single String is provided as `files`' do file = 'some file' expect_shell_command('git', 'add', file) expect_shell_command('git', 'commit', '-m', @message) - Fastlane::Helper::GitHelper.commit(message: @message, files: file) + described_class.commit(message: @message, files: file) end it 'adds multiple files before commit if an Array is provided as `files`' do files = ['file 1', 'file 2', 'file 3'] expect_shell_command('git', 'add', files[0], files[1], files[2]) expect_shell_command('git', 'commit', '-m', @message) - Fastlane::Helper::GitHelper.commit(message: @message, files: files) + described_class.commit(message: @message, files: files) end it 'adds all pending file changes before commit if :all is provided as `files`' do expect_shell_command('git', 'commit', '-a', '-m', @message) - Fastlane::Helper::GitHelper.commit(message: @message, files: :all) + described_class.commit(message: @message, files: :all) end end @@ -118,7 +118,7 @@ dummy_file_path: path, add_file_to_gitignore: false ) - expect(Fastlane::Helper::GitHelper.is_ignored?(path: path)).to be false + expect(described_class.is_ignored?(path: path)).to be false end context 'when the path is in the .gitignore' do @@ -132,7 +132,7 @@ add_file_to_gitignore: true, commit_gitignore: false ) - expect(Fastlane::Helper::GitHelper.is_ignored?(path: path)).to be true + expect(described_class.is_ignored?(path: path)).to be true end it 'returns true when the .gitignore has no uncommitted changes' do @@ -141,15 +141,15 @@ add_file_to_gitignore: true, commit_gitignore: true ) - expect(Fastlane::Helper::GitHelper.is_ignored?(path: path)).to be true + expect(described_class.is_ignored?(path: path)).to be true end end # This test ensures we support the usecase of the `configure` tool, which can create new files by decrypting secrets. # We need the ability to tell if a path result is ignored, regardless of whether it exists yet. it 'returns false for files not yet created but part of the repository' do - setup_git_repo() - expect(Fastlane::Helper::GitHelper.is_ignored?(path: path)).to be false + setup_git_repo + expect(described_class.is_ignored?(path: path)).to be false end it 'returns true when the path is outside the repository folder' do @@ -157,14 +157,14 @@ path = File.join(@path, '..', 'dummy.txt') setup_git_repo(dummy_file_path: path, add_file_to_gitignore: false) - expect(Fastlane::Helper::GitHelper.is_ignored?(path: path)).to be true + expect(described_class.is_ignored?(path: path)).to be true end # This is sort of redundant given the previous example already ensures the same logic. # But, we'll be using paths starting with `~` as part of our configurations, so it felt appopriate to explicitly ensure this important use case is respected. it 'returns true when the path is in the home folder ' do path = '~/a/path' - expect(Fastlane::Helper::GitHelper.is_ignored?(path: path)).to be true + expect(described_class.is_ignored?(path: path)).to be true end end end diff --git a/spec/ios_bump_version_release_spec.rb b/spec/ios_bump_version_release_spec.rb index f2a3f882e..03dad7929 100644 --- a/spec/ios_bump_version_release_spec.rb +++ b/spec/ios_bump_version_release_spec.rb @@ -8,7 +8,7 @@ describe 'creates the release branch, bumps the app version and commits the changes' do before do - other_action_mock = double() + other_action_mock = double allow(Fastlane::Action).to receive(:other_action).and_return(other_action_mock) allow(other_action_mock).to receive(:ensure_git_branch).with(branch: default_branch) diff --git a/spec/ios_lint_localizations_spec.rb b/spec/ios_lint_localizations_spec.rb index 094367c3a..eb96b7d81 100644 --- a/spec/ios_lint_localizations_spec.rb +++ b/spec/ios_lint_localizations_spec.rb @@ -6,7 +6,7 @@ describe Fastlane::Actions::IosLintLocalizationsAction do before do # Ensure `Action.sh` is not skipped during test – so that SwiftGen will be installed by our action as normal – See spec_helper.rb - allow_fastlane_action_sh() + allow_fastlane_action_sh end context 'SwiftGen Installation Logic' do @@ -95,6 +95,10 @@ def run_l10n_linter_test(data_file:, check_duplicate_keys: nil) allow(FastlaneCore::UI).to receive(:abort_with_message!) end + after(:each) do + FileUtils.remove_entry @test_data_dir + end + it 'succeeds when there are no violations' do run_l10n_linter_test(data_file: 'no-violations') end @@ -199,9 +203,5 @@ def run_l10n_linter_test(data_file:, check_duplicate_keys: nil) expect(result).to eq({ 'fr' => ['`key3` expected placeholders for [Int] but found [] instead.'] }) end - - after(:each) do - FileUtils.remove_entry @test_data_dir - end end end diff --git a/spec/release_notes_helper_spec.rb b/spec/release_notes_helper_spec.rb index c74b4323f..58515724b 100644 --- a/spec/release_notes_helper_spec.rb +++ b/spec/release_notes_helper_spec.rb @@ -59,7 +59,7 @@ end end -FAKE_CONTENT = <<~CONTENT +FAKE_CONTENT = <<~CONTENT.freeze 1.2.3 ----- - Item 1 for v1.2.3 @@ -73,7 +73,7 @@ - Item 2 for v1.2.2 CONTENT -NEW_SECTION = <<~CONTENT +NEW_SECTION = <<~CONTENT.freeze New Section -----