Skip to content

Latest commit

 

History

History
109 lines (72 loc) · 3.53 KB

.code-style.md

File metadata and controls

109 lines (72 loc) · 3.53 KB

Code Style

We are using some tools to keep a default coding style in the project.

  • git pre-commit hooks to lint and perform some standardization on every commit.

  • codacy, a platform integrated to github that executes static code quality analysis and track quality evolution.


Docstrings and Type Hinting

We following the Numpy docstring style with PEP484.

Links


flake8

Flake8 is a python linter that helps to keep the code up to PEP standards.

mypy

Mypy is a static type checker for python

To lint the code, run: make lint

Pre-Commit

Next we'll explain the steps to use the pre-commit hooks.

  1. Download and install the python package pre-commit

    • conda install -c conda-forge pre-commit or pip install pre-commit
    • In the repository folder, run pre-commit install
  2. With pre-commit, the next time you make a commit, it will analise your code to match the hooks defined in the .pre-commit-config.yaml file.

Fix double quoted strings................................................Passed
Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing pymove/core/dataframe.py

Fix End of Files.........................................................Passed
Mixed line ending........................................................Passed
Check for added large files..............................................Passed
Don't commit to branch...................................................Passed
seed isort known_third_party.............................................Failed
isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing pymove/core/dataframe.py
Fixing pymove/utils/trajectories.py

flake8...................................................................Failed
- hook id: flake8
- exit code: 1

pymove/utils/constants.py:64:5: F601 dictionary key 11 repeated with different values
pymove/utils/constants.py:65:5: F601 dictionary key 12 repeated with different values
pymove/utils/constants.py:74:5: F601 dictionary key 11 repeated with different values
pymove/utils/constants.py:75:5: F601 dictionary key 12 repeated with different values
pymove/core/dataframe.py:970:29: E711 comparison to None should be 'if cond is None:'

Explaining each hook

  • Fix double quoted strings: Checks and fixes every string declaration is made using single quotes.

  • Trim Trailing Whitespace: Checks and fixes so there are no trailing whitespaces.

  • Fix End of Files: Checks and fixes so that all files end's with a blank line.

  • Mixed line endings: Checks and fixes line breaks to use the unix LF.

  • Check for added large files: Doesn't allow files bigger than 15Mb to be commited.

  • Don't commit to branch: Doesn't allow direct commits to master branch.

  • isort: Sorts the imports.

  • flake8: Ensures that the code follows pylint and pyflakes guidelines. It will point the errors in the code.

  • mypy: Performs type checking. It will point the errors in the code.


Codacy

Codacy statically analyzes Pull Requests made into the master and developer branches.

Codacy uses the tools Bandit, Prospector, PyLint and Remark Lint;

The error encountered will be pointed by Codacy as PR Comments.