thenetcircle/dino

View on GitHub

Showing 808 of 808 total issues

File handler.py has 2967 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in dino/db/rdbms/handler.py - About 1 wk to fix

    DatabaseRdbms has 192 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseRdbms(object):
        def __init__(self, env: GNEnvironment):
            self.env = env
            if self.env.config.get(ConfigKeys.TESTING, False):
                DatabaseRdbms.db = MockDatabase()
    Severity: Major
    Found in dino/db/rdbms/handler.py - About 3 days to fix

      File __init__.py has 1432 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import ast
      import logging
      import os
      import re
      import sys
      Severity: Major
      Found in dino/utils/__init__.py - About 3 days to fix

        DatabaseRedis has 183 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class DatabaseRedis(object):
            redis = None
        
            def __init__(self, env: GNEnvironment, host: str, port: int = 6379, db: int = 0):
                if environ.env.config.get(ConfigKeys.TESTING, False) or host == 'mock':
        Severity: Major
        Found in dino/db/redis.py - About 3 days to fix

          IDatabase has 164 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class IDatabase(Interface):
              def init_config(self) -> None:
                  """
                  initialize the config table
          
          
          Severity: Major
          Found in dino/db/__init__.py - About 3 days to fix

            File __init__.py has 1235 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/env python
            
            # Licensed under the Apache License, Version 2.0 (the "License");
            # you may not use this file except in compliance with the License.
            # You may obtain a copy of the License at
            Severity: Major
            Found in dino/db/__init__.py - About 3 days to fix

              File redis.py has 1164 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import json
              import logging
              import traceback
              import random
              import sys
              Severity: Major
              Found in dino/cache/redis.py - About 2 days to fix

                CacheRedis has 143 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class CacheRedis(object):
                    def __init__(self, env, host: str, port: int = 6379, db: int = 0):
                        if env.config.get(ConfigKeys.TESTING, False) or host == 'mock':
                            from fakeredis import FakeStrictRedis
                
                
                Severity: Major
                Found in dino/cache/redis.py - About 2 days to fix

                  File redis.py has 1093 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #!/usr/bin/env python
                  
                  # Licensed under the Apache License, Version 2.0 (the "License");
                  # you may not use this file except in compliance with the License.
                  # You may obtain a copy of the License at
                  Severity: Major
                  Found in dino/db/redis.py - About 2 days to fix

                    File routes.py has 1024 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import logging
                    import os
                    import sys
                    import traceback
                    from functools import wraps
                    Severity: Major
                    Found in dino/admin/routes.py - About 2 days to fix

                      ICache has 129 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class ICache(Interface):
                          def get_user_for_sid(self, sid: str):
                              """
                              get the user id for a sid
                      
                      
                      Severity: Major
                      Found in dino/cache/__init__.py - About 2 days to fix

                        File environ.py has 858 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        # Licensed under the Apache License, Version 2.0 (the "License");
                        # you may not use this file except in compliance with the License.
                        # You may obtain a copy of the License at
                        #
                        # http://www.apache.org/licenses/LICENSE-2.0
                        Severity: Major
                        Found in dino/environ.py - About 2 days to fix

                          File __init__.py has 823 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          from typing import Set
                          
                          from zope.interface import Interface
                          from typing import Union, Dict, List, Optional
                          
                          
                          Severity: Major
                          Found in dino/cache/__init__.py - About 1 day to fix

                            Function handle_disconnect has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def handle_disconnect(arg: tuple, is_socket_disconnect: bool=False) -> None:
                                    """
                                    when a client disconnects this hook will handle the related logic
                            
                                    :param arg: tuple of (data, parsed_activity)
                            Severity: Minor
                            Found in dino/hooks/disconnect.py - About 1 day 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 do_process has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def do_process(arg: tuple) -> None:
                                    def send(_data: dict, _room: str, _json: bool=True, _broadcast: bool=True) -> None:
                                        environ.env.emit('message', _data, json=_json, room=_room, broadcast=_broadcast)
                            
                                    def publish_activity() -> None:
                            Severity: Minor
                            Found in dino/hooks/message.py - About 1 day 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 pre_process has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def pre_process(validation_name, should_validate_request=True):
                                def factory(view_func):
                                    @wraps(view_func)
                                    def decorator(*a, **k):
                                        def _pre_process(*args, **kwargs):
                            Severity: Minor
                            Found in dino/utils/decorators.py - About 1 day 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_message has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def on_message(self, activity: Activity) -> (bool, int, str):
                                    room_id = activity.target.id
                                    user_id = activity.actor.id
                                    object_type = activity.target.object_type
                                    message = activity.object.content
                            Severity: Minor
                            Found in dino/validation/request.py - About 1 day 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

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

                                elif message_queue_type == 'amqp':
                                    message_channel = 'dino_%s' % environ.env.config.get(ConfigKeys.ENVIRONMENT, default='test')
                                    message_queue = ';'.join(['amqp://%s:%s@%s:%s%s' % (
                                        environ.env.config.get(ConfigKeys.USER, domain=ConfigKeys.COORDINATOR, default=''),
                                        environ.env.config.get(ConfigKeys.PASSWORD, domain=ConfigKeys.COORDINATOR, default=''),
                            Severity: Major
                            Found in dino/server.py and 1 other location - About 1 day to fix
                            dino/restful.py on lines 61..69

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

                            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

                                elif message_queue_type == 'amqp':
                                    message_channel = 'dino_%s' % environ.env.config.get(ConfigKeys.ENVIRONMENT, default='test')
                                    message_queue = ';'.join(['amqp://%s:%s@%s:%s%s' % (
                                        environ.env.config.get(ConfigKeys.USER, domain=ConfigKeys.COORDINATOR, default=''),
                                        environ.env.config.get(ConfigKeys.PASSWORD, domain=ConfigKeys.COORDINATOR, default=''),
                            Severity: Major
                            Found in dino/restful.py and 1 other location - About 1 day to fix
                            dino/server.py on lines 59..67

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

                            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 request.py has 592 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import sys
                            from activitystreams.models.activity import Activity
                            from activitystreams.models.defobject import DefObject
                            from activitystreams.models.actor import Actor
                            from activitystreams.models.target import Target
                            Severity: Major
                            Found in dino/validation/request.py - About 1 day to fix
                              Severity
                              Category
                              Status
                              Source
                              Language