You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit implements the change in the exit codes for scan runs, both `phpcs` as well as `phpcbf`, as previously outlined and extensively discussed in 184.
It also introduces a new `ignore_non_auto_fixable_on_exit` config flag to influence the exit code.
To allow for determining whether there are fixable and/or non-fixable issues left at the end of a run, while also supporting the previously already supported `ignore_errors_on_exit` and `ignore_warnings_on_exit` config flags, this required more extensive changes than originally anticipated.
Originally, the `File` class and the `Reporter` class tracked (single file/all files) totals for:
* Errors found
* Warnings found
* Fixable violations found (errors and warnings combined)
* Violations fixed (errors and warnings combined)
Additionally, the total for "fixed" could be higher than the "fixable" count as it totals the fixes applied in all loops, including fixes for issues _created by fixers_ and not in the original scan, which made the "fixed" total unusable for the new exit code determination.
To allow for correctly determining the new exit codes, the "fixable" total had to be split up into "fixable errors" and "fixable warnings", both in the `File` class, as well as in the `Reporter` class.
Secondly, the "fixed" total also had to be split up, as well as being based on the _effective_ number of fixes made instead of the _actual_ number of fixes made.
These changes also affect the way scan results are cached, as the cache now also needs to store the split up numbers (for "fixable") and how parallel processing accumulates the totals of the child processes.
And as the logic for the exit code determination for the new exit codes is largely the same for both `phpcs` as well as `phpcbf`, a new `ExitCode::calculate()` method has been introduced to transparently handle this for both.
Notable API changes:
* The signature of the `DummyFile::setErrorCounts()` method has changed:
```diff
-public function setErrorCounts($errorCount, $warningCount, $fixableCount, $fixedCount)
+public function setErrorCounts($errorCount, $warningCount, $fixableErrorCount, $fixableWarningCount, $fixedErrorCount, $fixedWarningCount)
```
* The `Reporter::$totalFixable` and `Reporter::$totalFixed` properties are now deprecated. They will still be supported as readonly properties for the 4.x branch (via magic methods), but support will be removed in PHPCS 5.0.
* The return value of the `private` `Runner::run()` method has changed from `int` to ` void` as the return value was no longer used.
Includes mentioning the new `ignore_non_auto_fixable_on_exit` config flag in the CLI help text.
Includes extensive integration tests for the exit code calculations and the changes made in support of the new exit codes.
Includes git-ignoring temporary files which will be created during the test run in case the test run would bork out before the tear down methods are run.
Includes tests for the new magic methods in the `Reporter` class to safeguard that the deprecated properties are still accessible, but not writeable.
Includes improving the documentation for `Fixer::$numFixes`/`Fixer::getFixCount()` to mention that these numbers are _actual_ number fixes, not _effective_ number of fixes.
Fixes 184
Fixes squizlabs/PHP_CodeSniffer 2898
0 commit comments