Sha256: 270bcce2168d2d985b6934f85d138c4cfa8ca1791d4ffce1ac3025e6676e35b1

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

PuppetLint.new_check(:trailing_comma) do
  def check
    # Resource and class declarations
    resource_indexes.each do |resource|
      lbo_token = resource[:tokens][-1].prev_code_token
      if lbo_token && lbo_token.type != :COMMA
        notify :warning, {
          :message => 'missing trailing comma after last parameter',
          :line    => lbo_token.next_token.line,
          :column  => lbo_token.next_token.column,
          :token   => lbo_token.next_token,
        }
      end
    end
  end

  def fix(problem)
    comma = PuppetLint::Lexer::Token.new(
      :COMMA,
      ',',
      problem[:token].line,
      problem[:token].column
    )

    idx = tokens.index(problem[:token])
    tokens.insert(idx, comma)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-lint-trailing_comma-check-0.1.0 lib/puppet-lint/plugins/check_trailing_comma.rb