I fail to see why truly harmless whitespace at the end of lines should be declared an ERROR, surely a WARNING would suffice.

Currently, I have not solved a problem reported elsewhere with NetBeans IDE introducing (completely harmless) spaces after you hit enter, into the next line, on both some lines between functions and sometimes on blank docblock comment lines: #2306143: Feedback only: NetBeans introduces whitespace (have to remove "by hand").

For general readers: please do not suggest (with best intention) to me (yet again) on Drupal.org that I should simply pass my code through Drupal's code manipulation tools like PHPCBF and that all of my worries and concerns regarding Coder and Coding Standards would be magically solved (and that I should therefore stop complaining about certain Drupal Coding Standards); I am using a very specific UML-friendlier PHP coding style, and just passing my code through a code manipulation will break the synchronisation between my code and my graphical Unified Modeling Language (UML) models. I have very specific , and very good, reasons for doing this, and I know exactly what I am doing and why.

That said, if I could easily target say the "whitespace" rule only (without say hacking around with phpcs.xml), I could minimise the damage.

A more general solution: As I have commented elsewhere (#2306733: Advanced feature idea: Coder strict mode (applies all rules) and user selectable rule switches, together with Coder configuration file for submission with a module) what is need in my opinion is the ability to choose various level of compliance with the Drupal Coding Standards and even to have completely different compliance modes (such as spin-off standard based on my own UML-friendlier PHP coding practice). Users could then contribute their modules along with a Coding Standard Compliance Mode configuration file that it passes.

Whitespace rules address white space (which unless PHP spits on it already is in fact just harmless white space) could be enforced in STRICT mode.

Comments

webel’s picture

PS: I am aware of this (from @klausi from #2306143: Feedback only: NetBeans introduces whitespace (have to remove "by hand")):

You can pass config options to phpcbf to only run certain fixers and not all of them, see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automati...

I would be grateful if somebody could please provide a simple example of how one could use this to just apply PHPCBF to remove white space at the end of lines (safely, without affecting any other code).

webel’s picture

Priority: Normal » Minor

This works for removing trailing whitespace in NetBeans 8.0 (Mac version):

NetBeans > Preferences > Editor > On Save > Remove Trailing Whitespace From: All Lines 

Make sure your have:

Language = PHP

And you may need to deselect:

[ ] Use All Languages settings.

It was not at all obvious to me that this might be under On Save.

See also: http://stackoverflow.com/questions/4119872/netbeans-removing-trailing-wh...

I would still like to see trailing whitespace downgraded to a warning.

klausi’s picture

Version: 8.x-2.1 » 8.x-2.x-dev
Status: Active » Closed (won't fix)

What can do now is create a custom phpcs.xml file in your project and specify sniffs that you want applied, files you want to ignore, errors you want to have as warnings etc. See for example Drupal core's phpcs.xml.dist file http://cgit.drupalcode.org/drupal/tree/core/phpcs.xml.dist

Which means we don't have to change the sniff in Coder.