class AdLint::Exam::CBuiltin::W0073
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 384 def initialize(phase_ctxt) super trav = phase_ctxt[:cpp_ast_traversal] trav.enter_user_include_line += T(:enter_include_line) trav.enter_system_include_line += T(:enter_include_line) trav.enter_text_line += T(:enter_text_line) trav.enter_if_section += T(:enter_if_section) @main_fpath = phase_ctxt[:sources].first.fpath @last_fpath = nil @enclosed_by_if_section = false @warned_files = Set.new end
Private Instance Methods
cinit_fpath()
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 459 def cinit_fpath if fpath = traits.of_compiler.initial_header Pathname.new(fpath) else nil end end
empty_line?(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 433 def empty_line?(node) node.token.value.chomp.empty? end
enter_if_section(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 428 def enter_if_section(node) @enclosed_by_if_section = true @last_fpath = node.location.fpath end
enter_include_line(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 398 def enter_include_line(node) unless node.location.fpath == @last_fpath @enclosed_by_if_section = false @last_fpath = node.location.fpath end return if in_initial_header?(node) || in_main_file?(node) unless @enclosed_by_if_section || in_warned_file?(node) W(node.location) @warned_files.add(node.location.fpath) end end
enter_text_line(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 412 def enter_text_line(node) unless node.location.fpath == @last_fpath @enclosed_by_if_section = false @last_fpath = node.location.fpath end if empty_line?(node) || in_initial_header?(node) || in_main_file?(node) return end unless @enclosed_by_if_section || in_warned_file?(node) W(node.location) @warned_files.add(node.location.fpath) end end
in_initial_header?(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 441 def in_initial_header?(node) node.location.fpath.identical?(pinit_fpath) || node.location.fpath.identical?(cinit_fpath) end
in_main_file?(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 437 def in_main_file?(node) node.location.fpath == @main_fpath end
in_warned_file?(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 446 def in_warned_file?(node) @warned_files.include?(node.location.fpath) end
pinit_fpath()
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 450 def pinit_fpath if fpath = traits.of_project.initial_header Pathname.new(fpath) else nil end end