Class: SuppressionsPopulator

Inherits:
Object
  • Object
show all
Defined in:
lib/suppressions_populator.rb

Overview

Populates a string with the suppression xml, given a list of tokens

Constant Summary collapse

HEADER =
<<~HEADER
  <?xml version="1.0"?>
  <!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
        "https://checkstyle.org/dtds/suppressions_1_2.dtd">

  <suppressions>
HEADER
<<~FOOTER
  </suppressions>
FOOTER

Instance Method Summary collapse

Constructor Details

#initialize(tokens) ⇒ SuppressionsPopulator

Returns a new instance of SuppressionsPopulator.



17
18
19
# File 'lib/suppressions_populator.rb', line 17

def initialize(tokens)
  @tokens = tokens
end

Instance Method Details

#populateObject



21
22
23
24
25
# File 'lib/suppressions_populator.rb', line 21

def populate
  "#{HEADER}\n#{@tokens.uniq do |token|
                  [token.file_name, token.offense]
                end.map(&:to_suppression).join("\n")}\n\n#{FOOTER}"
end