Sha256: 48353a4a6c396a9ea26af3ee75714a8f5df30cfc2183be87e498ea399a8a5cd3

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require_relative 'base_error'

module Reek
  module Errors
    # Gets raised when trying to configure a detector which is unknown to us.
    # This might happen for multiple reasons. The users might have a typo in
    # his comment or he might use a detector that does not exist anymore.
    class BadDetectorInCommentError < BaseError
      UNKNOWN_SMELL_DETECTOR_MESSAGE = <<-MESSAGE.freeze

        Error: You are trying to configure an unknown smell detector '%<detector>s' in one
        of your source code comments.
        The source is '%<source>s' and the comment belongs to the expression starting in line %<line>d.
        Here's the original comment:

        %<comment>s

        Please see the Reek docs for:
          * how to configure Reek via source code comments: https://github.com/troessner/reek/blob/master/docs/Smell-Suppression.md
          * what smell detectors are available: https://github.com/troessner/reek/blob/master/docs/Code-Smells.md
        Update the offensive comment (or remove it if no longer applicable) and re-run Reek.

      MESSAGE

      def initialize(detector_name:, source:, line:, original_comment:)
        message = format(UNKNOWN_SMELL_DETECTOR_MESSAGE,
                         detector: detector_name,
                         source: source,
                         line: line,
                         comment: original_comment)
        super message
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-4.8.1 lib/reek/errors/bad_detector_in_comment_error.rb
reek-4.8.0 lib/reek/errors/bad_detector_in_comment_error.rb