mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Apply suggestions from code review
This commit is contained in:
parent
f39a7a4cd4
commit
1d5f554e88
4 changed files with 6 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue