getsentry/raven-python

View on GitHub

Showing 146 of 146 total issues

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

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

            try:
                self.client.captureException(exc_info=sys.exc_info(), request=request)
            except Exception as exc:
                try:
                    logger.exception('Unable to process log entry: %s' % (exc,))
    Severity: Major
    Found in raven/contrib/django/models.py and 1 other location - About 1 hr to fix
    raven/contrib/django/models.py on lines 142..148

    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 49.

    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 send_sync(self, url, data, headers, success_cb, failure_cb):
            try:
                super(ThreadedRequestsHTTPTransport, self).send(url, data, headers)
            except Exception as e:
                failure_cb(e)
    Severity: Major
    Found in raven/transport/threaded_requests.py and 1 other location - About 1 hr to fix
    raven/transport/threaded.py on lines 163..169

    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 49.

    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

            try:
                handler_kwargs['formatted'] = text_type(record.message)
            except UnicodeDecodeError:
                # Handle binary strings where it should be unicode...
                handler_kwargs['formatted'] = repr(record.message)[1:-1]
    Severity: Major
    Found in raven/handlers/logging.py and 1 other location - About 1 hr to fix
    raven/handlers/logging.py on lines 154..158

    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 49.

    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 send_sync(self, url, data, headers, success_cb, failure_cb):
            try:
                super(ThreadedHTTPTransport, self).send(url, data, headers)
            except Exception as e:
                failure_cb(e)
    Severity: Major
    Found in raven/transport/threaded.py and 1 other location - About 1 hr to fix
    raven/transport/threaded_requests.py on lines 24..30

    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 49.

    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

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

        try:
            client.captureException(exc_info=sys.exc_info(), request=request)
        except Exception as exc:
            try:
                logger.exception('Unable to process log entry: %s' % (exc,))
    Severity: Major
    Found in raven/contrib/django/models.py and 1 other location - About 1 hr to fix
    raven/contrib/django/models.py on lines 205..211

    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 49.

    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

            try:
                handler_kwargs['message'] = text_type(record.msg)
            except UnicodeDecodeError:
                # Handle binary strings where it should be unicode...
                handler_kwargs['message'] = repr(record.msg)[1:-1]
    Severity: Major
    Found in raven/handlers/logging.py and 1 other location - About 1 hr to fix
    raven/handlers/logging.py on lines 160..164

    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 49.

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

    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

      Severity
      Category
      Status
      Source
      Language