ionelmc/pytest-benchmark

View on GitHub
src/pytest_benchmark/utils.py

Summary

Maintainability
C
1 day
Test Coverage

File utils.py has 472 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
import json
import netrc
import os
import platform
Severity: Minor
Found in src/pytest_benchmark/utils.py - About 7 hrs to fix

    Function get_commit_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_commit_info(project_name=None):
        dirty = False
        commit = 'unversioned'
        commit_time = None
        author_time = None
    Severity: Minor
    Found in src/pytest_benchmark/utils.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function get_cprofile_functions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_cprofile_functions(stats):
        """
        Convert pstats structure to list of sorted dicts about each function.
        """
        result = []
    Severity: Minor
    Found in src/pytest_benchmark/utils.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _parse_hosts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_hosts(storage_url, netrc_file):
        # load creds from netrc file
        path = os.path.expanduser(netrc_file)
        creds = None
        if netrc_file and os.path.isfile(path):
    Severity: Minor
    Found in src/pytest_benchmark/utils.py - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __call__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, *args, **kwargs):
            for func in self.functions:
                try:
                    value = func(*args, **kwargs)
                except self.exceptions:
    Severity: Minor
    Found in src/pytest_benchmark/utils.py - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function short_filename has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def short_filename(path, machine_id=None):
        parts = []
        try:
            last = len(path.parts) - 1
        except AttributeError:
    Severity: Minor
    Found in src/pytest_benchmark/utils.py - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    There are no issues that match your filters.

    Category
    Status