T016 std::min and std::max should be allowed

Issue #50 resolved
lukasz_czajczyk created an issue

When min/max macro is included the code std::min or std::max will not compile so this is safe to use and does not require brackets. Could you consider allowing this? The simple fix would look like this:

# Calls to min/max should be protected against accidental macro substitution
set value "
foreach file [getSourceFileNames] {
    foreach identifier [getTokens $file 1 0 -1 -1 {}] {
        set prev $value
        set value [lindex $identifier 0]
        if {($value == "min" || $value == "max") && $prev != "::"} {
            set lineNumber [lindex $identifier 1]
            set columnNumber [expr [lindex $identifier 2] + [string length $value]]
            set restOfLine [string range [getLine $file $lineNumber] $columnNumber end]

            if {[regexp {^[[:space:]]*\(} $restOfLine] == 1} {
                report $file $lineNumber "min/max potential macro substitution problem"
            }
        }
    }
}

Comments (3)

  1. Log in to comment