Skip to main content

A small CLI tool that scans a codebase for string and numeric literals, helping you quickly spot hard-coded values in source files.

Project description

litscan 1.1.0

A small CLI tool that scans a codebase for string and numeric literals, helping you quickly spot hard-coded values in source files.

Prerequisites

  • Python 3.14+

Installation

pip install litscan

Usage

After installation, litscan is available as a console script:

litscan <path> [options]

What is detected

The scanner recognises the following literal types in any source file:

Type Examples
Triple-quoted strings (multiline) """hello""", '''world'''
Double-quoted strings "hello"
Single-quoted strings 'world'
Decimal numbers 3.14, 0.5
Integer numbers 42, 0

Results are grouped by unique literal value and sorted by occurrence count (highest first).

Arguments

Argument Description
path Target directory or file to scan. Multiple paths can be specified, separated by a semicolon (e.g. src;lib;tests).

Options

Option Default Description
--ext <exts> (all files) Comma-separated extensions to include (e.g. py,js,ts)
--output <name> litscan-output Base name (without extension) for output file(s)
--output-dir <dir> reports Directory where output file(s) will be written
--format <fmt> json Output format: json, html, or all
--workers <n> min(32, cpu_count + 4) Number of parallel worker threads used during scanning
--db <path> <system-temp>/litscan.db Path to the SQLite scratch database that stores occurrences during a scan run. Session records are removed after the report is written.

Examples

Scan all files in the current directory and produce a JSON report:

litscan .

Scan only Python and JavaScript files in src/:

litscan src --ext py,js

Generate both JSON and HTML reports in a custom directory:

litscan . --format all --output-dir my-reports

Scan a Java source tree with a custom output name:

litscan src/main/java --ext java --format all --output-dir reports

Configuration

Environment variable Description
LITSCAN_CONFIG_DIR Directory where logging.ini is seeded and read from. When unset, the bundled logging.ini inside the package is used directly.

Development

Prerequisites

  • Poetry 2.2+

Installation

poetry install

Architecture

flowchart TD
    CLI["cli.py\n(entry point)"] --> util["setup_logger()\nutil.py"]
    CLI --> discover["discover_files()"]
    discover --> concurrent["ThreadPoolExecutor\n(parallel scan)"]
    concurrent --> scan["scan_file()\nscanner.py"]
    scan --> store["SessionStore\nstore.py (SQLite)"]
    store --> report["write_outputs()\nreporter.py"]
    report --> JSON["JSON report"]
    report --> HTML["HTML report"]
Module Responsibility
cli.py Argument parsing, file discovery, orchestration
scanner.py Regex-based literal extraction; LiteralOccurrence / LiteralGroup types
store.py SessionStore — thread-safe SQLite scratch store; one UUID per scan run
reporter.py write_outputs() — renders JSON and/or HTML reports
util.py setup_logger() — logging config seeded from logging.ini

Test with coverage

poetry run pytest --cov=litscan tests --cov-report html

Format and lint

poetry run black litscan; poetry run pylint litscan

Quality gates

  • Coverage ≥ 80%
  • Pylint score 10/10

Changelog

Author

Ron Webb <ron@ronella.xyz>

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

litscan-1.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

litscan-1.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file litscan-1.1.0.tar.gz.

File metadata

  • Download URL: litscan-1.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.14.4 Windows/11

File hashes

Hashes for litscan-1.1.0.tar.gz
Algorithm Hash digest
SHA256 dbfb47571c67e9b15c7c479e5e8c7e41ab2f650c4a10f8a8005ccc6a9870fe67
MD5 7032a02897790a5a431e5b8f998bac49
BLAKE2b-256 1eba350f81ac5d1dedcf73e4c49a268f24ab1cf4a54046f419e03321ed5a9f69

See more details on using hashes here.

File details

Details for the file litscan-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: litscan-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.14.4 Windows/11

File hashes

Hashes for litscan-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8eb66d4a6a5fd48de57708b3a7d4bdfa2d43a5d8a7ae2e527c117a4827086cc
MD5 4c48c2f58af57535ac316094c43d55ab
BLAKE2b-256 c6306c79e0a807bd4fb071c713788efae36ee0f19ebd845e1cf7f0472f6dd27b

See more details on using hashes here.

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