Dead Code (ARCH6188)
Ce contenu n’est pas encore disponible dans votre langue.
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.
Incorrect
Section titled “Incorrect”def fetch(id) return cache[id] if cache.key?(id) return load(id) log("loaded") # unreachableendCorrect
Section titled “Correct”def fetch(id) return cache[id] if cache.key?(id) value = load(id) log("loaded") valueendRemove the unreachable statements, or restructure the control flow if they were meant to run.