endremborza/aswan

View on GitHub

Showing 23 of 23 total issues

File base.py has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import pickle
import sys
import time
import zipfile
Severity: Minor
Found in aswan/depot/base.py - About 4 hrs to fix

    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 _pull has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def _pull(self, conn: "Connection", complete: bool, post_status: Optional[str]):
              _ls = partial(self._remote_ls, conn)
              _mv = partial(self._conn_move, conn)
              self._merge_status_cache(conn)
              # TODO: all this set() thing brings a bit of uncertainty
      Severity: Minor
      Found in aswan/depot/remote.py - About 2 hrs 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_handler_events has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_handler_events(
              self,
              handler: Optional[Union[str, ANY_HANDLER_T]] = None,
              only_successful=True,
              only_latest=True,
      Severity: Minor
      Found in aswan/depot/base.py - About 2 hrs 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 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 continue_run has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def continue_run(
      Severity: Major
      Found in aswan/project.py - About 1 hr to fix

        Function integrate_events has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def integrate_events(
            session: Session, events: Iterable[Union[RegEvent, CollEvent]], dump_dir=None
        ):
            reg_urls = defaultdict(list)
            coll_urls = defaultdict(list)
        Severity: Minor
        Found in aswan/metadata_handling.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_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 cleanup_statuses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def cleanup_statuses(self):
                errs = {}
                err_set = set()
                while True:
                    for st in self.statuses_path.iterdir():
        Severity: Minor
        Found in aswan/depot/base.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in aswan/project.py - About 50 mins to fix

          Function browser_wait has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def browser_wait(
          Severity: Major
          Found in aswan/utils.py - About 50 mins to fix

            Function get_caps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_caps(self):
                    caps = [*self.proxy.caps]
                    if isinstance(self, BrowserHandler):
                        if not self.headless:  # pragma: no cover
                            caps.append(Caps.display)
            Severity: Minor
            Found in aswan/url_handler.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 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

                Function _get_leaf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _get_leaf(self, needs_db=False):
                        # just one that has no children
                        # and has the most runs in its tree
                        most_runs = 0
                        leaf, leaf_tree = Status(), set()
                Severity: Minor
                Found in aswan/depot/base.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 get_handler_events has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_handler_events(
                Severity: Minor
                Found in aswan/depot/base.py - About 45 mins to fix

                  Function get_soup has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def get_soup(
                  Severity: Minor
                  Found in aswan/simplified_functions.py - About 35 mins to fix

                    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

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

                      Function monitor has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def monitor(
                      Severity: Minor
                      Found in aswan/monitor_app.py - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language