Php_codesniffer: Report unfixable errors only

Created on 5 Jan 2021  ยท  5Comments  ยท  Source: squizlabs/PHP_CodeSniffer

Describe the bug new feature
While running in CI PHPCS may hold back contributors by reporting fixable (e.g. formatting) errors.
Please see https://tomasvotruba.com/blog/2020/12/28/why-coding-standards-should-not-be-part-of-ci

To reproduce

  1. vendor/bin/phpcs --unfixable-only
  2. List only unfixable errors

Expected behavior

All fixable errors could then be fixed in another PR.

Enhancement

Most helpful comment

IMHO:

  • Auto-fixable changes should be done by jenkins and included in the code if possible. (this solves 95% of the issues)(alternative: provide easy way to execute corrections for contributor)
  • Non auto-fixable changes should be changed by the contributor.
    Doing both results in less pain for the contributor and better quality of the repository.
    Which in the end results in less problems/bugs for the user :)

All 5 comments

This is not a bug, but a feature request.

Also: IMO, more than anything, all "auto-fixable" errors should be fixed in the PR which is introducing them. Why allow "dirty" code to be merged when it could easily be "clean" ?

I do not maintain big open-source projects, so I allow my contributors anything.
In an agency everyone should clean up their code.

So I just follow the things in the above article...
Cc @TomasVotruba

Why allow "dirty" code to be merged when it could easily be "clean" ?

BTW If I contribute 2 hours of work to a project for free a single whitespace should not be a โŒ in CI.

@szepeviktor He, nobody is forcing you to use CS in your projects, let alone have it run in CI.

BTW If I contribute 2 hours of work to a project for free a single whitespace should not be a x in CI.

So, instead, you think the maintainers of the projects you want to contribute to, should spend their spare and unpaid time cleaning up your code contribution ?

Sorry, but I don't get it. Personally, I'd rather - as a reviewer - be able to focus on the proposed change, then be distracted by horribly formatted code and miss something essential when reviewing.

IMHO:

  • Auto-fixable changes should be done by jenkins and included in the code if possible. (this solves 95% of the issues)(alternative: provide easy way to execute corrections for contributor)
  • Non auto-fixable changes should be changed by the contributor.
    Doing both results in less pain for the contributor and better quality of the repository.
    Which in the end results in less problems/bugs for the user :)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

wowcut picture wowcut  ยท  3Comments

justintadlock picture justintadlock  ยท  3Comments

jigius picture jigius  ยท  3Comments

stephanvierkant picture stephanvierkant  ยท  3Comments

jrfnl picture jrfnl  ยท  3Comments