getsentry/raven-python

View on GitHub
raven/base.py

Summary

Maintainability
F
4 days
Test Coverage

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

                Function capture has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def capture(self, event_type, data=None, date=None, time_spent=None,
                                extra=None, stack=None, tags=None, sample_rate=None,
                                **kwargs):
                        """
                        Captures and processes an event and pipes it off to SentryClient.send.
                Severity: Minor
                Found in raven/base.py - About 35 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 set_dsn has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def set_dsn(self, dsn=None, transport=None):
                        if not dsn and os.environ.get('SENTRY_DSN'):
                            msg = "Configuring Raven from environment variable 'SENTRY_DSN'"
                            self.logger.debug(msg)
                            dsn = os.environ['SENTRY_DSN']
                Severity: Minor
                Found in raven/base.py - About 35 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 send_remote has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def send_remote(self, url, data, headers=None):
                        # If the client is configured to raise errors on sending,
                        # the implication is that the backoff and retry strategies
                        # will be handled by the calling application
                        if headers is None:
                Severity: Minor
                Found in raven/base.py - About 35 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 _format_repos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _format_repos(self, value):
                        result = {}
                        if value:
                            for path, config in iteritems(value):
                                if path[0] != '/':
                Severity: Minor
                Found in raven/base.py - About 25 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 _iter_frames has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _iter_frames(self, data):
                        if 'stacktrace' in data:
                            for frame in data['stacktrace']['frames']:
                                yield frame
                        if 'exception' in data:
                Severity: Minor
                Found in raven/base.py - About 25 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

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

                    def __init__(self):
                        self.status = self.ONLINE
                        self.last_check = None
                        self.retry_number = 0
                        self.retry_after = 0
                Severity: Minor
                Found in raven/base.py and 1 other location - About 50 mins to fix
                raven/base.py on lines 112..116

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

                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 set_success(self):
                        self.status = self.ONLINE
                        self.last_check = None
                        self.retry_number = 0
                        self.retry_after = 0
                Severity: Minor
                Found in raven/base.py and 1 other location - About 50 mins to fix
                raven/base.py on lines 89..93

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

                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

                            for frame in data['exception']['values'][-1]['stacktrace'].get('frames', []):
                Severity: Minor
                Found in raven/base.py and 1 other location - About 30 mins to fix
                raven/base.py on lines 671..671

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

                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

                            for frame in data['exception']['values'][-1]['stacktrace'].get('frames', []):
                Severity: Minor
                Found in raven/base.py and 1 other location - About 30 mins to fix
                raven/base.py on lines 705..705

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

                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

                There are no issues that match your filters.

                Category
                Status