Sha256: 5ccdafba693b5033de3035c4854fbb102e876e1ab080e4fd7d49caeb3e511f0e

Contents?: true

Size: 911 Bytes

Versions: 7

Compression:

Stored size: 911 Bytes

Contents

# frozen_string_literal: true

require_relative 'simple_warning_formatter'

module Reek
  module Report
    module Formatter
      #
      # Formatter that adds a link to the wiki to the basic message from
      # SimpleWarningFormatter.
      #
      class WikiLinkWarningFormatter < SimpleWarningFormatter
        BASE_URL_FOR_HELP_LINK = 'https://github.com/troessner/reek/blob/master/docs/'.freeze

        def format(warning)
          "#{super} [#{explanatory_link(warning)}]"
        end

        def format_hash(warning)
          super.merge('wiki_link' => explanatory_link(warning))
        end

        private

        def explanatory_link(warning)
          "#{BASE_URL_FOR_HELP_LINK}#{class_name_to_param(warning.smell_type)}.md"
        end

        # :reek:UtilityFunction
        def class_name_to_param(name)
          name.split(/(?=[A-Z])/).join('-')
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reek-4.8.1 lib/reek/report/formatter/wiki_link_warning_formatter.rb
reek-4.8.0 lib/reek/report/formatter/wiki_link_warning_formatter.rb
reek-4.7.3 lib/reek/report/formatter/wiki_link_warning_formatter.rb
reek-4.7.2 lib/reek/report/formatter/wiki_link_warning_formatter.rb
reek-4.7.1 lib/reek/report/formatter/wiki_link_warning_formatter.rb
reek-4.7.0 lib/reek/report/formatter/wiki_link_warning_formatter.rb
reek-4.6.2 lib/reek/report/formatter/wiki_link_warning_formatter.rb