Revert "Add autocorrect checks to ExplainFormatter"

This reverts commit 1b6fe40a3b.
This commit is contained in:
fn ⌃ ⌥ 2021-10-31 22:12:21 -07:00
parent 61fc99e107
commit a40fdee33f
3 changed files with 6 additions and 17 deletions

View file

@ -27,7 +27,7 @@ module Ameba::Cli
runner = Ameba.run(config) runner = Ameba.run(config)
if location = opts.location_to_explain if location = opts.location_to_explain
runner.explain(location, autocorrect: opts.autocorrect?) runner.explain(location)
else else
exit 1 unless runner.success? exit 1 unless runner.success?
end end

View file

@ -11,7 +11,6 @@ module Ameba::Formatter
getter output : IO::FileDescriptor | IO::Memory getter output : IO::FileDescriptor | IO::Memory
getter location : Crystal::Location getter location : Crystal::Location
getter? autocorrect : Bool
# Creates a new instance of ExplainFormatter. # Creates a new instance of ExplainFormatter.
# Accepts *output* which indicates the io where the explanation will be wrtitten to. # Accepts *output* which indicates the io where the explanation will be wrtitten to.
@ -21,7 +20,7 @@ module Ameba::Formatter
# ExplainFormatter.new output, # ExplainFormatter.new output,
# {file: path, line: line_number, column: column_number} # {file: path, line: line_number, column: column_number}
# ``` # ```
def initialize(@output, location, @autocorrect = false) def initialize(@output, location)
@location = Crystal::Location.new(location[:file], location[:line], location[:column]) @location = Crystal::Location.new(location[:file], location[:line], location[:column])
end end
@ -41,22 +40,12 @@ module Ameba::Formatter
return unless (location = issue.location) return unless (location = issue.location)
issue_info = [ output_title "ISSUE INFO"
output_paragraph [
issue.message.colorize(:red).to_s, issue.message.colorize(:red).to_s,
location.to_s.colorize(:cyan).to_s, location.to_s.colorize(:cyan).to_s,
] ]
if issue.correctable?
if autocorrect?
issue_info << "Corrected".colorize(:green).to_s
else
issue_info << "Correctable".colorize(:yellow).to_s
end
end
output_title "ISSUE INFO"
output_paragraph issue_info
if affected_code = affected_code(issue, context_lines: 3) if affected_code = affected_code(issue, context_lines: 3)
output_title "AFFECTED CODE" output_title "AFFECTED CODE"
output_paragraph affected_code output_paragraph affected_code

View file

@ -160,8 +160,8 @@ module Ameba
# runner.run # runner.run
# runner.explain({file: file, line: l, column: c}) # runner.explain({file: file, line: l, column: c})
# ``` # ```
def explain(location, output = STDOUT, autocorrect = false) def explain(location, output = STDOUT)
Formatter::ExplainFormatter.new(output, location, autocorrect).finished @sources Formatter::ExplainFormatter.new(output, location).finished @sources
end end
# Indicates whether the last inspection successful or not. # Indicates whether the last inspection successful or not.