thenetcircle/dino

View on GitHub

Showing 809 of 809 total issues

Function _get_muted_users has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_muted_users(self, all_muted, encode_response: bool = False, session=None):
        output = dict()
        if all_muted is None or len(all_muted) == 0:
            return output

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

    def on_update_user_info(self, activity: Activity) -> (bool, int, str):
        if not hasattr(activity, 'object'):
            return False, ECodes.MISSING_OBJECT, 'no object on activity'
        if not hasattr(activity.object, 'attachments'):
            return False, ECodes.MISSING_OBJECT_ATTACHMENTS, 'no attachments on object'
Severity: Minor
Found in dino/validation/request.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 kick_user has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def kick_user(
            self, room_id: Optional[str], user_id: str, reason: str = None, admin_id: str = None, room_name: str = None
    ) -> None:
        # TODO: support get room_id from room name

Severity: Minor
Found in dino/db/manager/users.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_user_online has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def set_user_online(self, user_id: str, update_last_online: bool = False) -> None:
        @with_session
        def _set_user_online(session=None):
            user_status = session.query(UserStatus).filter(UserStatus.uuid == user_id).first()
            if user_status 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 index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def index():
    form = LoginForm.create()
    form.token.data = str(uuid())
    if form.validate_on_submit():
        # only for the reference implementation, generate a user id and token
Severity: Minor
Found in dino/endpoint/sockets.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 online_counter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def online_counter():
    if len(environ.env.config) == 0 or environ.env.config.get(ConfigKeys.TESTING, False):
        return

    with GracefulInterruptHandler() as interrupt_handler:
Severity: Minor
Found in dino/endpoint/sockets.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 user_is_on_this_node_ignore_rooms has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def user_is_on_this_node_ignore_rooms(self, activity: Activity) -> bool:
        if self.env.node not in {'app', 'wio'}:
            return False

        namespace = activity.target.url or '/ws'
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 _checkUpdatedKeys has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function _checkUpdatedKeys() {
        var oldCrc32List = JSON.parse(JSON.stringify(_storage.__jstorage_meta.CRC32)),
            newCrc32List;

        _reloadData();
Severity: Minor
Found in dino/templates/js/jstorage.js - About 1 hr to fix

    Function _initEvents has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _initEvents: function() {
                var self = this;
    
                // Toggle switch when the switch is clicked
                this.button_bg.click(function(e) {
    Severity: Minor
    Found in dino/admin/static/vendor/jquery.switchButton.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

      if(
      // make the regex if we don't have it already
      e=j([2e3,d]),c&&!this._longMonthsParse[d]&&(this._longMonthsParse[d]=new RegExp("^"+this.months(e,"").replace(".","")+"$","i"),this._shortMonthsParse[d]=new RegExp("^"+this.monthsShort(e,"").replace(".","")+"$","i")),c||this._monthsParse[d]||(f="^"+this.months(e,"")+"|^"+this.monthsShort(e,""),this._monthsParse[d]=new RegExp(f.replace(".",""),"i")),c&&"MMMM"===b&&this._longMonthsParse[d].test(a))return d;if(c&&"MMM"===b&&this._shortMonthsParse[d].test(a))return d;if(!c&&this._monthsParse[d].test(a))return d}}
      Severity: Major
      Found in dino/admin/static/vendor/moment.min.js - About 1 hr to fix

        Function msg_insert has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def msg_insert(self, msg_id, from_user, to_user, body, domain, timestamp, channel_id, deleted=False) -> None:
        Severity: Major
        Found in dino/storage/cassandra_interface.py - About 1 hr to fix

          Function update_spam_config has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def update_spam_config(
          Severity: Major
          Found in dino/db/rdbms/handler.py - About 1 hr to fix

            Function create_room has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def create_room(
            Severity: Major
            Found in dino/db/rdbms/handler.py - About 1 hr to fix

              Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, formdata=None, obj=None, prefix='', csrf_context=None,
              Severity: Major
              Found in dino/forms.py - About 1 hr to fix

                Function ban_user has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def ban_user(
                Severity: Major
                Found in dino/db/manager/users.py - About 1 hr to fix

                  Function validate_acl_for_action has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def validate_acl_for_action(
                  Severity: Major
                  Found in dino/validation/acl.py - About 1 hr to fix

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

                        def __init__(self):
                            super(ClearHistoryResource, self).__init__()
                            self.storage_manager = StorageManager(environ.env)
                            self.request = request
                    Severity: Major
                    Found in dino/rest/resources/clear_history.py and 1 other location - About 1 hr to fix
                    dino/rest/resources/kick.py on lines 19..22

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

                        def __init__(self):
                            super(KickResource, self).__init__()
                            self.user_manager = UserManager(environ.env)
                            self.request = request
                    Severity: Major
                    Found in dino/rest/resources/kick.py and 1 other location - About 1 hr to fix
                    dino/rest/resources/clear_history.py on lines 32..35

                    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

                    Function get_user_info_attachments_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_user_info_attachments_for(user_id: str, encode_attachments: bool=True, include_user_agent: bool=False) -> list:
                        attachments = list()
                        for info_key, info_val in environ.env.auth.get_user_info(user_id).items():
                            attachments.append({
                                'objectType': info_key,
                    Severity: Minor
                    Found in dino/utils/__init__.py - About 55 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

                    Function room_name_restricted has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def room_name_restricted(room_name: str):
                        if room_name.strip().lower() in {'admin', 'admins'}:
                            return True
                    
                        restricted_room_names = environ.env.db.get_black_list()
                    Severity: Minor
                    Found in dino/utils/__init__.py - About 55 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