OPNFV Coding Guidelines

Note: This document is a work in progress. Fundamentally stolen with pride at this timeā€¦

Git commit message style

For Git commit messages we recommend following the OpenStack commit message recommendations. See: https://wiki.openstack.org/wiki/GitCommitMessages

In a nutshell

Commit message content

The commit message must contain all the information required to fully understand & review the patch for correctness. Less is not more. More is more.

Please submit small commits

Ensure there is only one "logical change" per commit. There are many reasons why this is an important rule:

General Code headers

Headers must be applied to all contributed code. These should provide a copyright notice identifying the individual, and company where affiliated, of origin for the contribution and the license under which the contribution was made. In OPNFV we use the Apache 2.0 license, some templates for code headers follow.

C/C++/Java

/*******************************************************************************
* Copyright (c) 2015 <Company or Individual> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution, and is available at
* http://www.apache.org/licenses/LICENSE-2.0
*******************************************************************************/

Bash/Python

##############################################################################
# Copyright (c) 2015 <Company or Individual> and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

XML

<!--
Copyright (c) 2015 <Company or Individual> and others.

All rights reserved. This program and the accompanying materials
are made available under the terms of the Apache License, Version 2.0
which accompanies this distribution, and is available at
http://www.apache.org/licenses/LICENSE-2.0-->

Documentation

Per OPNFV IP Policy, all documentation will be received and made available by the OPNFV Project under the Creative Commons Attribution 4.0 International License.

All documentation files need to be licensed using the creative commons licence. The following example may be applied in the first lines of all contributed RST files:

.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
.. (c) <optionally add copywriters name>

These lines will not be rendered in the html and pdf files.

General Code Style

Depends on the upstream project to which we intend to contribute to. If it's OPNFV specific 120 character line length would suffice. Yet, for OpenStack, a lot of projects enforce an 80 character length limit.

Java

In General we follow the Google Java Code Style Guide with a few exceptions. See: https://google-styleguide.googlecode.com/svn/trunk/javaguide.html

* 120 character line length * 72 or 80 chars for javadoc

Python

PEP8 is the Python standard that should be followed when coding any Python code with the following exceptions.

* 80 character line length

The usage of tools such as flake8 is encouraged.