getsentry/raven-python

View on GitHub

Showing 146 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def captureException(self, *args, **kwargs):
              assert self.client, 'captureException called before application configured'
              data = kwargs.get('data')
              if data is None:
                  try:
      Severity: Major
      Found in raven/contrib/bottle/__init__.py and 1 other location - About 3 hrs to fix
      raven/contrib/bottle/__init__.py on lines 83..92

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 70.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def captureMessage(self, *args, **kwargs):
              assert self.client, 'captureMessage called before application configured'
              data = kwargs.get('data')
              if data is None:
                  try:
      Severity: Major
      Found in raven/contrib/bottle/__init__.py and 1 other location - About 3 hrs to fix
      raven/contrib/bottle/__init__.py on lines 72..81

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 70.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def captureMessage(self, *args, **kwargs):
                assert self.client, 'captureMessage called before application configured'
                data = kwargs.get('data')
                if data is None:
                    kwargs['data'] = get_data_from_request()
        Severity: Major
        Found in raven/contrib/webpy/__init__.py and 1 other location - About 2 hrs to fix
        raven/contrib/webpy/__init__.py on lines 64..70

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 60.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def captureException(self, *args, **kwargs):
                assert self.client, 'captureException called before application configured'
                data = kwargs.get('data')
                if data is None:
                    kwargs['data'] = get_data_from_request()
        Severity: Major
        Found in raven/contrib/webpy/__init__.py and 1 other location - About 2 hrs to fix
        raven/contrib/webpy/__init__.py on lines 72..78

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 60.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def captureMessage(self, *args, **kwargs):
                assert self.client, 'captureMessage called before application configured'
                result = self.client.captureMessage(*args, **kwargs)
                if result:
                    self.last_event_id = self.client.get_ident(result)
        Severity: Major
        Found in raven/contrib/flask.py and 1 other location - About 2 hrs to fix
        raven/contrib/flask.py on lines 316..323

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def captureException(self, *args, **kwargs):
                assert self.client, 'captureException called before application configured'
                result = self.client.captureException(*args, **kwargs)
                if result:
                    self.last_event_id = self.client.get_ident(result)
        Severity: Major
        Found in raven/contrib/flask.py and 1 other location - About 2 hrs to fix
        raven/contrib/flask.py on lines 325..332

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            data = {
                'request': {
                    'url': '%s://%s%s' % (urlparts.scheme, urlparts.netloc, urlparts.path),
                    'query_string': urlparts.query,
                    'method': request.method,
        Severity: Major
        Found in raven/contrib/bottle/utils.py and 1 other location - About 2 hrs to fix
        raven/contrib/flask.py on lines 227..233

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 55.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                return {
                    'url': '%s://%s%s' % (urlparts.scheme, urlparts.netloc, urlparts.path),
                    'query_string': urlparts.query,
                    'method': request.method,
                    'data': data,
        Severity: Major
        Found in raven/contrib/flask.py and 1 other location - About 2 hrs to fix
        raven/contrib/bottle/utils.py on lines 28..35

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 55.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language