Skip to content
Back to skills

483 Semantically Dead Code 824ee2a7

ASecurity

grep -n "_gitignore_patterns" src/tunacode/tools/glob.py ``` If all references are writes, it's dead.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 1, 2026
code-qualitybashgitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned June 1, 2026

npx -y skills add tools-only/X-Skills --skill 483-semantically-dead-code_824ee2a7 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 483 Semantically Dead Code 824ee2a7?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 483 Semantically Dead Code 824ee2a7
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-483-semantically-dead-code-824ee2a7/badge)](https://www.skillsdirectory.com/skills/tools-only-483-semantically-dead-code-824ee2a7)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
title: Semantically Dead Code - Loaded But Never Read
link: semantically-dead-code
type: qa
path: qa/
depth: 1
seams: [M]
ontological_relations:
  - relates_to: [[dead-code-detection]]
  - affects: [[glob-tool]]
  - fixes: [[wasted-cycles, api-lies]]
tags:
  - dead-code
  - static-analysis
  - antipattern
  - glob
created_at: 2026-01-14T12:45:00Z
updated_at: 2026-01-14T12:45:00Z
uuid: 953376a5-10a7-4d6b-8aee-c8468b4d267d
---

## Problem

`glob.py` had a `use_gitignore` parameter that did nothing. The function `_load_gitignore_patterns()` was called, populated a global `_gitignore_patterns`, but that global was never read. The actual filtering used `DEFAULT_EXCLUDE_DIRS` instead.

Static analysis tools (Vulture) reported "no dead code" because the function WAS called and the variable WAS assigned.

## Root Cause

**Syntactic vs semantic dead code.** Static analyzers check "is this symbol referenced?" not "is the result consumed?"

The code path was:
```
use_gitignore=True
  -> _load_gitignore_patterns() called
    -> _gitignore_patterns populated
      -> NEVER READ ANYWHERE
```

All 7 references to `_gitignore_patterns` were writes, zero reads.

## Why It Matters

1. **Wasted I/O** - Reading .gitignore files on every glob call for nothing
2. **API lie** - `use_gitignore` parameter implied functionality that didn't exist
3. **Global state pollution** - Module-level mutable state with no consumer
4. **Race condition** - Cache init had check-then-act bug (moot since never used)

## Detection Method

Static analysis fails. Manual review required:

```bash
# Find all references
grep -n "_gitignore_patterns" src/tunacode/tools/glob.py

# Check for READS (not just assignments)
# Writes: =, .add(), .update()
# Reads: in, if X, for x in X, return X, func(X)
```

If all references are writes, it's dead.

## Prevention

Before shipping code that "loads X":

1. **Grep for reads of X** - Not just references, actual consumption
2. **Trace parameter data flow** - If `use_foo` controls behavior, prove it changes output
3. **Question unused returns** - If a function populates state but nothing reads it, why?

## The Fix

Removed 37 lines:
- `_gitignore_patterns` global
- `_load_gitignore_patterns()` function
- `use_gitignore` parameter
- The call site

Also fixed deprecated `asyncio.get_event_loop()` -> `asyncio.to_thread()`.

## Related

- `memory-bank/research/2026-01-14_12-27-29_glob-tool-bottlenecks.md` - Original research
- `.claude/skills/dead-code-detector/` - Vulture-based detection (syntactic only)

Files in this skill

  • README.md1 KB
  • skill.md2.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.