shard-ameba/src/ameba/issue.cr

44 lines
864 B
Crystal
Raw Normal View History

2018-06-10 21:15:12 +00:00
module Ameba
# Represents an issue reported by Ameba.
struct Issue
enum Status
Enabled
Disabled
end
2018-06-10 21:15:12 +00:00
# A rule that triggers this issue.
getter rule : Rule::Base
2018-06-10 21:15:12 +00:00
# Location of the issue.
getter location : Crystal::Location?
2018-06-10 21:15:12 +00:00
# End location of the issue.
getter end_location : Crystal::Location?
2018-06-10 21:15:12 +00:00
# Issue message.
getter message : String
2018-06-10 21:15:12 +00:00
# Issue status.
getter status : Status
delegate :enabled?, :disabled?,
to: status
def initialize(@rule, @location, @end_location, @message, status : Status? = nil, @block : (Source::Corrector ->)? = nil)
@status = status || Status::Enabled
2018-06-10 21:15:12 +00:00
end
def syntax?
rule.is_a?(Rule::Lint::Syntax)
end
def correctable?
!@block.nil?
end
def correct(corrector)
@block.try &.call(corrector)
end
2018-06-10 21:15:12 +00:00
end
end