Net-ng/kansha

View on GitHub
kansha/app/comp.py

Summary

Maintainability
C
1 day
Test Coverage

File comp.py has 356 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding:utf-8 -*-
# --
# Copyright (c) 2012-2014 Net-ng.
# All rights reserved.
#
Severity: Minor
Found in kansha/app/comp.py - About 4 hrs to fix

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

        def send_notifications(self, hours, url):
    
            mail_sender = self._services['mail_sender']
            # Group users by board
            boards = {}
    Severity: Minor
    Found in kansha/app/comp.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 on_exception has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_exception(self, request, response):
            exc_class, e = sys.exc_info()[:2]
            for k, v in request.POST.items():
                if isinstance(v, cgi.FieldStorage):
                    request.POST[k] = u'Content not displayed'
    Severity: Minor
    Found in kansha/app/comp.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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, app_title, app_banner, favicon, theme,
    Severity: Minor
    Found in kansha/app/comp.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              with h.tr:
                                  h << h.td(usr.username)
                                  h << h.td(usr.fullname)
                                  h << h.td(usr.email)
                                  h << h.td(usr.registration_date.isoformat())
      Severity: Major
      Found in kansha/app/comp.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if event.card:
                                    # IDs are interpreted as anchors since HTML4. So don't use the ID of
                                    # the card as a URL fragment, because the browser
                                    # jumps to it.
                                    ev_url = urlparse.urljoin(url, event.board.url)
        Severity: Major
        Found in kansha/app/comp.py - About 45 mins to fix

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

              def __init__(self, app_title, theme, config, card_extensions, services_service):
          Severity: Minor
          Found in kansha/app/comp.py - About 35 mins to fix

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

                def __call__(self, environ, start_response):
                    query = environ['QUERY_STRING']
                    if ('state=' in query) and (('code=' in query) or ('error=' in query)):
                        request = webob.Request(environ)
                        environ['QUERY_STRING'] += ('&' + request.params['state'])
            Severity: Minor
            Found in kansha/app/comp.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

            There are no issues that match your filters.

            Category
            Status