millerf/django-channels-jsonrpc

View on GitHub

Showing 32 of 32 total issues

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

    @classmethod
    def rpc_method(cls, rpc_name=None, websocket=True, http=True):
        """
        Decorator to list RPC methodds available. An optional name and protocol rectrictions can be added
        :param rpc_name: RPC name for the function
Severity: Major
Found in channels_jsonrpc/jsonrpcconsumer.py and 1 other location - About 7 hrs to fix
channels_jsonrpc/jsonrpcconsumer.py on lines 141..160

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

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

    @classmethod
    def rpc_notification(cls, rpc_name=None, websocket=True, http=True):
        """
        Decorator to list RPC notifications available. An optional name can be added
        :param rpc_name: RPC name for the function
Severity: Major
Found in channels_jsonrpc/jsonrpcconsumer.py and 1 other location - About 7 hrs to fix
channels_jsonrpc/jsonrpcconsumer.py on lines 109..129

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

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

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

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

            def thread_test():
                for _i in range(0, 10000):
                    _message = SpoofMessage()
                    _message.channel.name = "websocket.test"
                    _message.payload = "test%s" % _i
    Severity: Major
    Found in example/django_example/tests.py and 1 other location - About 4 hrs to fix
    example/django_example/tests.py on lines 413..419

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

    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

            for i in range(0, 10000):
                _message = SpoofMessage()
                _message.channel.name = "websocket.test"
                _message.payload = "test%s" % i
                res = MyJsonRpcWebsocketConsumerTest._JsonRpcConsumer__process(
    Severity: Major
    Found in example/django_example/tests.py and 1 other location - About 4 hrs to fix
    example/django_example/tests.py on lines 401..408

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

    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

    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

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

            @classmethod
            def get_rpc_methods(cls):
                """
                Returns the RPC methods available for this consumer
                :return: list
        Severity: Major
        Found in channels_jsonrpc/jsonrpcconsumer.py and 1 other location - About 2 hrs to fix
        channels_jsonrpc/jsonrpcconsumer.py on lines 162..170

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

        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

            @classmethod
            def get_rpc_notifications(cls):
                """
                Returns the RPC methods available for this consumer
                :return: list
        Severity: Major
        Found in channels_jsonrpc/jsonrpcconsumer.py and 1 other location - About 2 hrs to fix
        channels_jsonrpc/jsonrpcconsumer.py on lines 131..139

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

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

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

            def test_id_on_errored_request(self):
                # Test that parsing a ping request works
                client = HttpClient()
        
                client.send_and_consume(u'websocket.receive',
        Severity: Major
        Found in example/django_example/tests.py and 1 other location - About 2 hrs to fix
        example/django_example/tests.py on lines 173..180

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

        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 test_id_on_good_request(self):
                # Test that parsing a ping request works
                client = HttpClient()
        
                client.send_and_consume(u'websocket.receive',
        Severity: Major
        Found in example/django_example/tests.py and 1 other location - About 2 hrs to fix
        example/django_example/tests.py on lines 182..189

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

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

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

                  self.assertEqual(client.receive()['error'],
                                   {u'code': JsonRpcConsumerTest.INVALID_REQUEST,
                                   u'message': JsonRpcConsumerTest.errors[JsonRpcConsumerTest.INVALID_REQUEST]})
          Severity: Major
          Found in example/django_example/tests.py and 10 other locations - About 1 hr to fix
          example/django_example/tests.py on lines 41..43
          example/django_example/tests.py on lines 46..48
          example/django_example/tests.py on lines 51..53
          example/django_example/tests.py on lines 63..65
          example/django_example/tests.py on lines 69..71
          example/django_example/tests.py on lines 74..76
          example/django_example/tests.py on lines 79..81
          example/django_example/tests.py on lines 84..86
          example/django_example/tests.py on lines 89..91
          example/django_example/tests.py on lines 109..111

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

          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 11 locations. Consider refactoring.
          Open

                  self.assertEqual(client.receive()['error'],
                                   {u'code': JsonRpcConsumerTest.INVALID_REQUEST,
                                   u'message': JsonRpcConsumerTest.errors[JsonRpcConsumerTest.INVALID_REQUEST]})
          Severity: Major
          Found in example/django_example/tests.py and 10 other locations - About 1 hr to fix
          example/django_example/tests.py on lines 41..43
          example/django_example/tests.py on lines 46..48
          example/django_example/tests.py on lines 51..53
          example/django_example/tests.py on lines 57..59
          example/django_example/tests.py on lines 63..65
          example/django_example/tests.py on lines 69..71
          example/django_example/tests.py on lines 74..76
          example/django_example/tests.py on lines 79..81
          example/django_example/tests.py on lines 89..91
          example/django_example/tests.py on lines 109..111

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

          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 11 locations. Consider refactoring.
          Open

                  self.assertEqual(client.receive()['error'], {u'code': JsonRpcConsumerTest.METHOD_NOT_FOUND,
                                                               u'message': JsonRpcConsumerTest.errors[
                                                                   JsonRpcConsumerTest.METHOD_NOT_FOUND]})
          Severity: Major
          Found in example/django_example/tests.py and 10 other locations - About 1 hr to fix
          example/django_example/tests.py on lines 41..43
          example/django_example/tests.py on lines 46..48
          example/django_example/tests.py on lines 51..53
          example/django_example/tests.py on lines 57..59
          example/django_example/tests.py on lines 63..65
          example/django_example/tests.py on lines 74..76
          example/django_example/tests.py on lines 79..81
          example/django_example/tests.py on lines 84..86
          example/django_example/tests.py on lines 89..91
          example/django_example/tests.py on lines 109..111

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

          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 11 locations. Consider refactoring.
          Open

                  self.assertEqual(client.receive()['error'], {u'code': JsonRpcConsumerTest.INVALID_REQUEST,
                                                               u'message': JsonRpcConsumerTest.errors[
                                                                   JsonRpcConsumerTest.INVALID_REQUEST]})
          Severity: Major
          Found in example/django_example/tests.py and 10 other locations - About 1 hr to fix
          example/django_example/tests.py on lines 41..43
          example/django_example/tests.py on lines 46..48
          example/django_example/tests.py on lines 51..53
          example/django_example/tests.py on lines 57..59
          example/django_example/tests.py on lines 63..65
          example/django_example/tests.py on lines 69..71
          example/django_example/tests.py on lines 79..81
          example/django_example/tests.py on lines 84..86
          example/django_example/tests.py on lines 89..91
          example/django_example/tests.py on lines 109..111

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

          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 11 locations. Consider refactoring.
          Open

                  self.assertEqual(client.receive()['error'],
                                   {u'code': JsonRpcConsumerTest.INVALID_REQUEST,
                                   u'message': JsonRpcConsumerTest.errors[JsonRpcConsumerTest.INVALID_REQUEST]})
          Severity: Major
          Found in example/django_example/tests.py and 10 other locations - About 1 hr to fix
          example/django_example/tests.py on lines 41..43
          example/django_example/tests.py on lines 46..48
          example/django_example/tests.py on lines 51..53
          example/django_example/tests.py on lines 57..59
          example/django_example/tests.py on lines 63..65
          example/django_example/tests.py on lines 69..71
          example/django_example/tests.py on lines 74..76
          example/django_example/tests.py on lines 79..81
          example/django_example/tests.py on lines 84..86
          example/django_example/tests.py on lines 109..111

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

          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

          Severity
          Category
          Status
          Source
          Language