thenetcircle/dino

View on GitHub

Showing 809 of 809 total issues

Function _toggleSwitch has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _toggleSwitch: function(isInitializing) {
            // Don't toggle the switch if it is set to readonly or disabled, unless it is initializing and animating itself
            if( !isInitializing && (this.element.attr('readonly') == 'readonly' || this.element.prop('disabled')) )
                    return;

Severity: Minor
Found in dino/admin/static/vendor/jquery.switchButton.js - About 1 hr to fix

    Function can_send_cross_room has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def can_send_cross_room(activity: Activity, from_room_uuid: str, to_room_uuid: str) -> bool:
        if from_room_uuid is None:
            raise NoOriginRoomException()
        if to_room_uuid is None:
            raise NoTargetRoomException()
    Severity: Minor
    Found in dino/utils/__init__.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 set_online has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_online(user_id: str, user_name: str, image: str = '') -> None:
            was_invisible = utils.user_is_invisible(user_id)
            OnStatusHooks.logger.info('setting user {} ({}) online (was invisible before? {})'.format(
                user_id, user_name, was_invisible
            ))
    Severity: Minor
    Found in dino/hooks/status.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 _get_rooms_for_channel_with_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_rooms_for_channel_with_info(self, channel_id: str) -> dict:
            """
            rooms_with_n_users[room_id] = {
                'name': all_rooms[room_id]['name'],
                'sort_order': all_rooms[room_id]['sort_order'],
    Severity: Minor
    Found in dino/cache/redis.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 _set_role_on_channel_for_user has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set_role_on_channel_for_user(self, the_role: str, channel_id: str, user_id: str) -> None:
            @with_session
            def _set(session=None):
                channel = session.query(Channels).outerjoin(Channels.roles).filter(Channels.uuid == channel_id).first()
                if channel is None:
    Severity: Minor
    Found in dino/db/rdbms/handler.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 get_user_mute_status has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_user_mute_status(self, room_id: str, user_id: str) -> dict:
            def _has_passed(the_time):
                now = datetime.utcnow()
                return now > datetime.fromtimestamp(int(float(the_time)))
    
    
    Severity: Minor
    Found in dino/db/rdbms/handler.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 reset_sids_for_user has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def reset_sids_for_user(self, user_id: str) -> None:
            @with_session
            def update_sid(session=None):
                user_sids = session.query(Sids)\
                    .filter(Sids.user_uuid == user_id)\
    Severity: Minor
    Found in dino/db/rdbms/handler.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 _validate_params has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _validate_params(self):
            is_valid, msg, json = self.validate_json(self.request, silent=False)
            if not is_valid:
                raise RuntimeError('invalid json: %s' % msg)
    
    
    Severity: Minor
    Found in dino/rest/resources/ban.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

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

                    acl_manager.update_room_acl(channel_id, room_id, ApiActions.AUTOJOIN, args[1][0], args[1][1][j])
    Severity: Major
    Found in bin/create_broadcast_groups.py and 2 other locations - About 1 hr to fix
    bin/create_broadcast_groups.py on lines 66..66
    bin/create_broadcast_groups.py on lines 68..68

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

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

                    acl_manager.update_room_acl(channel_id, room_id, ApiActions.AUTOJOIN, args[0][0], args[0][1][k])
    Severity: Major
    Found in bin/create_broadcast_groups.py and 2 other locations - About 1 hr to fix
    bin/create_broadcast_groups.py on lines 67..67
    bin/create_broadcast_groups.py on lines 68..68

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

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

                    acl_manager.update_room_acl(channel_id, room_id, ApiActions.AUTOJOIN, args[2][0], args[2][1][i])
    Severity: Major
    Found in bin/create_broadcast_groups.py and 2 other locations - About 1 hr to fix
    bin/create_broadcast_groups.py on lines 66..66
    bin/create_broadcast_groups.py on lines 67..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 45.

    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 handle_kick has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_kick(self, activity: Activity):
            kicker_id = activity.actor.id
            if kicker_id == '0':
                kicker_name = 'admin'
            else:
    Severity: Minor
    Found in dino/endpoint/queue.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 handle_local_node_events has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_local_node_events(self, data: dict, activity: Activity):
            # do this first, since ban might occur even if user is not connected
            if activity.verb == 'ban':
                user_is_on_node = True
    
    
    Severity: Minor
    Found in dino/endpoint/queue.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 is_multiple_sessions_allowed has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def is_multiple_sessions_allowed():
        valid_conf = environ.env.config.get(ConfigKeys.VALIDATION)
    
        if valid_conf is None:
            return True
    Severity: Minor
    Found in dino/utils/__init__.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 timeit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def timeit(_logger, tag: str):
        def factory(view_func):
            @wraps(view_func)
            def decorator(*args, **kwargs):
                failed = False
    Severity: Minor
    Found in dino/utils/decorators.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 can_send_whisper_to has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def can_send_whisper_to(self, sender_id: str, target_user_name: str) -> (bool, int):
            url = "{}/{}".format(self.host, self.path_whisper)
    
            # might not be an int in some applications
            try:
    Severity: Minor
    Found in dino/remote/handler.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 can_use_room_name has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def can_use_room_name():
        def factory(view_func):
            @wraps(view_func)
            def decorator(*args, **kwargs):
                def add_target_id_if_missing(data):
    Severity: Minor
    Found in dino/utils/decorators.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 remove_channel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def remove_channel(self, channel_id: str) -> None:
            @with_session
            def get_all_rooms(session=None):
                rooms = session.query(Rooms)\
                    .join(Rooms.channel)\
    Severity: Minor
    Found in dino/db/rdbms/handler.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 _remove_role_on_room_for_user has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _remove_role_on_room_for_user(self, the_role: str, room_id: str, user_id: str) -> None:
            @with_session
            def _remove(session=None):
                room = session.query(Rooms).outerjoin(Rooms.roles).filter(Rooms.uuid == room_id).first()
                if room is None:
    Severity: Minor
    Found in dino/db/rdbms/handler.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 check_acl_rules has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_acl_rules(acls: dict, all_actions: dict, rules: list) -> None:
            for target, actions in acls.items():
                if target not in all_actions:
                    continue
    
    
    Severity: Minor
    Found in dino/validation/acl.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

    Severity
    Category
    Status
    Source
    Language