Page MenuHomePhabricator

Make our base PHPCS config enforce all of our coding conventions
Open, Needs TriagePublic

Description

Presently, some parts of our coding conventions are not automatically enforced by PHPCS; this is particularly true of indentation-related guidelines, as well as "implicit" conventions as to how blocks should be placed that are de facto conventions (e.g., closing } and opening { should not be followed by any content on the same line). We should improve our default coding standard so that these thing are caught automatically, possibly reusing existing upstream sniffs, and with an autofixer.

Last year, I made an experiment to see how well our ruleset would do on randomly-formatted code. While many of those patterns are unlikely in practice, they might still happen. One example are unintended whitespace mistakes (e.g., copypaste gone wrong, or IDEs sometimes messing up with formatting). And another example could be new contributors who are not familiar with our coding conventions (e.g., putting a one-line conditional block on a single line). Ideally, we would catch these automatically. Quoting yours truly from elsewhere:

In an ideal world, no human reviewer should ever have to say "this code doesn't comply with our coding conventions". That feedback should be provided by a machine within minutes of submitting the patch, and possibly with a command that you can run to fix it automatically.

I recognize that this task is quite open-ended and ambitious, but I see a lot of value in addressing at least the low-hanging fruits. I firmly believe that efforts toward improving our ruleset would make for a better experience for all contributors, and especially those who are approaching our codebases for the first time.