Skip to content

Files

Latest commit

 

History

History
25 lines (17 loc) · 517 Bytes

simplifiable-if-statement.md

File metadata and controls

25 lines (17 loc) · 517 Bytes

Pattern: Use of verbose boolean return

Issue: -

Description

This error occurs when you have an if statement that can be refactored by using the value of the condition, rather than putting in extra True and False literals. This makes the code more succinct and clear to the readers.

Example of incorrect code:

def is_odd(num):
    if num % 2 != 0:
        return True
    else:
        return False

Example of correct code:

def is_odd(num):
    return num % 2 != 0