class AdLint::Exam::CBuiltin::W0413

Public Class Methods

new(phase_ctxt) click to toggle source
Calls superclass method AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 8238
def initialize(phase_ctxt)
  super
  trav = phase_ctxt[:cc1_ast_traversal]
  trav.enter_if_statement      += T(:check_if_statement)
  trav.enter_if_else_statement += T(:check_if_else_statement)
  trav.enter_while_statement   += T(:check_while_statement)
  trav.enter_do_statement      += T(:check_do_statement)
  trav.enter_for_statement     += T(:check_for_statement)
  trav.enter_c99_for_statement += T(:check_for_statement)
end

Private Instance Methods

check_do_statement(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 8286
def check_do_statement(node)
  unless node.header_terminator.location.line_no ==
      node.statement.head_location.line_no
    unless node.statement.kind_of?(Cc1::CompoundStatement)
      W(node.statement.location)
    end
  end
end
check_for_statement(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 8295
def check_for_statement(node)
  unless node.header_terminator.location.line_no ==
      node.body_statement.head_location.line_no
    unless node.body_statement.kind_of?(Cc1::CompoundStatement)
      W(node.body_statement.location)
    end
  end
end
check_if_else_statement(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 8259
def check_if_else_statement(node)
  unless node.then_header_terminator.location.line_no ==
      node.then_statement.head_location.line_no
    unless node.then_statement.kind_of?(Cc1::CompoundStatement)
      W(node.then_statement.location)
    end
  end

  unless node.else_header_terminator.location.line_no ==
      node.else_statement.head_location.line_no
    case node.else_statement
    when Cc1::CompoundStatement, Cc1::IfStatement, Cc1::IfElseStatement
    else
      W(node.else_statement.location)
    end
  end
end
check_if_statement(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 8250
def check_if_statement(node)
  unless node.header_terminator.location.line_no ==
      node.statement.head_location.line_no
    unless node.statement.kind_of?(Cc1::CompoundStatement)
      W(node.statement.location)
    end
  end
end
check_while_statement(node) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 8277
def check_while_statement(node)
  unless node.header_terminator.location.line_no ==
      node.statement.head_location.line_no
    unless node.statement.kind_of?(Cc1::CompoundStatement)
      W(node.statement.location)
    end
  end
end