CodeClone version
2.0.0
Detection family
Function clone
Minimal reproduction
# registry.py
REGISTRY = {}
def register(name):
def wrapper(fn):
REGISTRY[name] = fn
return fn
return wrapper
# handlers.py
from registry import register
@register("handler_a")
def handler_a():
print("A")
# runtime.py
from registry import REGISTRY
def run(name: str):
fn = REGISTRY.get(name)
if fn:
fn()
Why these should NOT be considered clones?
Why these should NOT be considered clones?
The reported dead code is actually reachable at runtime via a registry pattern:
- the function is registered through a decorator
- the decorator mutates shared state (REGISTRY)
- invocation happens indirectly via a lookup (REGISTRY[name])
This pattern is intentionally dynamic and does not produce explicit call edges
in the static control flow graph.
From a semantic perspective:
- the function is part of the executable behavior
- it has externally observable side effects
- removing it breaks runtime functionality
This appears to be a limitation of static reachability rather than unused code.
Additional signals
CodeClone version
2.0.0
Detection family
Function clone
Minimal reproduction
Why these should NOT be considered clones?
Why these should NOT be considered clones?
The reported dead code is actually reachable at runtime via a registry pattern:
This pattern is intentionally dynamic and does not produce explicit call edges
in the static control flow graph.
From a semantic perspective:
This appears to be a limitation of static reachability rather than unused code.
Additional signals