Code Standards

General

In order to provide a code base that is easy to maintain, as well as easy to contribute to, Robottelo has adopted a set of code standards that all contributers are held to. Violations to our strictly held standards will result in a rejected pull request until all violations have been resolved. While not adhering to our recomended standards isn’t a show stopper, keeping to them will help our code base to stay great!

Strictly Held

Linting

  • All code will be linted to PEP8 standards using flake8.
  • In the root of the Robottelo directory, run flake8 .
  • If flake8 returns errors, make corrections before submitting a pull request.
  • pre-commit configuration is available, and its use is strongly encouraged in local development.

Docstrings

  • Every class, method and function will have a properly formatted docstring.
  • Docstring will also contain testimony and sphinx directives, as appropriate.
    • testimony docstrings are specific to foreman tests, so every test in tests/foreman/* should have the testimony tags.
  • In the root of the Robottelo directory, run make test-docstrings to ensure you did not miss adding a docstring.

Strings

  • Use string methods instead of the string module.

  • Use the .format() method to properly format strings:

    formatted_string = 'I {0} a {1} string.'.format('am', 'formatted')
    

Naming

  • module_name
  • method_name
  • function_name
  • instance_variable_name
  • local_variable_name
  • function_parameter_name
  • ClassName
  • ExceptionName
  • GLOBAL_CONSTANT_NAME
  • _private_method
  • _private_variable
  • _PrivateClass

Style

  • Absolutely no semi colons.
  • Lines are not to exceed 99 characters in length.
  • Code will be indented with 4 spaces instead of tabs.

Todo

Compile a list of standards used by the Robottelo team

Categorize each standard into how strictly they are enforced