class AdLint::Exam::CBuiltin::W0026

Public Class Methods

new(phase_ctxt) click to toggle source
Calls superclass method AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 105
def initialize(phase_ctxt)
  super
  interp = phase_ctxt[:cpp_interpreter]
  interp.on_user_header_included   += T(:check_user_include)
  interp.on_system_header_included += T(:check_system_include)
  @usr_header_fpaths = Set.new
  @sys_header_fpaths = Set.new
end

Private Instance Methods

check_system_include(sys_include_line, sys_header) click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 125
def check_system_include(sys_include_line, sys_header)
  if @sys_header_fpaths.include?(sys_header.fpath)
    W(sys_include_line.location, sys_include_line.fpath)
  else
    if sys_include_line.include_depth > 1
      @sys_header_fpaths.add(sys_header.fpath)
    end
  end
end
check_user_include(usr_include_line, usr_header) click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 115
def check_user_include(usr_include_line, usr_header)
  if @usr_header_fpaths.include?(usr_header.fpath)
    W(usr_include_line.location, usr_include_line.fpath)
  else
    if usr_include_line.include_depth > 1
      @usr_header_fpaths.add(usr_header.fpath)
    end
  end
end