Decides on the severity of a given issue. The produced severity is one of `:error`, `:warning`, or `:ignore`. By default, a severity of `:error` is produced for all issues. To configure the severity of an issue call `severity=(issue, level)`.
@return [Symbol] a symbol representing the severity `:error`, `:warning`, or `:ignore`
@api public
@see {severity} @api public
# File lib/puppet/pops/validation.rb, line 116 def [] issue severity issue end
Override a default severity with the given severity level.
@param issue [Puppet::Pops::Issues::Issue] the issue for which to set severity @param level [Symbol] the severity level (:error, :warning, or :ignore). @api public
# File lib/puppet/pops/validation.rb, line 126 def []=(issue, level) raise Puppet::DevError.new("Attempt to set validation severity for something that is not an Issue. (Got #{issue.class})") unless issue.is_a? Puppet::Pops::Issues::Issue raise Puppet::DevError.new("Illegal severity level: #{option}") unless @@severity_hash[level] raise Puppet::DevError.new("Attempt to demote the hard issue '#{issue.issue_code}' to #{level}") unless issue.demotable? || level == :error @severities[issue] = level end
Checks if the given issue is valid. @api private
# File lib/puppet/pops/validation.rb, line 146 def assert_issue issue raise Puppet::DevError.new("Attempt to get validation severity for something that is not an Issue. (Got #{issue.class})") unless issue.is_a? Puppet::Pops::Issues::Issue end
Checks if the given severity level is valid. @api private
# File lib/puppet/pops/validation.rb, line 153 def assert_severity level raise Puppet::DevError.new("Illegal severity level: #{option}") unless @@severity_hash[level] end
Returns the severity of the given issue. @return [Symbol] severity level :error, :warning, or :ignore @api public
# File lib/puppet/pops/validation.rb, line 108 def severity(issue) assert_issue(issue) @severities[issue] end
Returns `true` if the issue should be reported or not. @return [Boolean] this implementation returns true for errors and warnings
@api public
# File lib/puppet/pops/validation.rb, line 138 def should_report? issue diagnose = @severities[issue] diagnose == :error || diagnose == :warning || diagnose == :deprecation end
Creates a new instance where all issues are diagnosed as :error unless overridden. @param [Symbol] specifies default severity if :error is not wanted as the default @api public
# File lib/puppet/pops/validation.rb, line 99 def initialize(default_severity = :error) # If diagnose is not set, the default is returned by the block @severities = Hash.new default_severity end