getsentry/raven-python

View on GitHub

Showing 104 of 146 total issues

Function extract_extra has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def extract_extra(record, reserved=RESERVED, contextual=CONTEXTUAL):
    data = {}

    extra = getattr(record, 'data', None)
    if not isinstance(extra, dict):
Severity: Minor
Found in raven/handlers/logging.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 __init__ has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self, dsn=None, raise_send_errors=False, transport=None,
                 install_sys_hook=True, install_logging_hook=True,
                 hook_libraries=None, enable_breadcrumbs=True,
                 _random_seed=None, **options):
        global Raven
Severity: Minor
Found in raven/base.py - About 1 hr to fix

    Function is_valid_origin has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def is_valid_origin(origin):
        if not settings.SENTRY_ALLOW_ORIGIN:
            return False
    
        if settings.SENTRY_ALLOW_ORIGIN == '*':
    Severity: Minor
    Found in raven/contrib/django/views.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 build_msg has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_msg(self, *args, **kwargs):
            data = super(DjangoClient, self).build_msg(*args, **kwargs)
    
            for frame in self._iter_frames(data):
                module = frame.get('module')
    Severity: Minor
    Found in raven/contrib/django/client.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 process has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def process(self, data, **kwargs):
            resp = self.get_data(data, **kwargs)
            if resp:
                data = resp
    
    
    Severity: Minor
    Found in raven/processors.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_user_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_user_info(self, request):
            """
            Requires Flask-Login (https://pypi.python.org/pypi/Flask-Login/)
            to be installed and setup.
            """
    Severity: Minor
    Found in raven/contrib/flask.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_targetted_stack has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_targetted_stack(self, stack, record):
            # we might need to traverse this multiple times, so coerce it to a list
            stack = list(stack)
            frames = []
            started = False
    Severity: Minor
    Found in raven/handlers/logging.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 _chained_exceptions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _chained_exceptions(exc_info):
            """
            Return a generator iterator over an exception's chain.
    
            The exceptions are yielded from outermost to innermost (i.e. last to
    Severity: Minor
    Found in raven/events.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_client has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_client(client=None, reset=False):
        global _client
    
        tmp_client = client is not None
        if not tmp_client:
    Severity: Minor
    Found in raven/contrib/django/models.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 build_msg has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_msg(self, event_type, data=None, date=None,
                      time_spent=None, extra=None, stack=None, public_key=None,
                      tags=None, fingerprint=None, **kwargs):
            """
            Captures, processes and serializes an event into a dict object
    Severity: Minor
    Found in raven/base.py - About 1 hr to fix

      Function get_lines_from_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_lines_from_file(filename, lineno, context_lines,
                              loader=None, module_name=None):
          """
          Returns context_lines before and after lineno from file.
          Returns (pre_context_lineno, pre_context, context_line, post_context).
      Severity: Minor
      Found in raven/utils/stacks.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 from_string has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_string(cls, value, transport=None, transport_registry=None):
              # in Python 2.x sending the DSN as a unicode value will eventually
              # cause issues in httplib
              if PY2:
                  value = to_string(value)
      Severity: Minor
      Found in raven/conf/remote.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 build_msg has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def build_msg(self, event_type, data=None, date=None,
      Severity: Major
      Found in raven/base.py - About 1 hr to fix

        Function get_version_from_app has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_version_from_app(module_name, app):
            version = None
        
            # Try to pull version from pkg_resources first
            # as it is able to detect version tagged with egg_info -b
        Severity: Minor
        Found in raven/utils/__init__.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 _record_log_breadcrumb has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def _record_log_breadcrumb(logger, level, msg, *args, **kwargs):
            for handler in special_logging_handlers:
                if handler(logger, level, msg, args, kwargs):
                    return
        
        
        Severity: Minor
        Found in raven/breadcrumbs.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 _install_httplib has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def _install_httplib():
            try:
                from httplib import HTTPConnection
            except ImportError:
                from http.client import HTTPConnection
        Severity: Minor
        Found in raven/breadcrumbs.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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, app=None, client=None, client_cls=Client, dsn=None,
        Severity: Major
        Found in raven/contrib/flask.py - About 1 hr to fix

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

              def __init__(self, dsn=None, raise_send_errors=False, transport=None,
          Severity: Major
          Found in raven/base.py - About 1 hr to fix

            Function capture has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def capture(self, event_type, data=None, date=None, time_spent=None,
            Severity: Major
            Found in raven/base.py - About 1 hr to fix

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

                  def __init__(self, dsn=None, raise_send_errors=False, transport=None,
                               install_sys_hook=True, install_logging_hook=True,
                               hook_libraries=None, enable_breadcrumbs=True,
                               _random_seed=None, **options):
                      global Raven
              Severity: Minor
              Found in raven/base.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

              Severity
              Category
              Status
              Source
              Language