Skip to content

Commit 25c55bc

Browse files
committed
Fix Rubocop violations
1 parent b9d981e commit 25c55bc

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

fastlane/Fastfile

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,13 @@ end
144144
lane :generate_source_po_file do |commit_and_push_changes: false|
145145
project_version = get_version_from_cargo_toml
146146

147-
UI.header("🔄 Converting English Fluent file to PO format")
147+
UI.header('🔄 Converting English Fluent file to PO format')
148148

149149
FileUtils.mkdir_p(File.dirname(LOCALIZATION_PO_SOURCE_FILE))
150150

151151
fluent_file = File.join(LOCALIZATION_FLUENT_FILES_DIR, 'en-US', MAIN_FLUENT_FILE_NAME)
152152

153-
unless File.exist?(fluent_file)
154-
UI.user_error!("❌ English Fluent file not found: #{fluent_file}")
155-
end
153+
UI.user_error!("❌ English Fluent file not found: #{fluent_file}") unless File.exist?(fluent_file)
156154

157155
begin
158156
fluent_to_po(
@@ -164,14 +162,16 @@ lane :generate_source_po_file do |commit_and_push_changes: false|
164162
)
165163

166164
UI.success("✅ #{File.basename(fluent_file)}#{File.basename(LOCALIZATION_PO_SOURCE_FILE)}")
167-
rescue => e
165+
rescue StandardError => e
168166
UI.error("❌ Failed to convert English Fluent file: #{e.message}")
169167
end
170168

171-
commit_changed_files(
172-
files: LOCALIZATION_PO_SOURCE_FILE,
173-
message: 'Update source PO file (en-US.pot) to be synced to GlotPress'
174-
) if commit_and_push_changes
169+
if commit_and_push_changes
170+
commit_changed_files(
171+
files: LOCALIZATION_PO_SOURCE_FILE,
172+
message: 'Update source PO file (en-US.pot) to be synced to GlotPress'
173+
)
174+
end
175175
end
176176

177177
# Converts a PO file for a given locale back to Fluent format
@@ -211,22 +211,20 @@ end
211211
# @param commit_and_push_changes [Boolean] Whether to commit and push the updated Fluent files (default: false)
212212
#
213213
lane :download_translations do |commit_and_push_changes: false|
214-
UI.header("🌐 Downloading translations from GlotPress")
214+
UI.header('🌐 Downloading translations from GlotPress')
215215

216216
downloaded_files = download_po_files_from_glotpress
217217
updated_fluent_files = []
218218

219219
# Convert PO files back to Fluent format
220220
if downloaded_files.any?
221-
UI.header("🔄 Converting PO files to Fluent format")
221+
UI.header('🔄 Converting PO files to Fluent format')
222222

223223
downloaded_files.each do |file_path|
224-
begin
225-
fluent_file_path = generate_fluent_file_from_po(file_path: file_path)
226-
updated_fluent_files << fluent_file_path if fluent_file_path
227-
rescue => e
228-
UI.error("❌ Failed to convert #{File.basename(file_path)}: #{e.message}")
229-
end
224+
fluent_file_path = generate_fluent_file_from_po(file_path: file_path)
225+
updated_fluent_files << fluent_file_path if fluent_file_path
226+
rescue StandardError => e
227+
UI.error("❌ Failed to convert #{File.basename(file_path)}: #{e.message}")
230228
end
231229

232230
UI.success("✅ Updated Fluent files: #{updated_fluent_files.length} locales")
@@ -252,7 +250,7 @@ end
252250
# @return [Array<String>] List of successfully downloaded files
253251
#
254252
lane :download_po_files_from_glotpress do |download_dir: LOCALIZATION_PO_FILES_TMP_DIR|
255-
UI.header("🌐 Downloading PO files from GlotPress")
253+
UI.header('🌐 Downloading PO files from GlotPress')
256254

257255
# Ensure PO output directory exists
258256
FileUtils.mkdir_p(download_dir)
@@ -275,7 +273,7 @@ lane :download_po_files_from_glotpress do |download_dir: LOCALIZATION_PO_FILES_T
275273
else
276274
UI.error("❌ Failed to download #{project_locale}: empty response")
277275
end
278-
rescue => e
276+
rescue StandardError => e
279277
UI.error("❌ Failed to download #{project_locale}: #{e.message}")
280278
end
281279
end
@@ -315,13 +313,11 @@ def get_version_from_cargo_toml
315313
default_version = '1.0.0'
316314

317315
File.readlines(cargo_toml_path).each do |line|
318-
if line.start_with?('version = ')
319-
return line.split('=')[1].strip.gsub(/["']/, '')
320-
end
316+
return line.split('=')[1].strip.gsub(/["']/, '') if line.start_with?('version = ')
321317
end
322318

323319
default_version
324-
rescue
320+
rescue StandardError
325321
default_version
326322
end
327323

@@ -334,8 +330,8 @@ def commit_changed_files(files:, message:, push: true)
334330
)
335331

336332
if result.nil?
337-
UI.important("⚠️ No changed files")
338-
else
339-
push_to_git_remote(set_upstream: true, tags: false) if push
333+
UI.important('⚠️ No changed files')
334+
elsif push
335+
push_to_git_remote(set_upstream: true, tags: false)
340336
end
341337
end

0 commit comments

Comments
 (0)