thenetcircle/dino

View on GitHub

Showing 480 of 808 total issues

File sockets.py has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import time
import traceback
import logging
import sys
import eventlet
Severity: Minor
Found in dino/endpoint/sockets.py - About 3 hrs to fix

    Function get_acl_config has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_acl_config() -> Union[MappingProxyType, dict]:
        acl_paths = None
        if 'DINO_ACL' in os.environ:
            acl_paths = [os.environ['DINO_ACL']]
    
    
    Severity: Minor
    Found in dino/environ.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

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

    class Driver(object):
        def __init__(self, session: Session, key_space: str, strategy: str, replications: int):
            self.session: Session = session
            self.statements = dict()
            self.key_space = key_space
    Severity: Minor
    Found in dino/storage/cassandra_driver.py - About 3 hrs to fix

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

      class UserManager(BaseManager):
          def __init__(self, env: GNEnvironment):
              self.env = env
      
          def auth_user(self, user_id, _):
      Severity: Minor
      Found in dino/db/manager/users.py - About 3 hrs to fix

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

        class QueueHandler(object):
            def __init__(self, socketio, env: GNEnvironment):
                self.socketio = socketio
                self.env = env
                self.recently_delegated_events = list()
        Severity: Minor
        Found in dino/endpoint/queue.py - About 3 hrs to fix

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

          def activity_for_users_in_room(activity: Activity, users_orig: dict) -> dict:
              users = users_orig.copy()
              response = ActivityBuilder.enrich({
                  'target': {
                      'id': activity.target.id,
          Severity: Minor
          Found in dino/utils/__init__.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

          CassandraStorage has 26 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class CassandraStorage(object):
              driver = None
              session = None
          
              def __init__(self, hosts: list, replications=None, strategy=None, protocol_version: int = 4, key_space='dino'):
          Severity: Minor
          Found in dino/storage/cassandra.py - About 3 hrs to fix

            Consider simplifying this complex logical expression.
            Open

            function hb(a){var b,c,d,e,f=[];if(!a._d){
            // Default to current date.
            // * if no year, month, day of month are given, default to today
            // * if day of month is given, default month and year
            // * if month is given, default only year
            Severity: Critical
            Found in dino/admin/static/vendor/moment.min.js - About 3 hrs to fix

              Function _do_get has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _do_get(self, user_id):
                      # always get from redis here, since the user is not logged in
                      session = self.env.auth.get_user_info(user_id)
              
                      channels = self.env.db.get_channels()
              Severity: Minor
              Found in dino/rest/resources/rooms_acl.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 create_env has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

              def create_env(config_paths: list = None) -> GNEnvironment:
                  logging.basicConfig(level='DEBUG', format=ConfigKeys.DEFAULT_LOG_FORMAT)
              
                  gn_environment = os.getenv(ENV_KEY_ENVIRONMENT)
                  logger.info('using environment %s' % gn_environment)
              Severity: Minor
              Found in dino/environ.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 check_acl_actions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_acl_actions(check_acls: list, actions: dict, available_acls: list) -> None:
                      for acl_target, acls in check_acls:
                          if acls is None or len(acls) == 0:
                              continue
              
              
              Severity: Minor
              Found in dino/validation/acl.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 leave_room has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  def leave_room(arg: tuple) -> None:
                      data, activity = arg
              
                      user_id = activity.actor.id
                      room_id = activity.target.id
              Severity: Minor
              Found in dino/hooks/leave.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 on_message has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              def on_message(data, activity: Activity):
                  """
                  send any kind of message/event to a target user/room
              
                  object.url: target channel_id
              Severity: Minor
              Found in dino/api.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 respond_with has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              def respond_with(gn_event_name=None, should_disconnect=False, use_callback=True):
                  def factory(view_func):
                      @wraps(view_func)
                      def decorator(*args, **kwargs):
                          tb = None
              Severity: Minor
              Found in dino/utils/decorators.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

              File index.js has 278 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              
              function checkLength(o, n, min, max, tipsFunc) {
                  if (o.val().length > max || o.val().length < min) {
                      o.addClass('ui-state-error');
                      tipsFunc('Length of ' + n + ' must be between ' + min + ' and ' + max + '.');
              Severity: Minor
              Found in dino/admin/static/custom/js/index.js - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],meridiem:null}}function l(a){return null==a._pf&&(a._pf=k()),a._pf}function m(a){if(null==a._isValid){var b=l(a),c=nd.call(b.parsedDateParts,function(a){return null!=a}),d=!isNaN(a._d.getTime())&&b.overflow<0&&!b.empty&&!b.invalidMonth&&!b.invalidWeekday&&!b.nullInput&&!b.invalidFormat&&!b.userInvalidated&&(!b.meridiem||b.meridiem&&c);if(a._strict&&(d=d&&0===b.charsLeftOver&&0===b.unusedTokens.length&&void 0===b.bigHour),null!=Object.isFrozen&&Object.isFrozen(a))return d;a._isValid=d}return a._isValid}function n(a){var b=j(NaN);return null!=a?i(l(b),a):l(b).userInvalidated=!0,b}function o(a){return void 0===a}function p(a,b){var c,d,e;if(o(b._isAMomentObject)||(a._isAMomentObject=b._isAMomentObject),o(b._i)||(a._i=b._i),o(b._f)||(a._f=b._f),o(b._l)||(a._l=b._l),o(b._strict)||(a._strict=b._strict),o(b._tzm)||(a._tzm=b._tzm),o(b._isUTC)||(a._isUTC=b._isUTC),o(b._offset)||(a._offset=b._offset),o(b._pf)||(a._pf=l(b)),o(b._locale)||(a._locale=b._locale),od.length>0)for(c in od)d=od[c],e=b[d],o(e)||(a[d]=e);return a}
                Severity: Critical
                Found in dino/admin/static/vendor/moment.min.js - About 2 hrs to fix

                  Function str has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function str(key, holder) {
                  
                  // Produce a string from holder[key].
                  
                          var i,          // The loop counter.
                  Severity: Major
                  Found in dino/templates/js/json2.js - About 2 hrs to fix

                    Function _init has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function _init() {
                            /* Check if browser supports localStorage */
                            var localStorageReallyWorks = false;
                            if ('localStorage' in window) {
                                try {
                    Severity: Major
                    Found in dino/templates/js/jstorage.js - About 2 hrs to fix

                      Function msgs_delete has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def msgs_delete(self, message_ids: list, clear_body=True) -> None:
                              to_update = list()
                      
                              for message_id in message_ids:
                                  keys = self._execute(StatementKeys.msg_select, message_id)
                      Severity: Minor
                      Found in dino/storage/cassandra_driver.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

                      File kafka_to_rabbitmq.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import json
                      import logging
                      import os
                      import time
                      import traceback
                      Severity: Minor
                      Found in bin/kafka_to_rabbitmq.py - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language