Skip to content

Coding Standard

Yarden Lev edited this page Apr 4, 2017 · 11 revisions

This page defines the coding standards of our project and applies for all its contributors.

Environment

  • This project is written (mainly) in Java.
    • Use JDK 8 (latest version).
    • If you wish to add code written in other languages, ask for permission.
  • The IDE we work with is Eclipse Java Neon, with the newest version of the Spartanizer plugin installed.

Spartanization

  • Fully spartanize the project before pushing commits.
  • Disable Centification and Dollarization: Go to Window -> Preferences -> Java -> Installed JREs -> Laconization Tips and uncheck them.

Before Pushing Commits

  • Avoid warnings.
    • If you see warnings in the code, try to solve them (even if they are not yours). Consult the team if necessary.
  • Run all tests.
    • If a test fails, fix it before pushing.
    • If you can't do it right now: Push your code, open an issue with a Bug label and explain the problem the best you can.
  • Don't push commented-out code.
    • If you must, explain why it is commented-out with a TODO to whoever should un-comment it.

Commits: Content & Structure

  • Try to commit a reasonable amount of code that makes sense logically.
  • Your commits should have the following structure:
    <Block> : <Title>
    
    <Explanations>
    
    Issue: #<Issue number>
    
    • Block: Specifies the part of the code you worked on (examples for our project: Android, Sensors, System, etc.)
    • Title: A few words describing your commit (e.g. "Adding new server")
    • Explanation: Explanation of the new features and / or content you added in this commit
    • Issue number: The number of the issue that is relevant to this commit

Documentation

  • Each class should have @author and @since annotations, as well as a short description of the class.
    • Write your name and not your email in the @author annotation.
    • Example:
      /**
       * @author Yarden
       * @author Ron
       * @since 3.4.17
       *
       * <short description>
       */
  • If you add code that is non-trivial in your opinion, add a short comment to explain it.
  • Add JavaDoc to public and protected methods.

Code Coverage

  • We wish to achieve code coverage of 70%.
  • We use Codecov in order to measure our code coverage.
  • For more detailed explanation, read the Testing wiki page.

Clone this wiki locally