Code quality checks

Poor quality code tends to die early because it might entail substantial technical debt.
What is Code Quality & why is it important

Writing codes that meet high standards play an important role in the success of a code project. But in a project with more than one contributor, it is hard to manually maintain certain code standards. Linters are static code analysis tools which can automatically check your code base for improvements and tells you if the code has met certain code quality standards. Although, it is important to write clean codes in the first place, having code quality checks integrated into the testing routines comes with many advantages for large-scale software projects.

Linters for checking code quality

Following is a set of tool recommendations for different code projects:

PythonC++
PyLintClang-Tidy
Flake8
SonarQubeSonarQube

Code quality checks with PyLint

For our exercises, we use PyLint to analyse our code for various quality flaws.

Running PyLint

cd <PROJECT_DIR>
py -m pylint <PATH_TO_SOURCE>

PyLint configuration

There are numerous checks which may or may not be valid for your project. An example would be to choose a different styling check for naming functions. You can configure your own necessary checks using the .pylintrc file. First generate a template for .pylintrc file using py -m pylint --generate-rcfile and editing different configurations. The configurations are automatically loaded when you call pylint from the same directory.