CodeQL documentation

Unreachable code

ID: py/unreachable-statement
Kind: problem
Security severity: 
Severity: warning
Precision: very-high
Tags:
   - quality
   - maintainability
   - useless-code
   - external/cwe/cwe-561
Query suites:
   - python-security-and-quality.qls

Click to see the query in the CodeQL repository

Unreachable code makes the code more difficult to understand and may slow down loading of modules.

Recommendation

Deleting the unreachable code will make the code clearer and preserve the meaning of the code. However, it is possible that the original intention was that the code should execute and that it is unreachable signifies some other error.

Example

In this example the assignment to remainder is never reached because there is a return statement on the previous line.

import math

def my_div(x, y):
    return math.floor(x / y)
    remainder = x - math.floor(x / y) * y

References

  • © GitHub, Inc.
  • Terms
  • Privacy
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy