# File lib/puppet-lint/plugins/check_whitespace.rb, line 94
  def check
    resource_indexes.each do |res_idx|
      indent_depth = [0]
      indent_depth_idx = 0
      level_tokens = []
      resource_tokens = res_idx[:tokens]
      resource_tokens.reject! do |token|
        COMMENT_TYPES.include? token.type
      end

      # If this is a single line resource, skip it
      first_arrow = resource_tokens.index { |r| r.type == :FARROW }
      last_arrow = resource_tokens.rindex { |r| r.type == :FARROW }
      next if first_arrow.nil?
      next if last_arrow.nil?
      next unless resource_tokens[first_arrow..last_arrow].any? { |r| r.type == :NEWLINE }

      resource_tokens.each_with_index do |token, idx|
        if token.type == :FARROW
          (level_tokens[indent_depth_idx] ||= []) << token
          prev_indent_token = resource_tokens[0..idx].rindex { |t| t.type == :INDENT }
          indent_length = resource_tokens[prev_indent_token].to_manifest.length + token.prev_code_token.to_manifest.length + 2

          if indent_depth[indent_depth_idx] < indent_length
            indent_depth[indent_depth_idx] = indent_length
          end

        elsif token.type == :LBRACE
          indent_depth_idx += 1
          indent_depth << 0
          level_tokens[indent_depth_idx] ||= []
        elsif token.type == :RBRACE
          level_tokens[indent_depth_idx].each do |arrow_tok|
            unless arrow_tok.column == indent_depth[indent_depth_idx]
              arrows_on_line = level_tokens[indent_depth_idx].select { |t| t.line == arrow_tok.line }
              notify :warning, {
                :message        => 'indentation of => is not properly aligned',
                :line           => arrow_tok.line,
                :column         => arrow_tok.column,
                :token          => arrow_tok,
                :indent_depth   => indent_depth[indent_depth_idx],
                :newline        => !(arrows_on_line.index(arrow_tok) == 0),
                :newline_indent => arrows_on_line.first.prev_code_token.prev_token.value,
              }
            end
          end
          indent_depth[indent_depth_idx] = 0
          level_tokens[indent_depth_idx].clear
          indent_depth_idx -= 1
        end
      end
    end
  end