Sha256: b2ecc5ad211a8793a7bcbb9dae999e0d02694acf0922fd3da0e32a3f30ea2f34
Contents?: true
Size: 1.76 KB
Versions: 5
Compression:
Stored size: 1.76 KB
Contents
# frozen_string_literal: true require "active_support/core_ext/string/inflections" require "shellwords" require "pathname" require "tty-link" require "rainbow" module Rfix module Extension module Offense STAR = Rainbow("⭑").yellow CROSS = Rainbow("✗").red CHECK = Rainbow("✓").green CIRCLE = Rainbow("⍟").blue include Dry::Core::Constants def where "#{line}:#{real_column}" end def info message.split(": ", 2).last.delete("\n") end def msg Rainbow(info).italic end def code message.split(": ", 2).first end def relative_path return EMPTY_STRING unless location.respond_to?(:source_buffer) location.source_buffer.name.sub(Dir.pwd, EMPTY_STRING).chars.drop_while do |char| char == "/" end.join rescue ArgumentError nil end def clickable_path Rainbow("#{relative_path}:#{where}").italic end def clickable_plain_severity cop_name.split("/", 2).then do |department, cop| return nil if [cop, department].any?(&:nil?) { type: department.parameterize, cop: cop.parameterize } end.then do |options| "https://docs.rubocop.org/rubocop/cops_%<type>s.html#%<type>s%<cop>s" % options end.then do |url| TTY::Link.link_to(cop_name, url) end end def clickable_severity clickable_plain_severity && Rainbow(clickable_plain_severity).italic end def icon { uncorrected: CIRCLE, unsupported: CROSS, correctable: STAR, corrected: CHECK }.fetch(status) end def escape(str) Shellwords.escape(str) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems