endremborza/aswan

View on GitHub
aswan/connection_session.py

Summary

Maintainability
B
7 hrs
Test Coverage

File connection_session.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import multiprocessing as mp
import sys
import time
from dataclasses import dataclass
Severity: Minor
Found in aswan/connection_session.py - About 2 hrs to fix

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

        def consume(self, task: HandlingTask):
            handler_name = task.handler.name
            if (handler_name in self._broken_handlers) or (
                task.handler.restart_session_after < self._num_queries
            ):
    Severity: Minor
    Found in aswan/connection_session.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_parsed_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_parsed_response(
            self, url, handler=RequestSoupHandler(), params: Optional[dict] = None
        ):
            if params:
                url = add_url_params(url, params)
    Severity: Minor
    Found in aswan/connection_session.py - About 55 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 get_actor_items has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_actor_items(handlers: Iterable[ANY_HANDLER_T], depot_path: Path):
        # TODO this is extreme hacky
        for handler in handlers:
            caps = handler.get_caps()
            full_kwargs = dict(proxy_cls=handler.proxy_cls, depot_path=depot_path)
    Severity: Minor
    Found in aswan/connection_session.py - About 45 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in aswan/connection_session.py - About 45 mins to fix

      Function _log_miss has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _log_miss(self, msg, content, handler: ANY_HANDLER_T, attempt, status, url):
      Severity: Minor
      Found in aswan/connection_session.py - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status