SKY-A136 · AI-code defects
New code nothing calls
New code nothing calls is a function, method, class or JavaScript file that the change added and that no code reaches, or that only other unused code calls. Agents often write a helper, then solve the task another way and leave the helper 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-A136 findings fail the verdict. - Finding type
- review
Why it matters
Unused new code makes a change look bigger and more finished than it is. It can also mean the wiring step was forgotten: the new handler or validator exists but nothing ever runs it.
What Skylos flags
"""Order totals for the checkout service.""" def order_total(items): return sum(item["cents"] * item["qty"] for item in items)Added: Added: Added: def apply_coupon(total_cents, percent_off):Added: return round(total_cents * (100 - percent_off) / 100)1 committed file the change leaves alone
from app.orders import order_total if __name__ == "__main__": print(order_total([{"cents": 1250, "qty": 2}]))What Skylos leaves alone
"""Order totals for the checkout service.""" Removed: from flask import FlaskAdded: from flask import Flask, request app = Flask(__name__) def order_total(items): return sum(item["cents"] * item["qty"] for item in items)Added: Added: Added: @app.post("/orders/total")Added: def order_total_view():Added: return {"total_cents": order_total(request.json["items"])}Why Skylos leaves it alone
No code in the repository calls order_total_view either, but Flask does: the route decorator registers it. Skylos treats framework routes as used, and does not judge a symbol under a decorator that may register it.
More languages
TypeScript
Flagged
export interface Item { cents: number; qty: number;} export function orderTotal(items: Item[]): number { return items.reduce((sum, item) => sum + item.cents * item.qty, 0);}Added: Added: function applyCoupon(totalCents: number, percentOff: number): number {Added: return Math.round((totalCents * (100 - percentOff)) / 100);Added: }2 committed files the change leaves alone
{"name": "shop", "type": "module", "main": "src/index.ts"}import { orderTotal } from "./orders.js"; console.log(orderTotal([{ cents: 1250, qty: 2 }]));Not flagged
export interface Item { cents: number; qty: number;} Removed: export function orderTotal(items: Item[]): number {Removed: return items.reduce((sum, item) => sum + item.cents * item.qty, 0);Added: export function orderTotal(items: Item[], percentOff = 0): number {Added: const total = items.reduce((sum, i) => sum + i.cents * i.qty, 0);Added: return applyCoupon(total, percentOff);}Added: Added: function applyCoupon(totalCents: number, percentOff: number): number {Added: return Math.round((totalCents * (100 - percentOff)) / 100);Added: }2 committed files the change leaves alone
Why Skylos leaves it alone
The new applyCoupon is called by orderTotal, which the entry point uses, so the new code is wired in.
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 unused in the head copy and whose declaration line the change added is new when its name is on no removed line and most of its body is new lines; a definition moved or renamed from elsewhere in the change is not new. A JS or TS file the change added that nothing imports is reported as a whole.
- Entry points, framework roots (routes, views, fixtures, commands), exported public API and dispatch the dead-code engine recognises count as used. A new symbol the analyzer is unsure about, one whose name appears in a template, config file or a file it could not parse, and one under a decorator that may register it are not judged.
- Survivors go through the same grep check as
skylos .(on the head copy without tests). A survivor that a test calls is reported as SKY-A137 instead.
How to fix it
Wire the new code in where it was meant to run, or delete it. A helper written for a later change belongs in that change.
def order_total(items, percent_off=0): total = sum(item["cents"] * item["qty"] for item in items) return apply_coupon(total, percent_off)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.
- A new public library function that only other packages will call is reported until something in the repository uses it or exports it.
- 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 SKY-A136 advisory whilebranch_orphansblocks, leave it out ofbranch_orphans_block_rulesin the base commit'spyproject.toml.TOML [tool.skylos.done]branch_orphans_block_rules = ["SKY-A135"] [tool.skylos.done.checks]branch_orphans = "block"