Tuleap coding standards

As Tuleap is mainly written in PHP, we use the PSR standards:

Internal conventions

  • Use an indent of 4 spaces, with no tabs. This helps to avoid problems with diffs, patches, git history ...

  • It is recommended to keep lines at approximately 85-100 characters long for better code readability.

  • methodsInCamelCase()

  • $variables_in_snake_case

  • constants in UPPER_CASE

  • public methods documented (at least @return statement)

  • class documented (I'm responsible of…)

  • One True Brace style

  • No trailing whitespaces

    Note: Contributions SHOULD NOT add/fix features AND fix coding standard of a legacy file in the same review. The code WONT be accepted. If your eyes are bleeding, conform to coding standard in a dedicated review, then contribute your change.

Good quality code

Tuleap is a big (+600k LOC) and old (16 years) software and has probably an example of every existing bad designs that existed during those 16 years.

Yet, it’s not a fatality and we are on the way to, slowly and carefully clean things up. On our road toward a Clean Code, some motto might help you to make your design choices:

  • Test your code; TDD (Test Driven Development) should be the default.
  • Follow SOLID design principles.
  • Don’t contribute STUPID code.

We also strongly suggest that you familiarize yourself with Code Smells as it might pop up during code reviews.

Resources

A couple of documents worth to read when you consider contributing to Tuleap:

  • http://www.phptherightway.com/