Class: PuppetX::Puppetlabs::Migration::MigrationChecker

Inherits:
Puppet::Pops::Migration::MigrationChecker
  • Object
show all
Defined in:
lib/puppet_x/puppetlabs/migration/migration_checker.rb

Overview

An implementation of the MigrationChecker API This class should be added in the puppet context under the key :migration_Checker when the future parser and evaluator is operating in order to get callbacks to the methods of this class.

When the transaction using the MigrationChecker has finished, the collected diagnostics can be obtained by getting the Acceptor and asking it for all diagnostics, errors, warnings etc.

Defined Under Namespace

Classes: MigrationIssueAcceptor, SeverityProducer

Constant Summary collapse

Issues =
PuppetX::Puppetlabs::Migration::MigrationIssues

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMigrationChecker

Returns a new instance of MigrationChecker.



50
51
52
53
54
55
56
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 50

def initialize
  @acceptor = MigrationIssueAcceptor.new
  @diagnostic_producer = Puppet::Pops::Validation::DiagnosticProducer.new(
    @acceptor,
    SeverityProducer.new,
    Puppet::Pops::Model::ModelLabelProvider.new)
end

Instance Attribute Details

#acceptorObject (readonly)

Returns the value of attribute acceptor.



48
49
50
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 48

def acceptor
  @acceptor
end

#diagnostic_producerObject (readonly)

Returns the value of attribute diagnostic_producer.



47
48
49
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 47

def diagnostic_producer
  @diagnostic_producer
end

Instance Method Details

#report_ambiguous_float(o) ⇒ Object



75
76
77
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 75

def report_ambiguous_float(o)
  report(Issues::MIGRATE4_AMBIGUOUS_FLOAT, o, {:value => o.value })
end

#report_ambiguous_integer(o) ⇒ Object



69
70
71
72
73
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 69

def report_ambiguous_integer(o)
  radix = o.radix
  return unless radix == 8 || radix == 16
  report(Issues::MIGRATE4_AMBIGUOUS_INTEGER, o, {:value => o.value, :radix => radix})
end

#report_array_last_in_block(o) ⇒ Object



135
136
137
138
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 135

def report_array_last_in_block(o)
  return unless o.is_a?(Puppet::Pops::Model::LiteralList)
  report(Issues::MIGRATE4_ARRAY_LAST_IN_BLOCK, o)
end

#report_empty_string_true(value, o) ⇒ Object



79
80
81
82
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 79

def report_empty_string_true(value, o)
  return unless value == ''
  report(Issues::MIGRATE4_EMPTY_STRING_TRUE, o)
end

#report_equality_type_mismatch(left, right, o) ⇒ Object



90
91
92
93
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 90

def report_equality_type_mismatch(left, right, o)
  return unless is_type_diff?(left, right)
  report(Issues::MIGRATE4_EQUALITY_TYPE_MISMATCH, o, {:left => left, :right => right })
end

#report_in_expression(o) ⇒ Object



131
132
133
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 131

def report_in_expression(o)
  report(Issues::MIGRATE4_REVIEW_IN_EXPRESSION, o)
end

#report_option_type_mismatch(test_value, option_value, option_expr, matching_expr) ⇒ Object



95
96
97
98
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 95

def report_option_type_mismatch(test_value, option_value, option_expr, matching_expr)
  return unless is_type_diff?(test_value, option_value) || is_match_diff?(test_value, option_value)
  report(Issues::MIGRATE4_OPTION_TYPE_MISMATCH, matching_expr, {:left => test_value, :right => option_value, :option_expr => option_expr})
end

#report_uc_bareword_type(value, o) ⇒ Object



84
85
86
87
88
# File 'lib/puppet_x/puppetlabs/migration/migration_checker.rb', line 84

def report_uc_bareword_type(value, o)
  return unless value.is_a?(Puppet::Pops::Types::PAnyType)
  return unless o.is_a?(Puppet::Pops::Model::QualifiedReference)
  report(Issues::MIGRATE4_UC_BAREWORD_IS_TYPE, o, {:type => value.to_s })
end