Skip to content

Commit be35b01

Browse files
Fix Naming/VariableName violations
1 parent b82b7c9 commit be35b01

File tree

6 files changed

+49
-60
lines changed

6 files changed

+49
-60
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ Naming/MethodParameterName:
4848
Naming/PredicateName:
4949
Enabled: false
5050

51-
# Offense count: 54
52-
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns.
53-
# SupportedStyles: snake_case, camelCase
54-
Naming/VariableName:
55-
Exclude:
56-
- 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb'
57-
- 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb'
58-
- 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb'
59-
- 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb'
60-
- 'lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb'
61-
6251
# Offense count: 2
6352
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
6453
# SupportedStyles: snake_case, normalcase, non_integer

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def self.run(params)
1515

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

18-
translationDirectories = subdirectories_for_path(params[:metadata_folder])
19-
imageDirectories = subdirectories_for_path(params[:orig_folder])
18+
translation_directories = subdirectories_for_path(params[:metadata_folder])
19+
image_directories = subdirectories_for_path(params[:orig_folder])
2020

2121
if helper.can_resolve_path(params[:output_folder])
2222
UI.message "#{self.check_path(params[:output_folder])} Output Folder: #{params[:output_folder]}"
@@ -25,18 +25,18 @@ def self.run(params)
2525
FileUtils.mkdir_p(params[:output_folder])
2626
end
2727

28-
outputDirectory = helper.resolve_path(params[:output_folder])
28+
output_directory = helper.resolve_path(params[:output_folder])
2929

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

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

5050
stylesheet_path = config['stylesheet']
5151

52-
entries = build_entries(config['entries'], languages, outputDirectory, params)
52+
entries = build_entries(config['entries'], languages, output_directory, params)
5353

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

@@ -183,32 +183,32 @@ def self.build_entries(config_entries, languages, output_directory, params)
183183
config_entries
184184
.flat_map do |entry|
185185
languages.map do |language|
186-
newEntry = entry.deep_dup
186+
new_entry = entry.deep_dup
187187

188188
# Not every output file will have a screenshot, so handle cases where no
189189
# screenshot file is defined
190190
if !entry['screenshot'].nil? && !entry['filename'].nil?
191-
newEntry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
192-
newEntry['filename'] = output_directory + language + entry['filename']
191+
new_entry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
192+
new_entry['filename'] = output_directory + language + entry['filename']
193193
elsif !entry['screenshot'].nil? && entry['filename'].nil?
194-
newEntry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
195-
newEntry['filename'] = output_directory + language + entry['screenshot']
194+
new_entry['screenshot'] = helper.resolve_path(params[:orig_folder]) + language + entry['screenshot']
195+
new_entry['filename'] = output_directory + language + entry['screenshot']
196196
elsif entry['screenshot'].nil? && !entry['filename'].nil?
197-
newEntry['filename'] = output_directory + language + entry['filename']
197+
new_entry['filename'] = output_directory + language + entry['filename']
198198
else
199-
puts newEntry
199+
puts new_entry
200200
abort 'Unable to find output file names'
201201
end
202202

203-
newEntry['locale'] = language
203+
new_entry['locale'] = language
204204

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

208208
# Map attachments paths to their localized versions
209-
newEntry['attachments'] = [] if newEntry['attachments'].nil?
209+
new_entry['attachments'] = [] if new_entry['attachments'].nil?
210210

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

243-
newEntry
243+
new_entry
244244
end
245245
end
246246
.sort do |x, y|

lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def self.add_file
4040
UI.message 'Example: google-services.json'
4141

4242
source = UI.input('Source File Path:')
43-
sourcePath = absolute_secret_store_path(source) # Transform the relative path into an absolute path.
43+
source_path = absolute_secret_store_path(source) # Transform the relative path into an absolute path.
4444

4545
# Don't allow the developer to accidentally specify an invalid file, otherwise validation will never succeed.
46-
if File.file?(sourcePath)
46+
if File.file?(source_path)
4747
invalid_file = false
4848
else
49-
UI.error "There is no file at #{sourcePath}."
49+
UI.error "There is no file at #{source_path}."
5050
end
5151
end
5252

lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def self.validate_that_all_copied_files_match
9191
source = absolute_secret_store_path(x.file)
9292
destination = absolute_project_path(x.destination)
9393

94-
sourceHash = file_hash(source)
95-
destinationHash = file_hash(destination)
94+
source_hash = file_hash(source)
95+
destination_hash = file_hash(destination)
9696

97-
UI.user_error!("`#{x.destination} doesn't match the file in the secrets repository (#{x.file}) – unable to continue") unless sourceHash == destinationHash
97+
UI.user_error!("`#{x.destination} doesn't match the file in the secrets repository (#{x.file}) – unable to continue") unless source_hash == destination_hash
9898
end
9999
end
100100

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def self.calc_prev_hotfix_version(version)
139139
def self.create_internal_version(version)
140140
vp = get_version_parts(version)
141141
d = DateTime.now
142-
todayDate = d.strftime('%Y%m%d')
143-
"#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{todayDate}"
142+
today_date = d.strftime('%Y%m%d')
143+
"#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{today_date}"
144144
end
145145

