Zend Framework

Provide a degree of automated coding standards compliance

Details

  • Type: Coding Standards Violation Coding Standards Violation
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: 1.6.0
  • Component/s: None
  • Labels:
    None

Description

It would be nice to have some level of automated coding standards compliance assistance, and below are a couple of options:

Most likely this is too old and doesn't work with PHP 5.1.4: phpCodeBeautifier
(Thanks, Gavin)

To evaluate: PHP_CodeSniffer
(Thanks, Nick Lo)

Help Wanted - We would like help with evaluating such a system for Zend Framework code, as we would possibly integrate a good solution as a pre-commit hook to the Subversion repository.

Issue Links

Activity

Hide
Matthew Ratzloff added a comment -

Not evaluated yet for quality yet, but:

http://pear.php.net/package/PHP_Beautifier

Most recent release was in June, built in PHP 5. Works on the command line, and you write custom rules.

Show
Matthew Ratzloff added a comment - Not evaluated yet for quality yet, but: http://pear.php.net/package/PHP_Beautifier Most recent release was in June, built in PHP 5. Works on the command line, and you write custom rules.
Hide
Matthew Ratzloff added a comment -

That should read, "you can write custom rules if you like."

Here's a command line usage guide:
http://php.apsique.com/PHP_Beautifier/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.commandline.pkg.html

Show
Matthew Ratzloff added a comment - That should read, "you can write custom rules if you like." Here's a command line usage guide: http://php.apsique.com/PHP_Beautifier/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.commandline.pkg.html
Hide
Gavin added a comment -

These tools require a non-trivial effort to configure and setup "profiles".
If someone takes the initiative of codifying the ZF coding standards into configurations for these tools, then the chance for adoption would increase.

Show
Gavin added a comment - These tools require a non-trivial effort to configure and setup "profiles". If someone takes the initiative of codifying the ZF coding standards into configurations for these tools, then the chance for adoption would increase.
Hide
Bill Karwin added a comment -

I've had bad luck with automated code beautifiers. The risk is that there's some obscure corner case that the code beautifier doesn't handle well, and it inadvertently changes the functionality of the code and introduces bugs.

This actually happened on a Java project I was on in 2005. We upgraded from Java 1.4 to Java 5 and the code beautifier tools didn't know about the new syntax in that release, so they totally ruined the code in the process of trying to beautify it.

It would be one thing to have a tool check and report mismatches between the code and the coding standard, but I wouldn't want it committing changes without a human reviewing them first. Code beautifiers should be run manually and then the results checked visually and with unit tests.

We also have some points in our draft coding standards document that are not simply syntactic issues. So enforcement by a code beautifier is not a complete solution. Still, some automation is better than none.

Matthew, if you want to write a profile that does best-effort checks with respect to the Zend Framework coding standard, that would be much appreciated.

Show
Bill Karwin added a comment - I've had bad luck with automated code beautifiers. The risk is that there's some obscure corner case that the code beautifier doesn't handle well, and it inadvertently changes the functionality of the code and introduces bugs. This actually happened on a Java project I was on in 2005. We upgraded from Java 1.4 to Java 5 and the code beautifier tools didn't know about the new syntax in that release, so they totally ruined the code in the process of trying to beautify it. It would be one thing to have a tool check and report mismatches between the code and the coding standard, but I wouldn't want it committing changes without a human reviewing them first. Code beautifiers should be run manually and then the results checked visually and with unit tests. We also have some points in our draft coding standards document that are not simply syntactic issues. So enforcement by a code beautifier is not a complete solution. Still, some automation is better than none. Matthew, if you want to write a profile that does best-effort checks with respect to the Zend Framework coding standard, that would be much appreciated.
Hide
Gavin added a comment -

The pre-commit SVN hook we previously discussed for code analysis/beautifier tools might simply result in an email under certain conditions instead of doing something drastic.

Show
Gavin added a comment - The pre-commit SVN hook we previously discussed for code analysis/beautifier tools might simply result in an email under certain conditions instead of doing something drastic.
Hide
Bill Karwin added a comment -

Changing to 'Unassigned'

Show
Bill Karwin added a comment - Changing to 'Unassigned'
Hide
Wil Sinclair added a comment -

This issue should have been fixed for the 1.5 release.

Show
Wil Sinclair added a comment - This issue should have been fixed for the 1.5 release.
Hide
Wil Sinclair added a comment -

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Show
Wil Sinclair added a comment - This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.
Hide
Wil Sinclair added a comment -

Thomas, I believe you are currently working on this. Please update the issue with any changes to the original idea.

Show
Wil Sinclair added a comment - Thomas, I believe you are currently working on this. Please update the issue with any changes to the original idea.
Hide
Thomas Weidner added a comment -

We have decide to use PHP_CodeSniffer.
Actually a testbed can already be found within incubator under tools.

This issue itself is seems to be duplicated by
ZF-3027 and ZF-3065.

Show
Thomas Weidner added a comment - We have decide to use PHP_CodeSniffer. Actually a testbed can already be found within incubator under tools. This issue itself is seems to be duplicated by ZF-3027 and ZF-3065.
Hide
Wil Sinclair added a comment -

Changing to comply with new IT coventions for components.

Show
Wil Sinclair added a comment - Changing to comply with new IT coventions for components.
Hide
Thomas Weidner added a comment -

Closing due to duplication of existing issue ZF-3065

Show
Thomas Weidner added a comment - Closing due to duplication of existing issue ZF-3065
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
3d
Original Estimate - 3 days
Remaining:
3d
Remaining Estimate - 3 days
Logged:
Not Specified
Time Spent - Not Specified