xlab-si / xopera-opera

xOpera orchestrator compliant with TOSCA YAML v1.3 in the making
https://xlab-si.github.io/xopera-docs/
Apache License 2.0
35 stars 14 forks source link

Sanity and static analysis checks: PEP8, linters, typing, including code reformatting. #165

Closed sstanovnik closed 3 years ago

sstanovnik commented 3 years ago

To help prevent preventable coding errors and to unify code style, we introduce almost all standard linting and static analysis tools applicable to this project:

This is accompanied by editorconfig, which makes it easier for IDEs to adhere to the styles.

Configurations of different tools are set so that their overlapping checks, such as line lengths, are identical. Static typing is relaxed enough to not require major changes in the codebase (such as requiring all variables to be explicitly typed), as well as other linter configurations, which mostly adhere to the style this project has used before.

CI is updated to perform sanity checks as part of its testing routine. A helper script exists to run all sanity checks at once, as a batch, only exiting with an error code at the end, which simplifies CI execution.

Touches nearly every file in the repository to adhere to sanity checks, most notably:

This uncovered some bad code that was corrected, such as unreachable branches, plain incorrect logic, use of deprecated and insecure functions etc.

Closes #163.

sstanovnik commented 3 years ago

If possible, this needs to be merged before doing anything else, otherwise there will be many ugly merge conflicts. It's a perfect time though, seeing as there are no open pull requests at the moment.

sstanovnik commented 3 years ago
  1. I think what the plugin wants is to have dependencies explicity. The current version, I think, loads the new depenencies from either setup.cfg or requirements.txt. I don't dare touch Pipfile in that way, because I have no idea how it works :)
  2. Done! I forgot to run code formatting on a couple of folders.
  3. I added a sanity check for trailing periods as a separate commit. Never again will you have to remind me of this! Take that! :D
anzoman commented 3 years ago
  1. Ok. interesting. I think that we should think about moving from pipenv and Pipfile to something else.
  2. Great!
  3. Magnificent!