Sha256: 8fb6bfd5e3b0d40400985ec9b1b91b90441f837a1f83fb13a93fc29c0071bccf

Contents?: true

Size: 839 Bytes

Versions: 56

Compression:

Stored size: 839 Bytes

Contents

module CC
  module Analyzer
    class IssueValidator
      CHECKS = IssueValidations.validations.freeze

      attr_reader :error

      def initialize(issue)
        @issue = issue
        validate
      end

      def validate
        return @valid unless @valid.nil?

        if issue && invalid_messages.any?
          @error = {
            message: "#{invalid_messages.join("; ")}: `#{issue}`.",
            issue: issue,
          }
          @valid = false
        else
          @valid = true
        end
      end
      alias valid? validate

      private

      attr_reader :issue

      def invalid_messages
        @invalid_messages ||= CHECKS.each_with_object([]) do |check, result|
          validator = check.new(issue)
          result << validator.message unless validator.valid?
        end
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
codeclimate-0.69.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.68.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.67.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.66.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.65.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.64.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.7 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.6 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.5 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.4 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.3 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.2 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.1 lib/cc/analyzer/issue_validator.rb
codeclimate-0.63.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.62.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.61.1 lib/cc/analyzer/issue_validator.rb
codeclimate-0.61.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.60.1 lib/cc/analyzer/issue_validator.rb
codeclimate-0.60.0 lib/cc/analyzer/issue_validator.rb
codeclimate-0.59.1 lib/cc/analyzer/issue_validator.rb