All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.py.rules.python.S3984.html Maven / Gradle / Ivy

There is a newer version: 4.23.0.17664
Show newest version

Why is this an issue?

Creating a new Exception without actually raising it has no effect and is probably due to a mistake.

Noncompliant code example

def func(x):
    if not isinstance(x, int):
        TypeError("Wrong type for parameter 'x'. func expects an integer")  # Noncompliant
    if x < 0:
        ValueError  # Noncompliant
    return x + 42

Compliant solution

def func(x):
    if not isinstance(x, int):
        raise TypeError("Wrong type for parameter 'x'. func expects an integer")
    if x < 0:
        raise ValueError
    return x + 42

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy