From ef9c34b7cd8c2d05e45d655dbcbc112761fe6d53 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 28 Apr 2024 12:43:55 +0200 Subject: [PATCH] Luacheck fixes --- errors.lua | 2 +- string_distance.lua | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/errors.lua b/errors.lua index f0dc592..8dad2e2 100644 --- a/errors.lua +++ b/errors.lua @@ -92,7 +92,7 @@ local function correct_error (self, module_suffix, format_msg, gotten_string, po assert(type(lvl) == 'number') -- Do stuff - local possible_strings = string_dist.strings_with_highest_similarity(gotten_string, possible_strings) + possible_strings = string_dist.strings_with_highest_similarity(gotten_string, possible_strings) local list_string = #possible_strings > 0 and format_probable_strings(possible_strings, 3) or "" -- Format error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, gotten_string, list_string), lvl + 1) diff --git a/string_distance.lua b/string_distance.lua index 629fa64..44c850d 100644 --- a/string_distance.lua +++ b/string_distance.lua @@ -46,7 +46,7 @@ local function levenshtein (str1, str2) if type(str2) ~= 'string' then error(('[errors/internal]: Bad argument #1 to levenshtein, expected string, got %s (%s)'):format(str2, type(str2))) end -- Do work - local str1, str2 = str1:lower(), str2:lower() + str1, str2 = str1:lower(), str2:lower() local len1, len2 = #str1, #str2 -- Quick cut-offs to save time @@ -65,9 +65,9 @@ local function levenshtein (str1, str2) -- Algorithm for x = 1, len2 do column[0] = x - local lastdiag, olddiag = x - 1, nil + local lastdiag = x - 1 for y = 1, len1 do - olddiag = column[y] + local olddiag = column[y] column[y] = math.min(column[y] + 1, column[y-1] + 1, lastdiag + (str1:byte(y-1) == str2:byte(x-1) and 0 or 1)) lastdiag = olddiag end @@ -93,7 +93,7 @@ local function longest_common_subsequence (str1, str2) if type(str2) ~= 'string' then error(('[errors/internal]: Bad argument #1 to longest_common_subsequence, expected string, got %s (%s)'):format(str2, type(str2))) end -- Do work - local str1, str2 = str1:lower(), str2:lower() + str1, str2 = str1:lower(), str2:lower() local len1, len2 = #str1, #str2 -- Quick cut-offs to save time @@ -139,7 +139,7 @@ local function jaccard_similarity_of_words (str1, str2) end -- Work work - local words1, words2, all = {}, {}, {}, {} + local words1, words2, all = {}, {}, {} for _, word in ipairs(split_string_into_words(str1)) do words1[word], all[word] = true, true end