Apply suggestions from code review

This commit is contained in:
fn ⌃ ⌥ 2021-10-26 08:17:06 -07:00
parent f39a7a4cd4
commit 1d5f554e88
4 changed files with 6 additions and 6 deletions

View file

@ -9,7 +9,7 @@ module Ameba
expect_issue rule, <<-CRYSTAL, number: number
number = %{number}
# ^{number} error: Large numbers should be written with underscores.
# ^{number} error: Large numbers should be written with underscores: #{expected}
CRYSTAL
expect_correction <<-CRYSTAL
@ -126,7 +126,7 @@ module Ameba
issue.rule.should_not be_nil
issue.location.to_s.should eq "source.cr:1:1"
issue.end_location.to_s.should eq "source.cr:1:7"
issue.message.should eq "Large numbers should be written with underscores."
issue.message.should match /1_200_000/
end
context "properties" do

View file

@ -91,7 +91,7 @@ module Ameba::Cli
opts.all = true
end
parser.on("-a", "--autocorrect", "Autocorrect issues") do
parser.on("--fix", "Autocorrect issues") do
opts.autocorrect = true
end

View file

@ -33,7 +33,7 @@ module Ameba::Rule::Style
int_min_digits 5
end
MSG = "Large numbers should be written with underscores."
MSG = "Large numbers should be written with underscores: %s"
def test(source)
Tokenizer.new(source).run do |token|
@ -48,7 +48,7 @@ module Ameba::Rule::Style
location.line_number,
location.column_number + token.raw.size - 1
)
issue_for location, end_location, MSG do |corrector|
issue_for location, end_location, MSG % expected do |corrector|
corrector.replace(location, end_location, expected)
end
end

View file

@ -109,7 +109,7 @@ module Ameba
source.issues.clear
end
corrected_issues.reverse_each { |issue| source.issues.unshift(issue) }
File.write(source.path, source.code) if corrected_issues.any?
File.write(source.path, source.code) unless corrected_issues.empty?
@formatter.source_finished source
end