T016 std::min and std::max should be allowed
Issue #50
resolved
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)
-
reporter -
- changed status to resolved
using min/max with the std:: prefix is good enough - fix
#50→ <<cset 10a33efe1fcd>>
-
reporter Hi, will you be planning to release new version with this fix soon?
- Log in to comment
Added pull request that should resolve this issue.