blog.Resource

Archive:

News-Feeds:


RSS 2.0
RSS 0.91
RDF
ATOM 0.3
September 14, 2014

Does your code align with the TYPO3 Coding Guidelines?

Category: Quality Assurance

By: Andy Grunwald

For a software project, coding guidelines are an important part especially if there is a team working on one piece of software like in TYPO3.
The core team follows specific coding guidelines and manually checking for all the rules is a difficult and somewhat mundane task. Luckily, there is a tool which automates this task called PHP_CodeSniffer.

In PHP_CodeSniffer every rule of a Coding Guideline is implemented in code and is called a Sniff.  There is a sniff which checks for tab indention instead of spaces and another one checking for the correct usage of the name schema of a method. A defined collection of sniffs called a Standard.
To represent the TYPO3 Coding Guidelines, we combined existing sniffs from the PHP_CodeSniffer with sniffs which were implemented by us - the TYPO3 Quality Assurance Team. Currently we maintain the following three projects on Github: 

  1. Custom Sniffs: TYPO3SniffPool
  2. TYPO3CMS Coding Standard
  3. TYPO3Flow Coding Standard

The first one contains all self implemented sniffs, the second and third one are the actual coding standards for CMS and Flow/Neos and contain only a ruleset.xml do define the sniff collection.

We started that project back in 2010, but there has been little to no activity since October 2012. However, now we are back and want to make this project as stable as possible and put it into production.

Current state and Changes

In the last weeks we have continued to work on these three aforementioned projects once again and as a result, many long term bugs were fixed.

Further more, we deleted the documentation of our custom sniffs from the wiki because we have decided to move back to the native documentation feature of PHP_CodeSniffer.  This documentation is written in XML and PHP_CodeSniffer and is able to generate clean and clear looking HTML files with it. See Docs/ControlStructures for an example.

Another change is the distribution of the coding standards. Up until now it was possible to download the standards via PEAR from pear.typo3.org, but for the new released version we will no longer support PEAR. Many important projects (like PHPUnit and Switfmailer) are replacing PEAR with Composer, and due to difficultly in maintaining the PEAR package, we have decieded to follow suit. New versions will be installable via composer only (next to source installation of course). pear.typo3.org will be shutdown at 01.01.2015.

Last but not least, we have moved from Forge to Github. From our point of view and for this project it does make sense to move to Github because:

  • the contribution workflow is much more common in the open source world
  • this project is not strictly related to TYPO3, the sniffs can be used by anyone
  • most developers have a github account anyway
  • we can easiliy use TravisCI and Scrutinizer
  • we are able to use Github pages as a nice looking and presentable documentation site

I know that some people don`t like it if a TYPO3 project moves from Forge to Github, but we hope you will accept it and understand our reasons.

New version

This is not only a "We are back" post, but also letting you know we have released a new version as well, and as mentioned earlier, this version covers many old bug fixes. Next to this we have adjusted the versioning scheme. We will follow the versions of the products (6.2 for TYPO3CMS, 2.2 for TYPO3Flow and so on).

The new versions can be found at Packagist:

If you need help to install it or have found a bug, please open a ticket in the github repositories.

Roadmap

We will continue further and have many tasks planned for the next versions of these projects. Here is a small overview:

  • Improve exiting documentation of custom sniffs
  • Migrate to version >=2.0.0 of PHP_CodeSniffer
  • Fulfill the TYPO3CMS standard to fit the complete TYPO3CMS Coding Guidelines
  • Extend the TYPO3Flow Standard

Contribution 

Currently, we are the only two people (Stefano Kowalke and Andy Grunwald) working on the projects, and are currently looking for motivated contributers to help us in achieving the goals ahead.  

Not only contribution to source code matters, but also other topics like documentation ("How to integrate this in IDE x?"), helping other people in setting up, filling bug issues, talking about this and raising awareness via blog posts and so on would be a huge contribution as well. If you are a company and would like to sponsor development time of one of your employee, this is also possible as well ;)
If you do not know how to start just contact us via email or twitter (@andygrunwald, @konafets).

We hope you like what you read. Please feel free to use this tool to improve the quality of your code and feel the benefits in your daily teamwork!
If you have any questions, cristim or feedback, feel free to contact us!

Have a nice day,
Andy + Stefano


comments

No comments yet. Be the first to comment on this!

Sorry, comments are closed for this post.