millerf/django-channels-jsonrpc

View on GitHub

Showing 8 of 32 total issues

File tests.py has 442 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import datetime
from channels_jsonrpc import JsonRpcConsumerTest, JsonRpcException
from channels.tests import ChannelTestCase, HttpClient
from .consumer import MyJsonRpcWebsocketConsumerTest, DjangoJsonRpcWebsocketConsumerTest

Severity: Minor
Found in example/django_example/tests.py - About 6 hrs to fix

    File jsonrpcconsumer.py has 334 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import json
    import logging
    import sys
    
    if sys.version_info < (3, 5):
    Severity: Minor
    Found in channels_jsonrpc/jsonrpcconsumer.py - About 4 hrs to fix

      Function __handle has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def __handle(self, content, message):
              """
              Handle
              :param content:
              :param message:
      Severity: Minor
      Found in channels_jsonrpc/jsonrpcconsumer.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

      TestsJsonRPCWebsocketConsumer has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class TestsJsonRPCWebsocketConsumer(ChannelTestCase):
      
          def test_connection(self):
              # Test connection
              client = HttpClient()
      Severity: Minor
      Found in example/django_example/tests.py - About 3 hrs to fix

        Function http_handler has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def http_handler(self, message):
                """
                Called on HTTP request
                :param message: message received
                :return:
        Severity: Minor
        Found in channels_jsonrpc/jsonrpcconsumer.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 __process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def __process(cls, data, original_msg, is_notification=False):
                """
                Process the recived data
                :param dict data:
                :param channels.message.Message original_msg:
        Severity: Minor
        Found in channels_jsonrpc/jsonrpcconsumer.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 test_group_notifications has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def test_group_notifications(self):
                from channels import Group
        
                @MyJsonRpcWebsocketConsumerTest.rpc_method()
                def add_client_to_group(group_name, **kwargs):
        Severity: Minor
        Found in example/django_example/tests.py - About 1 hr to fix

          Function __get_result has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __get_result(method, params, original_msg):
          
                  func_args = getattr(getfullargspec(method), keywords_args)
          
                  if func_args and "kwargs" in func_args:
          Severity: Minor
          Found in channels_jsonrpc/jsonrpcconsumer.py - About 45 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

          Severity
          Category
          Status
          Source
          Language