SKY-A135 · AI-code defects
Code left unused by the change
Code is left unused by a change when a function, method, class or JavaScript file had a production caller in the base version and has none after the change. It usually sits in a file the change did not touch: an agent switched a call site to a new helper and left the old one behind.
- Languages
- Python, TypeScript/JavaScript (symbols and whole files), Java, Kotlin, Go (needs the skylos-go engine), PHP, Rust, and the other languages the dead-code engine reads
- Turned on by
skylos doneafter a change (default baseHEAD, so uncommitted edits), orskylos done --base origin/mainfor a pull request- Quality gate
- not checked (full and diff scans). Only
skylos doneruns this rule, in itsbranch_orphanscheck, which advises by default: findings are listed and the verdict does not fail. Withbranch_orphans = "block"under[tool.skylos.done.checks]in the base commit'spyproject.toml, SKY-A135 findings fail the verdict, except the doubtful ones described below, which stay advice. - Finding type
- review
Why it matters
Diff-based review never shows the orphan, because none of its lines changed. It stays in the code, keeps being maintained and tested, and the next reader or agent may call the old, now-wrong helper.
What Skylos flags
"""Price formatting for the shop pages.""" def price_label(cents): return f"${cents / 100:,.2f}"Removed: from app.pricing import price_labelAdded: from app.money import format_money def line_text(item):Removed: return f"{item['name']}: {price_label(item['cents'])}"Added: return f"{item['name']}: {format_money(item['cents'], 'USD')}""""Money formatting in several currencies.""" SYMBOLS = {"USD": "$", "EUR": "€", "GBP": "£"} def format_money(cents, currency): return f"{SYMBOLS[currency]}{cents / 100:,.2f}"1 committed file the change leaves alone
from app.checkout import line_text if __name__ == "__main__": print(line_text({"name": "Mug", "cents": 1250}))What Skylos leaves alone
Removed: from app.pricing import price_labelAdded: from app.money import format_money def line_text(item):Removed: return f"{item['name']}: {price_label(item['cents'])}"Added: return f"{item['name']}: {format_money(item['cents'], 'USD')}""""Money formatting in several currencies.""" SYMBOLS = {"USD": "$", "EUR": "€", "GBP": "£"} def format_money(cents, currency): return f"{SYMBOLS[currency]}{cents / 100:,.2f}"3 committed files the change leaves alone
from app.pricing import price_label def receipt_total(order): return f"Total: {price_label(order['total_cents'])}"from app.checkout import line_textfrom app.receipts import receipt_total if __name__ == "__main__": print(line_text({"name": "Mug", "cents": 1250})) print(receipt_total({"total_cents": 1250}))Why Skylos leaves it alone
The same call to price_label was removed, but app/receipts.py still calls it. A symbol is reported only when no production caller is left.
More languages
JavaScript
Flagged
export function priceLabel(cents) { return `$${(cents / 100).toFixed(2)}`;}Removed: import { priceLabel } from "./pricing.js";Added: import { formatMoney } from "./money.js"; export function lineText(item) {Removed: return `${item.name}: ${priceLabel(item.cents)}`;Added: return `${item.name}: ${formatMoney(item.cents, "USD")}`;}const SYMBOLS = { USD: "$", EUR: "€", GBP: "£" }; export function formatMoney(cents, currency) { return `${SYMBOLS[currency]}${(cents / 100).toFixed(2)}`;}2 committed files the change leaves alone
{"name": "shop", "type": "module", "main": "src/index.js"}import { lineText } from "./checkout.js"; console.log(lineText({ name: "Mug", cents: 1250 }));Not flagged
Removed: import { priceLabel } from "./pricing.js";Added: import { formatMoney } from "./money.js"; export function lineText(item) {Removed: return `${item.name}: ${priceLabel(item.cents)}`;Added: return `${item.name}: ${formatMoney(item.cents, "USD")}`;}const SYMBOLS = { USD: "$", EUR: "€", GBP: "£" }; export function formatMoney(cents, currency) { return `${SYMBOLS[currency]}${(cents / 100).toFixed(2)}`;}4 committed files the change leaves alone
import { priceLabel } from "./pricing.js"; export function receiptTotal(order) { return `Total: ${priceLabel(order.totalCents)}`;}import { lineText } from "./checkout.js";import { receiptTotal } from "./receipts.js"; console.log(lineText({ name: "Mug", cents: 1250 }));console.log(receiptTotal({ totalCents: 1250 }));Why Skylos leaves it alone
src/receipts.js still imports src/pricing.js, so the file keeps a production importer. In the flagged version nothing imports it any more, and the whole file is reported.
How Skylos decides
- Runs in
skylos donewhen the change touches production code. Copies the base commit and the working tree (or pull request head) into private temporary folders, removes test files from both, and runs the regular dead-code analysis on each, with a confidence of 75 or more. Nothing in the repository runs. - A function, method or class that is alive in the base copy and unused in the head copy is a candidate, matched by name, kind and base line. A JS or TS file that something imported at the base and nothing imports now is a candidate too. Generated files and test code are never reported.
- A symbol the analyzer is unsure about (a weak helper name, for example) is kept only when a line the change removed used it, and then stays advice. A candidate whose name appears in a file the analyzer could not parse, or in a template or config file, or that has a decorator which may register it with a framework, is not judged.
- Survivors go through the same grep check as
skylos .(on the head copy without tests); any remaining use clears them. The message names the removed or changed line that used to call the symbol, and says when only tests still call it.
How to fix it
Delete the orphan in the same change (here, remove price_label from app/pricing.py, or the whole file once it holds nothing else), or point the old callers back at it if dropping them was a mistake.
When it can be wrong
- Code reached only by reflection, string dispatch or a plugin system the dead-code engine does not know looks unused, as it does for SKY-U001.
- Public library API that only other packages call is reported once its last caller in this repository goes away.
- Languages whose engine is not installed (Go without
skylos-go, Dart without Dart support) are listed as not checked, not passed.
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
skylos donedoes not read# skylos: ignorecomments for this rule. The check advises by default. To keep it advisory, or to turn it off, set its mode in the base commit'spyproject.toml.TOML [tool.skylos.done.checks]branch_orphans = "off"