getsentry/raven-python

View on GitHub
raven/contrib/django/client.py

Summary

Maintainability
C
1 day
Test Coverage

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 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 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 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 record_sql has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def record_sql(vendor, alias, start, duration, sql, params):
Severity: Minor
Found in raven/contrib/django/client.py - About 45 mins to fix

    Function record_many_sql has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def record_many_sql(vendor, alias, start, sql, param_list):
    Severity: Minor
    Found in raven/contrib/django/client.py - About 35 mins to fix

      Function get_user_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_user_info(self, request):
      
              user_info = {
                  'ip_address': get_client_ip(request.META),
              }
      Severity: Minor
      Found in raven/contrib/django/client.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

      There are no issues that match your filters.

      Category
      Status