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.4.0.tar.gz (49.3 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.4.0-py3-none-any.whl (65.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tingle-0.4.0.tar.gz
Algorithm Hash digest
SHA256 74cda382a880c3b1798ebc0b6c87028a5c7f9e976ac71be7dadf31465b8282fa
MD5 99ea6f076327e6ab0610261414885c0e
BLAKE2b-256 6b4d04ace3e24b720dac6d72e20c261eb3a94b02ae753376d5c8fdadab2516d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tingle-0.4.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.4.0-py3-none-any.whl.

File metadata

  • Download URL: tingle-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 65.8 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac785377cbffb72f9154cbe0b8907fdc6aa234d59ccb2144c8e1649180c6aae1
MD5 d38aa7b7877862abbb85dcf868d58dd7
BLAKE2b-256 1c7e21e753b59d4ca6e82537298b7751066daeac330eedd1052093a97943bcba

See more details on using hashes here.

Provenance

The following attestation bundles were made for tingle-0.4.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