Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff step by step #670

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open

Ruff step by step #670

wants to merge 37 commits into from

Conversation

c8y3
Copy link
Contributor

@c8y3 c8y3 commented Dec 18, 2024

This PR is a first step to activate some ruff rules into the baseline quality of DFIR-IRIS. It adds a configuration file for ruff (pyproject.toml), runs ruff during continuous integration and includes several cleanups to remove the following warnings:

  • unused variables (F841)
  • unused imports (F401), especially in app.models.init (no need for this indirection, as we are in the same application.)
  • wildcard imports (F403)

Here are the other improvements done on the fly:

  • removal of cyclic dependence between app.init and app.views (In the end goal, I'd like to remove the cyclic dependencies over the whole application: the Flask app is acting as a global hub. It prevents a true modular layered design and unit tests. This is only a first small step),
  • addition of a first end-to-end test for dim tasks,
  • start of some code for dim tasks in the business layer (app.business.dim_tasks),
  • app.business.dim_tasks: replaced calling private method of the AsyncResult Celery object by accesses to properties of its public API,
  • app.business.dim_tasks: transformed some ternary operator expressions into methods to convey meaning better,
  • app.business.dim_tasks: made code more readable by building all the values first and filling the dictionary at the end, replaced optional fields by None (as it's treated the same in the jinja template),
  • added a missing license header (there should be a tool run during build to check this automatically),
  • moved some code out of app.views up into app.init, the initialization is all in one file and more readable, more work remains to move the imports at the top-level.
  • one import per line

@c8y3 c8y3 added the quality label Dec 18, 2024
@c8y3 c8y3 requested a review from whikernel December 18, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant