Skip to main content

SKY-U005 · Dead code

Unused dependency

Medium

The catalog gives no severity for this rule; the detector always reports MEDIUM.

A declared Python runtime dependency or npm implementation/tooling dependency has no observed source, command or supported configuration use. Every install still downloads it.

Languages
Python, npm package.json
Turned on by
skylos . --quality (or -a)
Quality gate
counted toward the gate limits (full and diff scans). Reported in the quality list, so it counts toward max_quality (10 by default), not max_dead_code.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Each unused package makes installs slower and images larger, and is one more thing that can carry a vulnerability or be taken over by an attacker. Dependencies left behind after a rewrite are rarely noticed otherwise.

What Skylos flags

requirements.txt · TextReported on line 5
flask==3.0.3requests==2.32.3PyYAML==6.0.2beautifulsoup4==4.12.3python-dateutil==2.9.0
app.py · Python
"""Price watcher service."""import requestsimport yamlfrom bs4 import BeautifulSoupfrom flask import Flask app = Flask(__name__)  @app.get("/price")def price():    with open("settings.yml") as handle:        settings = yaml.safe_load(handle)    page = requests.get(settings["url"], timeout=10).text    return BeautifulSoup(page, "html.parser").select_one(".price").text

What Skylos leaves alone

requirements.txt · Text
flask==3.0.3requests==2.32.3PyYAML==6.0.2beautifulsoup4==4.12.3alembic==1.13.2
Procfile · Text
release: alembic upgrade headweb: flask run

app.py: same as in the flagged example.

Why Skylos leaves it alone

PyYAML is imported as yaml and beautifulsoup4 as bs4: Skylos maps distribution names to the modules they provide. alembic is never imported, but the Procfile runs its command, which counts as a use.

How Skylos decides

  1. For npm, also reads dependencies and devDependencies from each owning package.json with --quality. Literal imports (including Vue, Svelte and Astro script and style blocks, MDX ESM and stylesheet at-rules), package scripts, GitHub Actions run: steps, Dockerfile, Makefile, Procfile and GitLab CI commands, /// <reference types> directives, tsconfig types (following relative extends), supported tool configurations and package names in tool config strings supply usage; peer contracts are retained. An ancestor declaration that a workspace's import or command resolves to counts as used.
  2. An @types/x package is reported only when x is used nowhere in the project and no tsconfig types entry, reference directive or ambient global names it; @types/node stays while any source uses Node built-ins or process. A package declared in two sections is reported in each.
  3. The npm check never runs package code or scripts. Command lines are read segment by segment, with $VAR arguments, redirections, cross-env, yarn --cwd/npm --prefix targets and node <script> files followed. Dynamic loaders that are not proven local, an expanded command name, unread source, unparsed components and incomplete source selection prevent absence claims. An unknown command holds back only the uninstalled, name-related dependencies that could provide it; an unread ESLint, Babel, Prettier or tool config holds back only that tool's family; an unresolved workspace consumer holds back only the ancestor declarations it could resolve. The receipt is analysis_summary.npm_dependency_analysis.
  4. Runs with --quality on a directory scan that contains Python files (not when you scan single files). It reads run-time declarations next to the code, walking up at most five folders to the project root: requirements.txt and requirements/*.txt (following -r includes, ignoring -c constraint files), [project].dependencies in pyproject.toml, and install_requires in setup.cfg or setup.py. Extras, setup_requires and tests_require are not read.
  5. Treats compiled lock files (pip-compile or uv output with hashes and # via comments) as pins, not declarations, and reads their .in input files instead.
  6. Collects uses: imports (including importlib.import_module and other string imports), module names in Django settings and other configuration, entry points, mypy and Sphinx plugins, pytest plugins, fixtures and markers, and commands in a Procfile, Dockerfile, Compose file or Makefile.
  7. Never reports the project itself, command-line tools (black, ruff, pytest, mypy and similar), runtime plugins such as gunicorn, celery and database drivers, or type-stub packages. Maps each remaining package to the modules it installs, using the installed package metadata and a bundled name table, and keeps it when any of them is used.
  8. Abstains, with a reason in analysis_summary.unused_dependency_analysis, when an import or configuration value could not be resolved or a shared namespace hides which package is used. Otherwise reports MEDIUM on the package's line in the manifest.

How to fix it

Remove the package from the manifest and reinstall. If it is needed by something Skylos cannot see, such as a notebook or a deploy script outside the repository, move it to an extra or a separate requirements file for that use.

Fix · Text
flask==3.0.3requests==2.32.3PyYAML==6.0.2beautifulsoup4==4.12.3

When it can be wrong

  • Packages used only by notebooks, scripts outside the scanned folder or a shell command Skylos does not read are reported.
  • A package loaded only through a plugin system Skylos does not know (a setting string it cannot resolve) is reported; an import it cannot resolve makes it abstain for every package instead.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • An inline # skylos: ignore[SKY-U005] comment in requirements.txt is not read: the package stays reported.

  • [tool.skylos] ignore = ["SKY-U005"] turns the rule off; the summary then records rule_ignored.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.