lib/puppet-lint/data.rb
def parse_control_comments
      @ignore_overrides.each_key { |check| @ignore_overrides[check].clear }

      comment_token_types = Set[:COMMENT, :MLCOMMENT, :SLASH_COMMENT]

      comment_tokens = tokens.select { |token|
        comment_token_types.include?(token.type)
      }
      control_comment_tokens = comment_tokens.select { |token|
        token.value.strip =~ /\Alint:(ignore:[\w\d]+|endignore)/
      }

      stack = []
      control_comment_tokens.each do |token|
        control, reason = token.value.strip.split(' ', 2)
        split_control = control.split(':')
        command = split_control[1]

        if command == 'ignore'
          check = split_control[2].to_sym

          if token.prev_token && !Set[:NEWLINE, :INDENT].include?(token.prev_token.type)
            # control comment at the end of the line, override applies to
            # a single line only
            (ignore_overrides[check] ||= {})[token.line] = reason
          else
            stack << [token.line, reason, check]
          end
        else
          start = stack.pop
          unless start.nil?
            (start[0]..token.line).each do |i|
              (ignore_overrides[start[2]] ||= {})[i] = start[1]
            end
          end
        end
      end
    end
# Internal: Parses all COMMENT, MLCOMMENT and SLASH_COMMENT tokens looking
# for control comments (comments that enable or disable checks). Builds the
# contents of the `ignore_overrides` hash.
#
# Returns nothing.
Parses all COMMENT, MLCOMMENT and SLASH_COMMENT tokens looking
for control comments (comments that enable or disable checks). Builds the
contents of the `ignore_overrides` hash.

Returns nothing.
Parses all COMMENT MLCOMMENT and SLASH_COMMENT tokens looking for control comments ( comments that enable or disable checks ) . Builds the contents of the ` ignore_overrides ` hash . Returns nothing .
def parse_control_comments
      @ignore_overrides.each_key { |check| @ignore_overrides[check].clear }
      comment_token_types = Set[:COMMENT, :MLCOMMENT, :SLASH_COMMENT]
      comment_tokens = tokens.select { |token|
        comment_token_types.include?(token.type)
      }
      control_comment_tokens = comment_tokens.select { |token|
        token.value.strip =~ /\Alint:(ignore:[\w\d]+|endignore)/
      }
      stack = []
      control_comment_tokens.each do |token|
        control, reason = token.value.strip.split(' ', 2)
        split_control = control.split(':')
        command = split_control[1]
        if command == 'ignore'
          check = split_control[2].to_sym
          if token.prev_token && !Set[:NEWLINE, :INDENT].include?(token.prev_token.type)
            (ignore_overrides[check] ||= {})[token.line] = reason
          else
            stack << [token.line, reason, check]
          end
        else
          start = stack.pop
          unless start.nil?
            (start[0]..token.line).each do |i|
              (ignore_overrides[start[2]] ||= {})[i] = start[1]
            end
          end
        end
      end
    end
def parse_control_comments @ignore_overrides . each_key { | check | @ignore_overrides [ check ] . clear } comment_token_types = Set [ :COMMENT , :MLCOMMENT , :SLASH_COMMENT ] comment_tokens = tokens . select { | token | comment_token_types . include? ( token . type ) } control_comment_tokens = comment_tokens . select { | token | token . value . strip =~ / \A lint:(ignore:[ \w \d ]+|endignore) / } stack = [ ] control_comment_tokens . each do | token | control , reason = token . value . strip . split ( ' ' , 2 ) split_control = control . split ( ':' ) command = split_control [ 1 ] if command == 'ignore' check = split_control [ 2 ] . to_sym if token . prev_token && ! Set [ :NEWLINE , :INDENT ] . include? ( token . prev_token . type ) ( ignore_overrides [ check ] ||= { } ) [ token . line ] = reason else stack << [ token . line , reason , check ] end else start = stack . pop unless start . nil? ( start [ 0 ] .. token . line ) . each do | i | ( ignore_overrides [ start [ 2 ] ] ||= { } ) [ i ] = start [ 1 ] end end end end end
Internal: Parses all COMMENT, MLCOMMENT and SLASH_COMMENT tokens looking
for control comments (comments that enable or disable checks).
Internal : Parses all COMMENT MLCOMMENT and SLASH_COMMENT tokens looking for control comments ( comments that enable or disable checks ) .
# control comment at the end of the line, override applies to # a single line only