Open zbee opened 6 years ago
I agree. There should be an option to ignore comments, or they should be under a lesser category. A comment typo with an extra dollar sign in front of a variable should not count as Critical.
This is an easy fix. In php7mar/classes/test.php:
function testLine($line) $issues = []; $testLine = ltrim($line); if(substr($testLine,0,2) == "//" || substr($testLine,0,1) == "#") return $issues. ...
This is an easy fix. In php7mar/classes/test.php:
function testLine($line) $issues = []; $testLine = ltrim($line); if(substr($testLine,0,2) == "//" || substr($testLine,0,1) == "#") return $issues. ...
That suggestion does not take multi-line comments into account, such as:
/**
* Comment
*/
Nor does it handle comments that are not at the start of a line. This would still throw a critical error:
$test = $value + 1; // Add one to $$test.
I used this on a test box at work to run against our code base to show how simple upgrading to PHP 7.2 will be (from 5.6) given the improvements, but the generated report showed probably 75% of errors originating from commented out lines (I don't know why we have so many, but that's a task for another time) these should be ignored to boot. This included single line comments and block comments.
For example:
It wouldn't be wrong to include this in a
notices
section or something of the like, just to make users aware that they have comments full of deprecated code like we do for some unknown reason; but it shouldn't show in the main list of problems.