module CC::Service::QualityHelper

Public Instance Methods

constant_basename(name) click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 45
def constant_basename(name)
  if name.include?(".")
    File.basename(name)
  else
    name
  end
end
constant_name() click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 6
def constant_name
  payload["constant_name"]
end
improved?() click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 2
def improved?
  remediation_cost < previous_remediation_cost
end
previous_rating() click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 22
def previous_rating
  with_article(payload["previous_rating"])
end
previous_remediation_cost() click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 30
def previous_remediation_cost
  payload.fetch("previous_remediation_cost", 0)
end
quality_title() click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 10
def quality_title
  if payload["rating"].present?
    "Refactor #{constant_name} from #{rating} on Code Climate"
  else
    "Refactor #{constant_name} on Code Climate"
  end
end
rating() click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 18
def rating
  with_article(payload["rating"])
end
remediation_cost() click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 26
def remediation_cost
  payload.fetch("remediation_cost", 0)
end
with_article(letter, bold = false) click to toggle source
# File lib/cc/helpers/quality_helper.rb, line 34
def with_article(letter, bold = false)
  letter ||= "?"

  text = bold ? "*#{letter}*" : letter
  if %w[A F].include?(letter.to_s)
    "an #{text}"
  else
    "a #{text}"
  end
end