Skip to main content

A fast, opinionated, extensible linter for Gherkin .feature files and Behave test suites.

Project description

behave-lint

CI Python License: MIT Code style: Ruff

A fast, opinionated, extensible linter for Gherkin .feature files and Behave test suites.

behave-lint statically analyzes your Gherkin feature files for correctness, consistency, complexity, and style — without executing a single test. It ships with 41 built-in rules across 6 categories, supports auto-fix for common violations, and outputs in 5 formats including SARIF for GitHub Code Scanning.

Why behave-lint?

Without behave-lint With behave-lint
Duplicate step definitions cause silent match failures BD001 detects duplicates at lint time
Inconsistent tag casing breaks CI filters BS001 auto-fixes to snake_case
Trailing punctuation in steps clutters reports BD005 strips it automatically
No Given-When-Then ordering enforcement BC001 catches structural violations
Feature files grow unchecked in complexity BX001-BX005 enforce limits

Installation

pip install behave-lint

Or with uv:

uv add behave-lint

Quick start

# Lint all feature files
behave-lint features/

# Apply safe auto-fixes
behave-lint features/ --fix

# JSON output for CI integration
behave-lint features/ --json --output-file report.json

# SARIF for GitHub Code Scanning
behave-lint features/ --sarif --output-file results.sarif

# List all available rules
behave-lint --list-rules

# Explain a specific rule
behave-lint --explain BC001

Features

  • 41 built-in rules across 6 categories: correctness, step definitions, consistency, complexity, style, and pedantic.
  • Auto-fix — safe, deterministic fixes for common violations (--fix). Unsafe fixes require --unsafe-fixes.
  • 5 output formats — console (colored), JSON, SARIF, Markdown, and GitHub Actions inline annotations.
  • Zero-config — sensible defaults work out of the box. Override anything via [tool.behave-lint] in pyproject.toml.
  • Plugin system — write custom rules and reporters as Python packages. Register via entry points.
  • CI/CD ready — deterministic output, clear exit codes, SARIF integration with GitHub Code Scanning.
  • Fast — sub-second on typical projects through caching and parallel execution.

Rules

Category Prefix Rules Default Severity
Correctness BC 6 Error
Step Definitions BD 5 Warning
Consistency BK 5 Warning / Info
Complexity BX 5 Warning
Style BS 5 Warning
Pedantic BP 5 Info

Auto-fixable rules

Rule Fix Safety
BC004 Replace invalid tag characters with _ Safe
BD004 Convert {param}<param> Safe
BD005 Remove trailing punctuation from steps Safe
BS001 Convert tags to snake_case Safe

Configuration

Configure behave-lint in your pyproject.toml:

[tool.behave-lint]
select = ["BC001", "BC002", "BS001"]
ignore = ["BP001", "BP002"]
fail-on = "warning"
exclude = ["features/wip/"]

[tool.behave-lint.severity]
BK001 = "info"

[tool.behave-lint.rules]
BX001 = { max-steps = 8 }
BP003 = { min-length = 5 }

Precedence (lowest → highest):

  1. Built-in defaults
  2. pyproject.toml [tool.behave-lint]
  3. Environment variables (BEHAVE_LINT_*)
  4. CLI flags

See the Configuration guide for all options.

CI/CD integration

GitHub Actions with SARIF

- run: pip install behave-lint
- run: behave-lint features/ --sarif --output-file behave-lint.sarif
- uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: behave-lint.sarif

Inline annotations

- run: behave-lint features/ --output github

See the CI/CD guide for full workflows.

Output formats

Format Flag Use case
Console --output console Local development (default)
JSON --json CI pipelines, custom tooling
SARIF --sarif GitHub Code Scanning
Markdown --output markdown PR comments, reports
GitHub --output github Inline PR annotations

See the Output Formats reference for schema details.

Examples

Runnable example projects in the examples/ directory:

Example Description
basic-usage Minimal project with configuration
auto-fix Before/after demo of --fix
ci-cd GitHub Actions with SARIF upload
custom-rules Custom rule plugin with entry points

Documentation

User guide

Rules

Guides

Design documents

Development

git clone https://github.com/MathiasPaulenko/behave-lint.git
cd behave-lint
uv sync
uv run pre-commit install

# Run tests
uv run pytest

# Lint
uv run ruff check src/ tests/

# Type check
uv run mypy src/

# Build docs
uv run mkdocs build --strict

See CONTRIBUTING.md for detailed contribution guidelines, coding standards, and PR workflow.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

behave_lint-1.6.0.tar.gz (156.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

behave_lint-1.6.0-py3-none-any.whl (113.7 kB view details)

Uploaded Python 3

File details

Details for the file behave_lint-1.6.0.tar.gz.

File metadata

  • Download URL: behave_lint-1.6.0.tar.gz
  • Upload date:
  • Size: 156.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for behave_lint-1.6.0.tar.gz
Algorithm Hash digest
SHA256 3cdc666298a603ad35c23b729569d1f255e7bdc16b499f1b89643341672bcdf8
MD5 c59358fbb69acb0ddfa9d15e24ae87f3
BLAKE2b-256 1b566262d2a39e505e8ffcd6f9bfcfe291f2341c1efb3e6d5ec8baf8a7a9c2f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for behave_lint-1.6.0.tar.gz:

Publisher: release.yml on MathiasPaulenko/behave-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file behave_lint-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: behave_lint-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 113.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for behave_lint-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ffd6286bb2f9d9f8053e27d4cfa573afe17e0f5d681da9884a2fa63aa2d580a
MD5 aa9ad175cab2da302a33c6d0ecaf87a6
BLAKE2b-256 a2b7df6fb8290642c332682f146d9ef3b1544d9fd5a1062e8cc866c8aa13094d

See more details on using hashes here.

Provenance

The following attestation bundles were made for behave_lint-1.6.0-py3-none-any.whl:

Publisher: release.yml on MathiasPaulenko/behave-lint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page