slopcheck 0.1.0
29 / 100
█████░░░░░░░░░░░ sloppy
5 files
191 lines
20 findings
6 errors · 9 warnings · 5 notes

demo/taskflow/client.py

11:5SLP001error

bare except swallows errors, including KeyboardInterrupt and SystemExit

    except:
        pass

Catch the specific exception you can handle, or let it propagate. A bare except also catches KeyboardInterrupt and SystemExit.

18:5SLP002error

broad except swallows the error

    except Exception:
        return None

Handle the specific error, or re-raise. Returning None here hides a real failure.

26:9SLP003error

except handler returns dummy value {}

        return {}

Return a real result or raise. An empty dict, list, or string from except is made-up data.

33:9SLP015warning

except handler returns an error payload instead of raising

        return "Error: failed to fetch title"

Raise, or return a value the caller expects on purpose. An error string drops the traceback.

37:5SLP005warning

leftover debug print

    print("DEBUG reached task fetch")

Remove the debug call. A normal print of a finished message is left alone.

38:5SLP005warning

leftover debug f-string

    print(f"{tasks=}")

Remove the debug call. A normal print of a finished message is left alone.

39:5SLP005warning

leftover breakpoint or set_trace()

    breakpoint()

Remove the debug call. A normal print of a finished message is left alone.

46:13SLP011warning

try/except nested to depth 3 (limit 2)

            try:
                return url.strip()
            except ConnectionError as exc:

Flatten the handlers or split the function. Deeply nested try blocks hide which error is which.

demo/taskflow/imports_hallucinated.py

3:8SLP010error

import `requets` does not resolve

import requets

Point the import at a real module. Optional imports belong in `try/except ImportError`. Allow known extras under rules.SLP010.allowed_modules.

4:1SLP010error

import `jason` does not resolve

from jason import loads

Point the import at a real module. Optional imports belong in `try/except ImportError`. Allow known extras under rules.SLP010.allowed_modules.

5:25SLP010error

`defaultdictx` is not an attribute of `collections`

from collections import defaultdictx

Point the import at a real module. Optional imports belong in `try/except ImportError`. Allow known extras under rules.SLP010.allowed_modules.

demo/taskflow/utils.py

7:5SLP004note

narrating comment restates the code

    # increment index
    index += 1

Delete the comment. Keep a comment only when it says something the code cannot.

12:1SLP004note

narrating comment restates the code

# This function returns the count
def task_count(tasks):

Delete the comment. Keep a comment only when it says something the code cannot.

13:1SLP012note

docstring is 11 lines on a 1-statement function

def task_count(tasks):
    """Return the number of tasks.

Cut the docstring to one line, or delete it. The body is already shorter than the preface.

28:1SLP006warning

private function `_format_legacy_banner` is never used

def _format_legacy_banner(text):
    return "*** " + text + " ***"

Delete the helper, or call it. Methods are skipped; other modules may use them.

34:5SLP008note

over-defensive check: `name` is a non-None literal here

    if name is not None:
        return name.upper()

Delete the branch. Checks on parameters and on values returned from calls are kept.

39:1SLP009warning

function body is only pass

def export_tasks(tasks, path):
    """Write tasks somewhere eventually."""
    pass

Implement the function or delete it. Abstract methods and `.pyi` stubs are ignored.

45:5SLP014note

commented-out code (2 lines)

    # status = "archived"
    # owner = "ada"

Delete it. Version control remembers the old line.

70:1SLP007warning

duplicate of `summarize_tasks` (100% similar)

def summarize_tasks_v2(tasks, limit):
    rows = []
    index = 0

Keep one function and parameterize the difference. Delete the copy.

70:1SLP013warning

`summarize_tasks_v2` looks like a leftover versioned name

def summarize_tasks_v2(tasks, limit):
    rows = []
    index = 0

Rename it to the real name and delete the previous copy. Suffixes like `_new` are flagged when the base name still exists.