Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Please delete options that are not relevant.
- [ ] I have inserted the copyright banner at the start of the file: ```# This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl # See the file 'LICENSE' for copying permission.```
- [ ] Please avoid adding new libraries as requirements whenever it is possible. Use new libraries only if strictly needed to solve the issue you are working for. In case of doubt, ask a maintainer permission to use a specific library.
- [ ] If external libraries/packages with restrictive licenses were added, they were added in the [Legal Notice](https://github.com/certego/IntelOwl/blob/master/.github/legal_notice.md) section.
- [ ] Linters (`Black`, `Flake`, `Isort`) gave 0 errors. If you have correctly installed [pre-commit](https://intelowlproject.github.io/docs/IntelOwl/contribute/#how-to-start-setup-project-and-development-instance), it does these checks and adjustments on your behalf.
- [ ] Linters (`Ruff`) gave 0 errors. If you have correctly installed [pre-commit](https://intelowlproject.github.io/docs/IntelOwl/contribute/#how-to-start-setup-project-and-development-instance), it does these checks and adjustments on your behalf.
- [ ] I have added tests for the feature/bug I solved (see `tests` folder). All the tests (new and old ones) gave 0 errors.
- [ ] If the GUI has been modified:
- [ ] I have a provided a screenshot of the result in the PR.
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/pull_request_automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,10 @@ jobs:
pip3 install --upgrade pip
pip3 install -r requirements/test-requirements.txt

- name: Black formatter
- name: Lint and format with Ruff
run: |
black . --check --diff --exclude "migrations|venv|.ipython|docs_env|.cache"

- name: Lint with flake8 (PEP8 enforcer + linter)
run: |
flake8 . --config=.flake8 --show-source

- name: isort
run: |
isort . --profile black --filter-files --check-only --diff --skip configuration/ldap_config.py
ruff check . --output-format=github
ruff format --check .

- name: Perform ShellCheck Analysis
run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/shellcheck/master/pipeline.sh)
Expand Down
28 changes: 7 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 24.8.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to use an old version ?

hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args:
[
"--profile",
"black",
"--filter-files",
"--skip",
"venv",
"--skip",
"configuration/ldap_config.py",
]
# Run the linter
- id: ruff
args: [--fix]
# Run the formatter
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.16.0
hooks:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
[![Official Site](https://img.shields.io/badge/official-site-blue)](https://intelowlproject.github.io)
[![Live Instance](https://img.shields.io/badge/live-demo-blue)](https://intelowl.honeynet.org)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![CodeQL](https://github.com/intelowlproject/IntelOwl/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/intelowlproject/IntelOwl/actions/workflows/codeql-analysis.yml)
[![Dependency Review](https://github.com/intelowlproject/IntelOwl/actions/workflows/dependency_review.yml/badge.svg)](https://github.com/intelowlproject/IntelOwl/actions/workflows/dependency_review.yml)
[![Build & Tests](https://github.com/intelowlproject/IntelOwl/workflows/Build%20&%20Tests/badge.svg)](https://github.com/intelowlproject/IntelOwl/actions)
Expand Down
55 changes: 43 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
[tool.black]
exclude = '''
/(
venv
| frontend
| node_modules
)/
'''
[tool.isort]
[tool.ruff]
line-length = 140
target-version = "py311"

exclude = [
"venv",
"frontend",
"node_modules",
"migrations",
"docs",
"virtualenv",
"configuration/ldap_config.py",
]

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"DJ", # flake8-django
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this specific set has been chosen over all the possibilities?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selected ruleset is intentionally conservative and maps closely to the linters we were already using (flake8 core, flake8-django, isort), with a few widely adopted extensions like bugbear and comprehensions that catch real issues with low noise

Core Rules (Direct Replacements)

  • E, W, F - Direct replacement for flake8 core
  • I - Direct replacement for isort
  • DJ - Replacement for unmaintained flake8-django (primary reason for this migration)


ignore = [
"W503", # line break before binary operator (conflicts with black)
"E231", # missing whitespace after ','
"W605", # invalid escape sequence
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # unused imports in __init__ files

[tool.ruff.lint.isort]
known-first-party = ["certego_saas"]
profile = "black"
multi_line_output = 3
use_parentheses = true
known_first_party = ["certego_saas"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

[tool.codereviewdoctor]
disable = ["missing-reverse-migration"]
4 changes: 1 addition & 3 deletions requirements/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
flake8==7.1.1
black==24.10.0
isort==5.12.0
ruff==0.8.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any particular reason to use an old version of ruff ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's good catch, we must use the most recent one

pre-commit==4.0.1
coverage==7.6.1
Loading