Skip to content

Commit

Permalink
Minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Oct 8, 2024
1 parent 522933e commit 9aeb25b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/ameba/rule/lint/typos.cr
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ module Ameba::Rule::Lint
end

private record Typo,
path : String,
typo : String,
corrections : Array(String),
location : {Int32, Int32},
Expand All @@ -83,24 +82,23 @@ module Ameba::Rule::Lint

return if typo.empty? || corrections.empty?

path = issue["path"].as_s
line_no = issue["line_num"].as_i
col_no = issue["byte_offset"].as_i + 1
end_col_no = col_no + typo.size - 1

new(path, typo, corrections,
{line_no, col_no}, {line_no, end_col_no})
new(typo, corrections,
{line_no, col_no},
{line_no, end_col_no})
end
end

protected def typos_from(source : Source) : Array(Typo)?
unless bin_path = self.bin_path
if fail_on_error?
raise RuntimeError.new "Could not find `typos` executable"
end
return
if bin_path = self.bin_path
return Typos.typos_from(bin_path, source)
end
if fail_on_error?
raise RuntimeError.new "Could not find `typos` executable"
end
Typos.typos_from(bin_path, source)
end
end
end

0 comments on commit 9aeb25b

Please sign in to comment.