getsentry/raven-python

View on GitHub

Showing 104 of 146 total issues

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

"""
raven.base
~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
Severity: Major
Found in raven/base.py - About 1 day to fix

    Function emit has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

        def emit(self, record):
            if record.levelno <= logging.ERROR and self.can_record(record):
                request = None
                exc_info = None
                for frame_info in getouterframes(currentframe()):
    Severity: Minor
    Found in raven/contrib/zope/__init__.py - About 7 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 build_msg has a Cognitive Complexity of 43 (exceeds 5 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 6 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

    Client has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Client(object):
        """
        The base Raven client.
    
        Will read default configuration from the environment variable
    Severity: Minor
    Found in raven/base.py - About 5 hrs to fix

      Function fetch_git_sha has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      def fetch_git_sha(path, head=None):
          """
          >>> fetch_git_sha(os.path.dirname(__file__))
          """
          if not head:
      Severity: Minor
      Found in raven/versioning.py - About 4 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_stack_info has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_stack_info(frames, transformer=transform, capture_locals=True,
                         frame_allowance=25):
          """
          Given a list of frames, returns a list of stack information
          dictionary objects that are JSON-ready.
      Severity: Minor
      Found in raven/utils/stacks.py - About 3 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 update_data_from_request has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_data_from_request(self, request, result):
              if result.get('user') is None:
                  result['user'] = self.get_user_info(request)
      
              try:
      Severity: Minor
      Found in raven/contrib/django/client.py - About 3 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 match_hostname has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      def match_hostname(cert, hostname):
          """Verify that *cert* (in decoded format as returned by
          SSLSocket.getpeercert()) matches the *hostname*.  RFC 2818 and RFC 6125
          rules are followed, but IP addresses are not accepted for *hostname*.
      
      
      Severity: Minor
      Found in raven/utils/ssl_match_hostname.py - About 3 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

      File breadcrumbs.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from __future__ import absolute_import
      
      import os
      import logging
      
      
      Severity: Minor
      Found in raven/breadcrumbs.py - About 3 hrs to fix

        Function get_data_from_template has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_data_from_template(source, debug=None):
            def _remove_numbers(items):
                rv = []
                for item in items:
                    # Some debug info from django has tuples in the form (lineno,
        Severity: Minor
        Found in raven/contrib/django/utils.py - About 3 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 force_text has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def force_text(s, encoding='utf-8', strings_only=False, errors='strict'):
            """
            Similar to smart_text, except that lazy instances are resolved to
            strings, rather than kept as lazy objects.
        
        
        Severity: Minor
        Found in raven/utils/encoding.py - About 3 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 init_app has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def init_app(self, app, dsn=None, logging=None, level=None,
                         logging_exclusions=None, wrap_wsgi=None,
                         register_signal=None):
                if dsn is not None:
                    self.dsn = dsn
        Severity: Minor
        Found in raven/contrib/flask.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_versions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_versions(module_list=None):
            if not module_list:
                return {}
        
            ext_module_list = set()
        Severity: Minor
        Found in raven/utils/__init__.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

        File flask.py has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        raven.contrib.flask
        ~~~~~~~~~~~~~~~~~~~
        
        :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
        Severity: Minor
        Found in raven/contrib/flask.py - About 2 hrs to fix

          Function filter_http has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def filter_http(self, data):
                  for n in ('data', 'cookies', 'headers', 'env', 'query_string'):
                      if n not in data:
                          continue
          
          
          Severity: Minor
          Found in raven/processors.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 format_sql has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def format_sql(sql, params):
              rv = []
          
              if isinstance(params, dict):
                  conv = _FormatConverter(params)
          Severity: Minor
          Found in raven/contrib/django/client.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_buffer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_buffer(self):
                  rv = []
                  for idx, (payload, processor) in enumerate(self.buffer):
                      if processor is not None:
                          try:
          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 slim_frame_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          def slim_frame_data(frames, frame_allowance=25):
              """
              Removes various excess metadata from middle frames which go beyond
              ``frame_allowance``.
          
          
          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 _resolve has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def _resolve(self, resolver, path, parents=None):
          
                  match = get_regex(resolver).search(path)  # Django < 2.0
          
                  if not match:
          Severity: Minor
          Found in raven/contrib/django/resolver.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 capture has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def capture(self, event_type, request=None, **kwargs):
                  if kwargs.get('data') is None:
                      kwargs['data'] = data = {}
                  else:
                      data = kwargs['data']
          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

          Severity
          Category
          Status
          Source
          Language