class AdLint::Postfilter::SmaConfig

Attributes

line_wise_suppressions[R]
msg_fpath[R]
suppression_list[R]
tunit_wide_suppressions[R]

Public Class Methods

new(config_fpath, traits_fpath, src_fpath, strip_num, output_dpath = nil) click to toggle source
Calls superclass method AdLint::Postfilter::Config::new
# File lib/adlint/postfilter/config.rb, line 137
def initialize(config_fpath, traits_fpath,
               src_fpath, strip_num, output_dpath = nil)
  super(config_fpath, traits_fpath, strip_num)

  @msg_fpath = sma_msg_fpath_of(src_fpath, strip_num, output_dpath)
  @suppression_list =
    create_suppression_list(src_fpath, strip_num, output_dpath)
end

Private Instance Methods

collect_composing_fpaths_in(i_fpath) click to toggle source
# File lib/adlint/postfilter/config.rb, line 202
def collect_composing_fpaths_in(i_fpath)
  File.open(i_fpath, "r:binary") do |io|
    io.each_line.with_object([]) { |line, composing_fpaths|
      if line =~ /\A# \d+ "(.*)"/
        composing_fpaths.push(Pathname.new($1).realpath)
      end
    }.uniq
  end
end
collect_line_wise_annotations(fpath) click to toggle source
# File lib/adlint/postfilter/config.rb, line 212
def collect_line_wise_annotations(fpath)
  File.open(fpath, "r:binary") do |io|
    io.each_line.with_index.with_object([]) do |(line, index), annotations|
      if ann = LineWiseAnnotation.detect(line, fpath, index + 1)
        annotations.push(ann)
      end
    end
  end
end
create_line_wise_suppressions(src_fpath, strip_num, output_dpath) click to toggle source
# File lib/adlint/postfilter/config.rb, line 176
def create_line_wise_suppressions(src_fpath, strip_num, output_dpath)
  return [] unless individual_suppression_control_enabled?

  i_fpath = i_fpath_of(src_fpath, strip_num, output_dpath)
  collect_composing_fpaths_in(i_fpath).each_with_object([]) do |fpath, ary|
    collect_line_wise_annotations(fpath).each do |ann, line_no|
      ary.concat(ann.generate_suppressions)
    end
  end
end
create_suppression_list(src_fpath, strip_num, output_dpath) click to toggle source
# File lib/adlint/postfilter/config.rb, line 152
def create_suppression_list(src_fpath, strip_num, output_dpath)
  @tunit_wide_suppressions = 
    create_tunit_wide_suppressions(src_fpath, strip_num, output_dpath)
  @line_wise_suppressions =
    create_line_wise_suppressions(src_fpath, strip_num, output_dpath)

  MessageSuppressionList.new(@initial_header_suppression,
                             @platform_header_suppression,
                             @project_wide_suppressions,
                             @tunit_wide_suppressions,
                             @line_wise_suppressions)
end
create_tunit_wide_suppressions(src_fpath, strip_num, output_dpath) click to toggle source
# File lib/adlint/postfilter/config.rb, line 165
def create_tunit_wide_suppressions(src_fpath, strip_num, output_dpath)
  return [] unless individual_suppression_control_enabled?

  i_fpath = i_fpath_of(src_fpath, strip_num, output_dpath)
  if ann = find_effective_tunit_wide_annotation(src_fpath, i_fpath)
    ann.generate_suppressions
  else
    []
  end
end
find_effective_tunit_wide_annotation(src_fpath, i_fpath) click to toggle source
# File lib/adlint/postfilter/config.rb, line 187
def find_effective_tunit_wide_annotation(src_fpath, i_fpath)
  composing_fpaths = collect_composing_fpaths_in(i_fpath)

  # NOTE: If multiple tunit-wide-annotations are written in the source
  #       file, the first one will be treated as effective.
  File.open(src_fpath, "r:binary") do |io|
    io.each_line do |line|
      if ann = TranslationUnitWideAnnotation.detect(line, composing_fpaths)
        return ann
      end
    end
  end
  nil
end