146146
# Return the build number value incremented by one.
@@ -266,31 +266,31 @@ def self.get_version_parts(version)
266266

267267
# Extract the VERSION_LONG entry from an `xcconfig` file
268268
#
269-
# @param [String] filePath The path to the `.xcconfig` file to read the value from
269+
# @param [String] file_path The path to the `.xcconfig` file to read the value from
270270
# @return [String] The long version found in said xcconfig file, or nil if not found
271271
#
272-
def self.read_long_version_from_config_file(filePath)
273-
read_from_config_file('VERSION_LONG', filePath)
272+
def self.read_long_version_from_config_file(file_path)
273+
read_from_config_file('VERSION_LONG', file_path)
274274
end
275275

276276
# Extract the BUILD_NUMBER entry from an `xcconfig` file
277277
#
278-
# @param [String] filePath The path to the `.xcconfig` file to read the value from
278+
# @param [String] file_path The path to the `.xcconfig` file to read the value from
279279
# @return [String] The build number found in said xcconfig file, or nil if not found
280280
#
281-
def self.read_build_number_from_config_file(filePath)
282-
read_from_config_file('BUILD_NUMBER', filePath)
281+
def self.read_build_number_from_config_file(file_path)
282+
read_from_config_file('BUILD_NUMBER', file_path)
283283
end
284284

285285
# Read the value of a given key from an `.xcconfig` file.
286286
#
287287
# @param [String] key The xcconfig key to get the value for
288-
# @param [String] filePath The path to the `.xcconfig` file to read the value from
288+
# @param [String] file_path The path to the `.xcconfig` file to read the value from
289289
#
290290
# @return [String] The value for the given key, or `nil` if the key was not found.
291291
#
292-
def self.read_from_config_file(key, filePath)
293-
File.open(filePath, 'r') do |f|
292+
def self.read_from_config_file(key, file_path)
293+
File.open(file_path, 'r') do |f|
294294
f.each_line do |line|
295295
line = line.strip
296296
return line.split('=')[1] if line.start_with?("#{key}=")

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def initialize
3232
UI.user_error!('`drawText` not found – install it using `brew install automattic/build-tools/drawText`.') unless system('command -v drawText')
3333
end
3434

35-
def read_config(configFilePath)
36-
configFilePath = resolve_path(configFilePath)
35+
def read_config(config_file_path)
36+
config_file_path = resolve_path(config_file_path)
3737

3838
begin
3939
# NOTE: While JSON is a subset of YAML and thus YAML.load_file would technically cover both cases at once, in practice
4040
# `JSON.parse` is more lenient with JSON files than `YAML.load_file` is — especially, it accepts `// comments` in the
4141
# JSON file, despite this not being allowed in the spec — hence why we still try with `JSON.parse` for `.json` files.
42-
return File.extname(configFilePath) == '.json' ? JSON.parse(File.read(configFilePath)) : YAML.load_file(configFilePath)
42+
return File.extname(config_file_path) == '.json' ? JSON.parse(File.read(config_file_path)) : YAML.load_file(config_file_path)
4343
rescue StandardError => e
4444
UI.error(e)
4545
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)
280280

281281
def draw_text_to_canvas(canvas, text, width, height, x_position, y_position, font_size, stylesheet_path, position = 'center')
282282
begin
283-
tempTextFile = Tempfile.new
283+
temp_text_file = Tempfile.new
284284

285285
Action.sh('drawText', "html=#{text}", "maxWidth=#{width}", "maxHeight=#{height}", "output=#{tempTextFile.path}", "fontSize=#{font_size}", "stylesheet=#{stylesheet_path}", "alignment=#{position}")
286286

@@ -292,8 +292,8 @@ def draw_text_to_canvas(canvas, text, width, height, x_position, y_position, fon
292292
when 'top' then composite_image_top(text_frame, text_content, 0, 0)
293293
end
294294
ensure
295-
tempTextFile.close
296-
tempTextFile.unlink
295+
temp_text_file.close
296+
temp_text_file.unlink
297297
end
298298

299299
composite_image(canvas, text_frame, x_position, y_position)
@@ -431,12 +431,12 @@ def resolve_path(path)
431431
end
432432

433433
def resolve_text_into_path(text, locale)
434-
localizedFile = format(text, locale)
434+
localized_file = format(text, locale)
435435

436-
text = if File.exist?(localizedFile)
437-
localizedFile
438-
elsif can_resolve_path(localizedFile)
439-
resolve_path(localizedFile).realpath.to_s
436+
text = if File.exist?(localized_file)
437+
localized_file
438+
elsif can_resolve_path(localized_file)
439+
resolve_path(localized_file).realpath.to_s
440440
else
441441
format(text, 'source')
442442
end

0 commit comments

Comments
 (0)