Sha256: 7bf89148ae97f66c7f4e7614c500b5fcf7b7879a1654431ed77f144da0683c3f

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 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 != :COLON && 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.1 lib/puppet-lint/plugins/check_trailing_comma.rb