bomquote/transistor

View on GitHub

Showing 35 of 220 total issues

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

    def open(self, url, splash_args:dict=None, reuse_session=False, *args, **kwargs):
Severity: Minor
Found in transistor/crawlers/splash_crawler_abc.py - About 35 mins to fix

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

        def open(self, url, splash_args:dict=None, reuse_session=False, *args, **kwargs):
    Severity: Minor
    Found in transistor/scrapers/splash_scraper_abc.py - About 35 mins to fix

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

          def _init_tasks(self, kwargs):
              """
              Create individual task queues for the workers.
      
              If, Type[StatefulBook] is passed as the `tasks` parameter, the tracker with
      Severity: Minor
      Found in transistor/managers/base_manager.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 _response_callback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _response_callback(self, resp):
              """
              Callback for after response received. If status code is not 200 then
              recursively retry. Retry up to five times.
      
      
      Severity: Minor
      Found in transistor/browsers/splash_browser.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 _write_headers_and_set_fields_to_export has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _write_headers_and_set_fields_to_export(self, item):
              if self.include_headers_line:
                  if not self.fields_to_export:
                      if isinstance(item, dict):
                          # for dicts try using fields of the first item
      Severity: Minor
      Found in transistor/persistence/exporters/exporters.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 _next_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _next_page(self):
              """
              Find the url to the next page from the pagination link.
              """
              if self.page:
      Severity: Minor
      Found in examples/books_to_scrape/scraper.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

      Avoid too many return statements within this function.
      Open

              return value
      Severity: Major
      Found in transistor/persistence/exporters/exporters.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return f"<{type(o).__name__}, {o.status_code}, {o.url}>"
        Severity: Major
        Found in transistor/utility/serialize.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return dict(o)
          Severity: Major
          Found in transistor/utility/serialize.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return str(o)
            Severity: Major
            Found in transistor/utility/serialize.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return f"<{type(o).__name__}, {o.method}, {o.url}>"
              Severity: Major
              Found in transistor/utility/serialize.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return super(TransistorJSONEncoder, self).default(o)
                Severity: Major
                Found in transistor/utility/serialize.py - About 30 mins to fix

                  Function stateful_post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def stateful_post(self, url, *args, **kwargs):
                          """Post to the URL and store the Browser's state, as received from
                          the response object, in this object.
                  
                          All arguments are forwarded to :func:`SplashCrawleraBrowser.post`.
                  Severity: Minor
                  Found in transistor/browsers/splash_browser.py - About 25 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_oldest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def get_oldest(class_name):
                      """Get the oldest object for a specific class name"""
                      for cls, wdict in live_refs.items():
                          if cls.__name__ == class_name:
                              if not wdict:
                  Severity: Minor
                  Found in transistor/utility/trackref.py - About 25 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 _add_soup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _add_soup(self, response, soup_config):
                          """Attaches a soup object to a requests response."""
                          if self.resp_headers:
                              if ("text/html" in self.resp_content_type_header or
                                      SplashBrowser.__looks_like_html(self.html)):
                  Severity: Minor
                  Found in transistor/browsers/splash_browser.py - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language