Sha256: e522e2e1da468680a879af72e3650066c831ece8420f95d1901a61efa2fb5cad

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

require "virtus"
require "json"

module CCEngine
  class Issue
    include Virtus.model(strict: true)

    attribute :check_name, String
    attribute :description, String
    attribute :categories, Array[String]
    attribute :location
    attribute :remediation_points
    attribute :content
    attribute :fingerprint

    def render
      to_hash.to_json + "\0"
    end

    def to_json
      to_hash.to_json
    end

    def to_hash
      {
        type: "issue",
        check_name: check_name,
        description: description,
        categories: categories,
        location: location.to_hash
      }.merge(remediation_points_hash).merge(content_hash).merge(fingerprint_hash)
    end

    private

    def remediation_points_hash
      return {} unless remediation_points

      {
        remediation_points: remediation_points
      }
    end

    def content_hash
      return {} unless content

      {
        content: {
          body: content
        }
      }
    end

    def fingerprint_hash
      return {} unless fingerprint

      {
        fingerprint: fingerprint
      }
    end
  end
end

Version data entries

6 entries across 4 versions & 2 rubygems

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/codeclimate-engine-rb-0.4.1/lib/cc_engine/issue.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/codeclimate-engine-rb-0.4.1/lib/cc_engine/issue.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/codeclimate-engine-rb-0.4.1/lib/cc_engine/issue.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/codeclimate-engine-rb-0.4.1/lib/cc_engine/issue.rb
codeclimate-engine-rb-0.4.1 lib/cc_engine/issue.rb
codeclimate-engine-rb-0.4.0 lib/cc_engine/issue.rb