Trailing Whitespace in Core Code

87 views
Skip to first unread message

Adam

unread,
Oct 13, 2012, 3:42:42 PM10/13/12
to cakeph...@googlegroups.com
Hey guys,

First of all, I appreciate all of your work on CakePHP. I am a big fan!

One thing I noticed about the code in version 2.2.3 is that there are many files (67, to be exact) that have trailing whitespace. This can be annoying, especially for developers like me who have their editor set up to automatically strip trailing whitespace. This is something that Mark Story apparently cares about, too.

Would you guys please consider making a policy of not having trailing whitespace in the core code? That would be fantastic.

Thanks!

AD7six

unread,
Oct 13, 2012, 7:45:24 PM10/13/12
to cakeph...@googlegroups.com
It is an existing policy, though it's not part of the phpcs standard (I'll add a rule).

whitespace like that creeps in because not all pull requests are written by devs who are as careful about whitespace as the core team.

AD

mark_story

unread,
Oct 13, 2012, 9:25:28 PM10/13/12
to cakeph...@googlegroups.com
There is a PHPCS check for it.  It even gets tracked in jenkins (http://ci.cakephp.org/job/CakePHP%202.2%20-%20Checkstyle/390/checkstyleResult/HIGH/?).  However, a human (usually me) has to go around and fix the problems.  67 seems high though, perhaps the existing code linter is missing some situations.

-Mark

Adam

unread,
Oct 13, 2012, 10:13:53 PM10/13/12
to cakeph...@googlegroups.com
I found the files with this command:

find . -type f -exec egrep -l " +$" {} \;

I just checked again and found that 30 of the 67 were .mo files. I don't think those matter. Of the remaining 37, 4 are in the "app" folder, so I would think they have the highest priority of having trailing whitespace removed. Here's the list:

./app/Config/acl.php
./app/Config/bootstrap.php
./app/Config/core.php
./app/Config/routes.php
./lib/Cake/Cache/CacheEngine.php
./lib/Cake/Cache/Engine/FileEngine.php
./lib/Cake/Console/Command/Task/TemplateTask.php
./lib/Cake/Console/Command/TestShell.php
./lib/Cake/Console/Templates/skel/Config/core.php
./lib/Cake/Controller/Component/Acl/IniAcl.php
./lib/Cake/Controller/Component/Acl/PhpAcl.php
./lib/Cake/Controller/Component/Auth/DigestAuthenticate.php
./lib/Cake/Controller/Component/CookieComponent.php
./lib/Cake/Controller/Component/SecurityComponent.php
./lib/Cake/Controller/Component/SessionComponent.php
./lib/Cake/Controller/Component.php
./lib/Cake/Core/CakePlugin.php
./lib/Cake/Event/CakeEvent.php
./lib/Cake/Event/CakeEventManager.php
./lib/Cake/Model/Behavior/ContainableBehavior.php
./lib/Cake/Model/ConnectionManager.php
./lib/Cake/Model/Datasource/Database/Sqlserver.php
./lib/Cake/Model/Datasource/DataSource.php
./lib/Cake/Network/Email/CakeEmail.php
./lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php
./lib/Cake/Test/Case/Configure/PhpReaderTest.php
./lib/Cake/Test/Case/Console/Command/TestShellTest.php
./lib/Cake/Test/Case/Event/CakeEventManagerTest.php
./lib/Cake/Test/Case/Model/Datasource/DataSourceTest.php
./lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php
./lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php
./lib/Cake/Test/Case/Utility/StringTest.php
./lib/Cake/TestSuite/Fixture/CakeTestFixture.php
./lib/Cake/Utility/File.php
./lib/Cake/View/Helper/SessionHelper.php
./lib/Cake/View/JsonView.php
./lib/Cake/View/ViewBlock.php

mark_story

unread,
Oct 15, 2012, 12:24:42 PM10/15/12
to cakeph...@googlegroups.com
If you're feeling eager you can always send a pull request to fix the files.  If not I'll get around to this sometime soon.  It seems that from a few files that I checked the trailing space was inside comments which means there is probably a problem with the phpcs checker.

-Mark

Adam

unread,
Oct 15, 2012, 8:23:48 PM10/15/12
to cakeph...@googlegroups.com
Done:


It was all comments except for these two files:

./lib/Cake/Test/Case/Configure/PhpReaderTest.php
./lib/Cake/Test/Case/Utility/StringTest.php

I didn't touch the above two files, though, because the trailing whitespace in those two files was intentional.
Reply all
Reply to author
Forward
0 new messages