Ruff | Stack | Fluid Attacks Help

Ruff

Rationale

We use Ruff to lint and format Python source code. Ruff allows us to achieve the following:
  1. Lint Python files in an extremely fast fashion with hundreds of rules inherited from other linters like pyflakes, flake8, pylint, among others. Such rules were reimplemented using Rust.
  2. Format Python files based on Black rules for consistency
  3. Cache already-reviewed files for performance
  4. Integrate in-editor linting and formatting using its VS Code extension for development experience

Alternatives

Below are alternatives we have used in the past and were replaced by Ruff.

Prospector

  1. Prospector is a meta-linter that incorporates other linters like pylint, pycodestyle and McCabe complexity.
  2. It does not do anything else besides incorporating external linters in a unified interface.
  3. It supports less rules when compared to Ruff and does not support formatting.
  4. It is much slower compared to Ruff.
  5. It does not provide any formatting capabilities.
  6. It does not seem to provide caching mechanisms.
  7. It does not have an official VS Code extension.
Note on Prospector last review date
Prospector was last reviewed on Jan 28, 2025.

Black

  1. Black is a Python source code formatter.
  2. It does not do anything else besides formatting Python code.
  3. It does not support any linting rules as it is only a formatter.
  4. It is similar to Ruff in terms of formatting performance.
  5. It provides the same formatting capabilities as Ruff.
  6. It provides caching mechanisms for performance.
  7. It has an official VS Code extension.
Note on Black last review date
Black was last reviewed on Jan 28, 2025.

SonarQube

  1. SonarQube is a SaaS source code linter.
  2. It supports linting for several languages and also other features like code coverage and SCA.
  3. It does not seem to publish which rules it supports for Python.
  4. It is much slower compared to Ruff and Prospector.
  5. It does not provide any formatting capabilities.
  6. Although it provides cache mechanisms, we found that they actually made the tool slower.
  7. Although it has an official VS Code extension, we found it was very slow and affected development experience.
Note on SonarQube last review date
SonarQube was last reviewed on Jan 28, 2025.

Usage

We use Ruff for linting and formatting all of Fluid Attacks' Python source code.