Fix more 'Lint/ShadowingOuterLocalVar' warnings reported by ameba

This commit is contained in:
Samantaz Fox
2022-01-20 17:17:22 +01:00
parent 1c91110464
commit 12b818a83c
10 changed files with 22 additions and 18 deletions

View File

@@ -94,8 +94,8 @@ def translate(locale : String?, key : String, text : String | Nil = nil) : Strin
translation = ""
match_length = 0
raw_data.as_h.each do |key, value|
if md = text.try &.match(/#{key}/)
raw_data.as_h.each do |hash_key, value|
if md = text.try &.match(/#{hash_key}/)
if md[0].size >= match_length
translation = value.as_s
match_length = md[0].size

View File

@@ -98,9 +98,9 @@ module JSONFilter
end
end
group_name.split('/').each do |group_name|
group_name.split('/').each do |name|
nest_stack.push({
group_name: group_name,
group_name: name,
closing_bracket_index: closing_bracket_index,
})
end

View File

@@ -175,9 +175,9 @@ module Kemal
if @cached_files.sum(&.[1][:data].bytesize) + (size = File.size(file_path)) < CACHE_LIMIT
data = Bytes.new(size)
File.open(file_path) do |file|
file.read(data)
end
File.open(file_path) { |f| f.read(data) }
filestat = File.info(file_path)
@cached_files[file_path] = {data: data, filestat: filestat}

View File

@@ -42,6 +42,9 @@ end
def sign_token(key, hash)
string_to_sign = [] of String
# TODO: figure out which "key" variable is used
# Ameba reports a warning for "Lint/ShadowingOuterLocalVar" on this
# variable, but its preferrable to not touch that (works fine atm).
hash.each do |key, value|
next if key == "signature"

View File

@@ -292,8 +292,8 @@ def parse_range(range)
end
ranges = range.lchop("bytes=").split(',')
ranges.each do |range|
start_range, end_range = range.split('-')
ranges.each do |r|
start_range, end_range = r.split('-')
start_range = start_range.to_i64? || 0_i64
end_range = end_range.to_i64?