class AdLint::Postfilter::Config
Public Class Methods
new(config_fpath, traits_fpath, strip_num)
click to toggle source
# File lib/adlint/postfilter/config.rb, line 44 def initialize(config_fpath, traits_fpath, strip_num) load_postfilter_config(config_fpath) load_adlint_traits(traits_fpath) @initial_header_suppression = create_adlint_initial_header_suppression @platform_header_suppression = create_platform_header_supression(strip_num) @project_wide_suppressions = create_project_wide_suppressions end
Public Instance Methods
individual_suppression_control_enabled?()
click to toggle source
# File lib/adlint/postfilter/config.rb, line 55 def individual_suppression_control_enabled? @@config_yaml["message_traits"]["enable_individual_suppression_control"] end
msg_fpath()
click to toggle source
# File lib/adlint/postfilter/config.rb, line 59 def msg_fpath subclass_responsibility end
suppression_list()
click to toggle source
# File lib/adlint/postfilter/config.rb, line 63 def suppression_list subclass_responsibility end
Private Instance Methods
adlint_traits()
click to toggle source
# File lib/adlint/postfilter/config.rb, line 85 def adlint_traits @@adlint_traits end
create_adlint_initial_header_suppression()
click to toggle source
# File lib/adlint/postfilter/config.rb, line 68 def create_adlint_initial_header_suppression AdLintInitialHeaderSuppression.new( Pathname.new(adlint_traits.of_compiler.initial_header).realpath, Pathname.new(adlint_traits.of_project.initial_header).realpath) end
create_platform_header_supression(strip_num)
click to toggle source
# File lib/adlint/postfilter/config.rb, line 74 def create_platform_header_supression(strip_num) root_dpath = Pathname.getwd.realpath strip_num.times { root_dpath = root_dpath.parent } PlatformHeaderSuppression.new(root_dpath) end
create_project_wide_suppressions()
click to toggle source
# File lib/adlint/postfilter/config.rb, line 80 def create_project_wide_suppressions list = @@config_yaml["message_traits"]["suppression_list"] || [] list.map { |mesg_id| ProjectWideSuppression.new(mesg_id.to_sym) } end
load_adlint_traits(traits_fpath)
click to toggle source
# File lib/adlint/postfilter/config.rb, line 116 def load_adlint_traits(traits_fpath) return if defined?(@@adlint_traits) # NOTE: Psych::SyntaxError is a subclass of the builtin ::SyntaxError. # The rescue clause without error_type is equivalent to # `rescue StandardError'. So, the rescue clause without error_type # cannot catch Psych::SyntaxError. begin @@adlint_traits = Traits.instance @@adlint_traits.read_from(traits_fpath) rescue SyntaxError, StandardError # NOTE: If the AdLint's traits file is invalid, child analysis command # will encounter the same problem and will notice it. # So, nothing to be done. end end
load_postfilter_config(config_fpath)
click to toggle source
# File lib/adlint/postfilter/config.rb, line 89 def load_postfilter_config(config_fpath) return if defined?(@@config_yaml) # NOTE: Psych::SyntaxError is a subclass of the builtin ::SyntaxError. # The rescue clause without error_type is equivalent to # `rescue StandardError'. So, the rescue clause without error_type # cannot catch Psych::SyntaxError. begin @@config_yaml = File.open(config_fpath, "r:utf-8") { |io| case array_or_stream = YAML.load_stream(io) when Array # NOTE: YAML.load_stream returns Array in Ruby 1.9.3-preview1. array_or_stream.first when YAML::Stream array_or_stream.documents.first end } rescue SyntaxError, StandardError => ex $stderr.puts "#{command}: Failed to read `#{config_fpath}'." $stderr.puts $stderr.puts "Detailed message is below;" $stderr.puts ex.message, ex.backtrace $stderr.puts exit 11 end end