Class: Sarif::ReportingDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/sarif/reporting_descriptor.rb

Overview

Metadata that describes a specific report produced by the tool, as part of the analysis it provides or its runtime reporting.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, deprecated_ids: nil, guid: nil, deprecated_guids: nil, name: nil, deprecated_names: nil, short_description: nil, full_description: nil, message_strings: nil, default_configuration: nil, help_uri: nil, help: nil, relationships: [], properties: nil) ⇒ ReportingDescriptor

Returns a new instance of ReportingDescriptor.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sarif/reporting_descriptor.rb', line 8

def initialize(id:, deprecated_ids: nil, guid: nil, deprecated_guids: nil, name: nil, deprecated_names: nil, short_description: nil, full_description: nil, message_strings: nil, default_configuration: nil, help_uri: nil, help: nil, relationships: [], properties: nil)
  @id = id
  @deprecated_ids = deprecated_ids
  @guid = guid
  @deprecated_guids = deprecated_guids
  @name = name
  @deprecated_names = deprecated_names
  @short_description = short_description
  @full_description = full_description
  @message_strings = message_strings
  @default_configuration = default_configuration
  @help_uri = help_uri
  @help = help
  @relationships = relationships
  @properties = properties
end

Instance Attribute Details

#default_configurationObject

Returns the value of attribute default_configuration.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def default_configuration
  @default_configuration
end

#deprecated_guidsObject

Returns the value of attribute deprecated_guids.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def deprecated_guids
  @deprecated_guids
end

#deprecated_idsObject

Returns the value of attribute deprecated_ids.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def deprecated_ids
  @deprecated_ids
end

#deprecated_namesObject

Returns the value of attribute deprecated_names.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def deprecated_names
  @deprecated_names
end

#full_descriptionObject

Returns the value of attribute full_description.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def full_description
  @full_description
end

#guidObject

Returns the value of attribute guid.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def guid
  @guid
end

#helpObject

Returns the value of attribute help.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def help
  @help
end

#help_uriObject

Returns the value of attribute help_uri.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def help_uri
  @help_uri
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def id
  @id
end

#message_stringsObject

Returns the value of attribute message_strings.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def message_strings
  @message_strings
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def name
  @name
end

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def properties
  @properties
end

#relationshipsObject

Returns the value of attribute relationships.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def relationships
  @relationships
end

#short_descriptionObject

Returns the value of attribute short_description.



6
7
8
# File 'lib/sarif/reporting_descriptor.rb', line 6

def short_description
  @short_description
end

Class Method Details

.from_hash(h) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/sarif/reporting_descriptor.rb', line 48

def self.from_hash(h)
  return nil if h.nil?
  new(
    id: h["id"],
    deprecated_ids: h["deprecatedIds"],
    guid: h["guid"],
    deprecated_guids: h["deprecatedGuids"],
    name: h["name"],
    deprecated_names: h["deprecatedNames"],
    short_description: MultiformatMessageString.from_hash(h["shortDescription"]),
    full_description: MultiformatMessageString.from_hash(h["fullDescription"]),
    message_strings: h["messageStrings"],
    default_configuration: ReportingConfiguration.from_hash(h["defaultConfiguration"]),
    help_uri: h["helpUri"],
    help: MultiformatMessageString.from_hash(h["help"]),
    relationships: h["relationships"]&.map { |v| ReportingDescriptorRelationship.from_hash(v) } || [],
    properties: h["properties"]
  )
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



68
69
70
71
# File 'lib/sarif/reporting_descriptor.rb', line 68

def ==(other)
  return false unless other.is_a?(ReportingDescriptor)
  @id == other.id && @deprecated_ids == other.deprecated_ids && @guid == other.guid && @deprecated_guids == other.deprecated_guids && @name == other.name && @deprecated_names == other.deprecated_names && @short_description == other.short_description && @full_description == other.full_description && @message_strings == other.message_strings && @default_configuration == other.default_configuration && @help_uri == other.help_uri && @help == other.help && @relationships == other.relationships && @properties == other.properties
end

#hashObject



75
76
77
# File 'lib/sarif/reporting_descriptor.rb', line 75

def hash
  [@id, @deprecated_ids, @guid, @deprecated_guids, @name, @deprecated_names, @short_description, @full_description, @message_strings, @default_configuration, @help_uri, @help, @relationships, @properties].hash
end

#to_hObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sarif/reporting_descriptor.rb', line 25

def to_h
  h = {}
  h["id"] = @id
  h["deprecatedIds"] = @deprecated_ids if @deprecated_ids&.any?
  h["guid"] = @guid unless @guid.nil?
  h["deprecatedGuids"] = @deprecated_guids if @deprecated_guids&.any?
  h["name"] = @name unless @name.nil?
  h["deprecatedNames"] = @deprecated_names if @deprecated_names&.any?
  h["shortDescription"] = @short_description&.to_h unless @short_description.nil?
  h["fullDescription"] = @full_description&.to_h unless @full_description.nil?
  h["messageStrings"] = @message_strings unless @message_strings.nil?
  h["defaultConfiguration"] = @default_configuration&.to_h unless @default_configuration.nil?
  h["helpUri"] = @help_uri unless @help_uri.nil?
  h["help"] = @help&.to_h unless @help.nil?
  h["relationships"] = @relationships&.map(&:to_h) if @relationships&.any?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



44
45
46
# File 'lib/sarif/reporting_descriptor.rb', line 44

def to_json(pretty: false)
  pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h)
end