Skip to main content

Constant refactoring monitoring tool

Project description

tingle

Spider-sense for refactoring: you know that tingle — the itch that says the codebase isn't right yet. This tool puts a number on it, so you can watch it drop.

Code metrics for the era of constant refactoring.

tingle measures things you want to shrink (or watch) while refactoring a codebase: ignored lint rules, inline # noqa / # type: ignore comments, uses of a legacy class during a strangler-fig migration, lines of code in a package that should disappear.

It runs once, prints the numbers, and stores nothing — pipe the JSON into whatever tracks history for you (CI artifacts, dashboards, a spreadsheet).

📖 Documentation: https://fancysnake.github.io/tingle/

Install

$ pip install tingle

Quick start

$ tingle init                                    # starter tingle.toml
$ tingle add regex_count '#\s*noqa'              # add a metric from the CLI
$ tingle add toml_list_length tool.ruff.lint.ignore --name ruff-ignores
$ tingle                                         # interactive mode (on a terminal)
$ tingle stat                                    # summary table
$ tingle stat --json                             # machine-readable output
$ tingle stat --diff                             # impact of the current branch
$ tingle report                                  # every occurrence, file:line
$ tingle report --diff                           # what the branch added/removed

Metrics are declared in tingle.toml (or a [tool.tingle] section in pyproject.toml):

[ranges.python]
include = ["src/**/*.py", "tests/**/*.py"]
default = true

[[metrics]]
name = "noqa-comments"
type = "regex_count"
pattern = '#\s*noqa'

You can count regex matches, uses of a Python symbol, entries in a TOML or INI list (this is how you count ignored lint rules), files, and lines. See the metric types.

What it does

Three things, in rising order of opinion:

  • Measure. tingle stat counts what you told it to count and prints the numbers. Metric values never affect the exit code — tingle measures, it does not judge.
  • Attribute. tingle stat --diff measures only what the current branch changed, against the merge-base with a base branch, so commits that landed on the base after you branched don't pollute your numbers.
  • Judge. tingle check is the CI gate: the same branch measurement, but it exits 1 if the branch made things worse, so a pull request that takes on debt fails the build.
$ tingle check
noqa-comment (regex_count): +2
  + src/api/views.py:23
  + src/api/views.py:41

$ echo $?
1

Documentation

Development

Python 3.11–3.14 are supported (CI runs the full matrix). The project uses mise + Poetry.

$ mise install
$ poetry install
$ mise run test:py      # tests
$ mise run lint:py      # ruff, mypy, pylint, import-linter
$ mise run docs:serve   # preview the docs site

See contributing for the GLIMPSE source layout and the layer contracts.

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

tingle-0.1.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

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

tingle-0.1.0-py3-none-any.whl (52.5 kB view details)

Uploaded Python 3

File details

Details for the file tingle-0.1.0.tar.gz.

File metadata

  • Download URL: tingle-0.1.0.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for tingle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bd24f0eec81ba304f8f661a24b5fe7ed4b6569cfee9db05856dffbd331ae417b
MD5 18c9a531d9c01bd7d028e818664acbf2
BLAKE2b-256 55c6441a7526c05d06566b560bfed82dedea3f197159578292c880a7514361b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tingle-0.1.0.tar.gz:

Publisher: release.yml on fancysnake/tingle

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

File details

Details for the file tingle-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tingle-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 52.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for tingle-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9de03c33c0700d52b38112a86dabf179c9259d6ae75864564681dc82049e93b7
MD5 2ec7c400a467f50f4e60bd4ac2f112e3
BLAKE2b-256 7f4abde37f100080db28f53d1c6365b3be1eff513ba8fc0878b9d7e29d771685

See more details on using hashes here.

Provenance

The following attestation bundles were made for tingle-0.1.0-py3-none-any.whl:

Publisher: release.yml on fancysnake/tingle

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