Skip to content

Dead Code (ARCH6188)

Key ruby.quality.dead-code · Severity info · Category quality

Statements after return, raise, break, or next never run; they create confusion and mislead the reader into thinking logic is present.

def fetch(id)
return cache[id] if cache.key?(id)
return load(id)
log("loaded") # unreachable
end
def fetch(id)
return cache[id] if cache.key?(id)
value = load(id)
log("loaded")
value
end

Remove the unreachable statements, or restructure the control flow if they were meant to run.