Sha256: 702c081b05345f8c75fcbe3472ebcf7459da42bb3a74c8ea23cc161fd51e7805

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

PuppetLint.new_check(:resource_reference_without_title_capital) do
  def check
    resource_indexes.each do |resource|
      resource[:param_tokens].select { |param_token|
        ['require', 'subscribe', 'notify', 'before', 'consume', 'export'].include? param_token.value
      }.each do |param_token|
        value_token = param_token.next_code_token
        check = value_token.next_token
        until resource[:param_tokens].include? check or not resource[:tokens].include? check or check.nil?
          case value_token.next_token.type
          when :CLASSREF
            begin
              if value_token.next_token.next_token.type == :LBRACK
                check_token = value_token.next_token.next_token.next_token
                if check_token.type == :CLASSREF
                  notify :error, {
                    :message => 'resource reference with title with capital letter',
                    :line    => check_token.line,
                    :column  => check_token.column
                  }
                elsif check_token.type == :NAME
                  notify :error, {
                    :message => 'resource reference with title with missing quotes',
                    :line    => check_token.line,
                    :column  => check_token.column
                  }
                end
              end
              value_token = value_token.next_token
              check = value_token.next_token
            end
          else
            value_token = value_token.next_token
            check = value_token.next_token
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puppet-lint-resource_reference_syntax-1.0.14 lib/puppet-lint/plugins/resource_reference_without_title_capital.rb
puppet-lint-resource_reference_syntax-1.0.13 lib/puppet-lint/plugins/resource_reference_without_title_capital.rb
puppet-lint-resource_reference_syntax-1.0.12 lib/puppet-lint/plugins/resource_reference_without_title_capital.rb
puppet-lint-resource_reference_syntax-1.0.11 lib/puppet-lint/plugins/resource_reference_without_title_capital.rb
puppet-lint-resource_reference_syntax-1.0.10 lib/puppet-lint/plugins/resource_reference_without_title_capital.rb