Continuous Integration and Coding Standards - parthibann/My_wiki GitHub Wiki

Coding Standard: Code must be formatted to agreed coding standards. Coding standards keep the code consistent and easy for the entire team to read and refactor. Code that looks the same encourages collective ownership.

Code Review: Code Review, or Peer Code Review, is the act of consciously and systematically convening with one’s fellow programmers to check each other’s code for mistakes, and has been repeatedly shown to accelerate and streamline the process of software development like few other practices can.

Verifying coding standars will be very tough while reviewing large chunks of code, the below explains how to Automate coding standards verification process using continuous integration (jenkins).

Continuous Integration and Coding Standards:

Continuous integration is a process in which all development work is integrated as early as possible. The resulting artifacts are automatically created and tested. This process should identify errors as very early in the process.

Jenkins is one open source tool to perform continuous integration. Installation and configuration of jenkins is not covered here.

  • Install "Report Violations" plugin in jenkins (Jenkins -> Manage jenkins -> Manage plugins -> Available).
  • Create a new free-style project in jenkins
  • Configure the job, If you for example using Git, enter the URL to the Git repository. If the repository is not public, you may also need to configure the credentials.

Lets take an example python project Mistral

  • Add build step "Execute shell" and run the following command

pylint $(find mistral -name "*.py" -print) --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" > pylint.log || exit 0

In the above command replace "mistral" with your project.

p1

  • Under "post-build actions" select "Report Violations" plugin which we installed earlier and enter the "XML filename pattern" as the output file "**/pylint.log".
  • Enter source path as "**"

p3

  • Save and execute the build, the result graph will be displayed in the project home page with no of violations and in the violations page you can find the violations for each and every file.

pylint2

p5