Class: WhyClasses::Offense

Inherits:
Data
  • Object
show all
Defined in:
lib/why_classes/offense.rb

Overview

An immutable finding produced by a Rule.

corrector is nil for advice-only offenses, or a callable taking a Parser::Source::TreeRewriter and queueing the edits that apply the suggested refactoring.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column

Returns:

  • (Object)

    the current value of column



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def column
  @column
end

#correctableObject (readonly)

Returns the value of attribute correctable

Returns:

  • (Object)

    the current value of correctable



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def correctable
  @correctable
end

#correctorObject (readonly)

Returns the value of attribute corrector

Returns:

  • (Object)

    the current value of corrector



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def corrector
  @corrector
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def message
  @message
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def path
  @path
end

#rule_nameObject (readonly)

Returns the value of attribute rule_name

Returns:

  • (Object)

    the current value of rule_name



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def rule_name
  @rule_name
end

#severityObject (readonly)

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def severity
  @severity
end

#suggestionObject (readonly)

Returns the value of attribute suggestion

Returns:

  • (Object)

    the current value of suggestion



9
10
11
# File 'lib/why_classes/offense.rb', line 9

def suggestion
  @suggestion
end

Instance Method Details

#correctable?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/why_classes/offense.rb', line 20

def correctable?
  correctable && !corrector.nil?
end

#positionObject

Sort key: by position within a file.



25
26
27
# File 'lib/why_classes/offense.rb', line 25

def position
  [line, column]
end