bomquote/transistor

View on GitHub
transistor/scrapers/splash_scraper_abc.py

Summary

Maintainability
A
3 hrs
Test Coverage

File splash_scraper_abc.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""
transistor.scrapers.splash_scraper_abc
~~~~~~~~~~~~
This module implements an abstract base class for a scraper which assumes the
Severity: Minor
Found in transistor/scrapers/splash_scraper_abc.py - About 2 hrs to fix

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

        def _stateful_post(self, url, *args, **kwargs):
            """
            Execute sending the post request to the local running Splash service with our
            self.browser object.
    
    
    Severity: Minor
    Found in transistor/scrapers/splash_scraper_abc.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 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

      Missing whitespace around parameter equals
      Open

          def __init__(self, script:str=None, **kwargs):

      Don't use spaces around the '=' sign in function arguments.

      Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value, except when
      using a type annotation.
      
      Okay: def complex(real, imag=0.0):
      Okay: return magic(r=real, i=imag)
      Okay: boolean(a == b)
      Okay: boolean(a != b)
      Okay: boolean(a <= b)
      Okay: boolean(a >= b)
      Okay: def foo(arg: int = 42):
      Okay: async def foo(arg: int = 42):
      
      E251: def complex(real, imag = 0.0):
      E251: return magic(r = real, i = imag)
      E252: def complex(real, image: float=0.0):

      Missing whitespace after ':'
      Open

          def open(self, url, splash_args:dict=None, reuse_session=False, *args, **kwargs):

      Each comma, semicolon or colon should be followed by whitespace.

      Okay: [a, b]
      Okay: (3,)
      Okay: a[1:4]
      Okay: a[:4]
      Okay: a[1:]
      Okay: a[1:4:2]
      E231: ['a','b']
      E231: foo(bar,baz)
      E231: [{'a':'b'}]

      Missing whitespace around parameter equals
      Open

          def open(self, url, splash_args:dict=None, reuse_session=False, *args, **kwargs):

      Don't use spaces around the '=' sign in function arguments.

      Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value, except when
      using a type annotation.
      
      Okay: def complex(real, imag=0.0):
      Okay: return magic(r=real, i=imag)
      Okay: boolean(a == b)
      Okay: boolean(a != b)
      Okay: boolean(a <= b)
      Okay: boolean(a >= b)
      Okay: def foo(arg: int = 42):
      Okay: async def foo(arg: int = 42):
      
      E251: def complex(real, imag = 0.0):
      E251: return magic(r = real, i = imag)
      E252: def complex(real, image: float=0.0):

      Missing whitespace around parameter equals
      Open

          def open(self, url, splash_args:dict=None, reuse_session=False, *args, **kwargs):

      Don't use spaces around the '=' sign in function arguments.

      Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value, except when
      using a type annotation.
      
      Okay: def complex(real, imag=0.0):
      Okay: return magic(r=real, i=imag)
      Okay: boolean(a == b)
      Okay: boolean(a != b)
      Okay: boolean(a <= b)
      Okay: boolean(a >= b)
      Okay: def foo(arg: int = 42):
      Okay: async def foo(arg: int = 42):
      
      E251: def complex(real, imag = 0.0):
      E251: return magic(r = real, i = imag)
      E252: def complex(real, image: float=0.0):

      Missing whitespace around parameter equals
      Open

          def __init__(self, script:str=None, **kwargs):

      Don't use spaces around the '=' sign in function arguments.

      Don't use spaces around the '=' sign when used to indicate a
      keyword argument or a default parameter value, except when
      using a type annotation.
      
      Okay: def complex(real, imag=0.0):
      Okay: return magic(r=real, i=imag)
      Okay: boolean(a == b)
      Okay: boolean(a != b)
      Okay: boolean(a <= b)
      Okay: boolean(a >= b)
      Okay: def foo(arg: int = 42):
      Okay: async def foo(arg: int = 42):
      
      E251: def complex(real, imag = 0.0):
      E251: return magic(r = real, i = imag)
      E252: def complex(real, image: float=0.0):

      Missing whitespace after ':'
      Open

          def __init__(self, script:str=None, **kwargs):

      Each comma, semicolon or colon should be followed by whitespace.

      Okay: [a, b]
      Okay: (3,)
      Okay: a[1:4]
      Okay: a[:4]
      Okay: a[1:]
      Okay: a[1:4:2]
      E231: ['a','b']
      E231: foo(bar,baz)
      E231: [{'a':'b'}]

      Continuation line under-indented for visual indent
      Open

                                  'scrapers/certs/crawlera-ca.crt').decode('utf-8')

      Continuation lines indentation.

      Continuation lines should align wrapped elements either vertically
      using Python's implicit line joining inside parentheses, brackets
      and braces, or using a hanging indent.
      
      When using a hanging indent these considerations should be applied:
      - there should be no arguments on the first line, and
      - further indentation should be used to clearly distinguish itself
        as a continuation line.
      
      Okay: a = (\n)
      E123: a = (\n    )
      
      Okay: a = (\n    42)
      E121: a = (\n   42)
      E122: a = (\n42)
      E123: a = (\n    42\n    )
      E124: a = (24,\n     42\n)
      E125: if (\n    b):\n    pass
      E126: a = (\n        42)
      E127: a = (24,\n      42)
      E128: a = (24,\n    42)
      E129: if (a or\n    b):\n    pass
      E131: a = (\n    42\n 24)

      There are no issues that match your filters.

      Category
      Status