Class: CC::Engine::RemediationPoints

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/engine/remediation_points.rb

Overview

Generates the remediation points for a given linter

Constant Summary collapse

DEFAULT_POINTS =

The default points for the smallest issue

50_000
POINTS =

Maps the linters to their remediation points

{
  'AlignmentTabs' => DEFAULT_POINTS,
  'AltText' => DEFAULT_POINTS * 2,
  'ClassAttributeWithStaticValue' => DEFAULT_POINTS,
  'ClassesBeforeIds' => DEFAULT_POINTS,
  'ConsecutiveComments' => DEFAULT_POINTS,
  'ConsecutiveSilentScripts' => DEFAULT_POINTS,
  'EmptyObjectReference' => DEFAULT_POINTS,
  'EmptyScript' => DEFAULT_POINTS,
  'FinalNewline' => DEFAULT_POINTS,
  'HtmlAttributes' => DEFAULT_POINTS * 2,
  'IdNames' => DEFAULT_POINTS * 5,
  'ImplicitDiv' => DEFAULT_POINTS,
  'Indentation' => DEFAULT_POINTS,
  'InlineStyles' => DEFAULT_POINTS * 2,
  'InstanceVariables' => DEFAULT_POINTS * 3,
  'LeadingCommentSpace' => DEFAULT_POINTS,
  'LineLength' => DEFAULT_POINTS,
  'MultilinePipe' => DEFAULT_POINTS * 2,
  'MultilineScript' => DEFAULT_POINTS,
  'ObjectReferenceAttributes' => DEFAULT_POINTS * 2,
  'RepeatedId' => DEFAULT_POINTS * 2,
  'RuboCop' => DEFAULT_POINTS * 5,
  'RubyComments' => DEFAULT_POINTS,
  'SpaceBeforeScript' => DEFAULT_POINTS,
  'SpaceInsideHashAttributes' => DEFAULT_POINTS,
  'Syntax' => DEFAULT_POINTS,
  'TagName' => DEFAULT_POINTS,
  'TrailingWhitespace' => DEFAULT_POINTS,
  'UnnecessaryInterpolation' => DEFAULT_POINTS,
  'UnnecessaryStringOutput' => DEFAULT_POINTS,
  'ViewLength' => DEFAULT_POINTS * 4
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(linter) ⇒ RemediationPoints

Instantiates a remediate points value for a linter

Examples:

CC::Engine::RemediationPoints.new("TagName")

Parameters:

  • linter (String)

    the name of the linter to remediate


56
57
58
# File 'lib/cc/engine/remediation_points.rb', line 56

def initialize(linter)
  @linter = linter
end

Instance Method Details

#empty?Boolean

Checks whether there is a points assignment for the linter

Examples:

points = CC::Engine::RemediationPoints.new("TagName")
points.empty?  #=> false

Returns:

  • (Boolean)

68
69
70
# File 'lib/cc/engine/remediation_points.rb', line 68

def empty?
  !points
end

#pointsInteger

The number of remediation points for the linter

Examples:

points = CC::Engine::RemediationPoints.new("TagName")
points.points

Returns:

  • (Integer)

80
81
82
# File 'lib/cc/engine/remediation_points.rb', line 80

def points
  POINTS[linter]
end

#to_json(*args) ⇒ String

Converts the remediation points into a JSON format

Examples:

points = CC::Engine::RemediationPoints.new("TagName")
points.to_json

Returns:

  • (String)

    a JSON document of the remediation points


92
93
94
95
96
# File 'lib/cc/engine/remediation_points.rb', line 92

def to_json(*args)
  return unless points

  points.to_json(*args)
end