thenetcircle/dino

View on GitHub

Showing 809 of 809 total issues

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

    def remove_sid_for_user(self, user_id: str, sid: str) -> None:
        def _try_to_remove_sid(sid_to_remove):
            sid_key = RedisKeys.user_id_for_sid()
            self.redis.hdel(sid_key, sid_to_remove)

Severity: Minor
Found in dino/cache/redis.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 create_ban_even_if_not_on_this_node has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def create_ban_even_if_not_on_this_node(self, activity: Activity) -> None:
        """
        since bans can be created through the rest api we need to create the ban even though the user might not be on
        this node, since one reason could be that he's not even connected. So make sure the ban is created first.
        """
Severity: Minor
Found in dino/endpoint/queue.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 connections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def connections():
    c = statsd.StatsClient(STATSD_HOST, 8125, prefix=PREFIX + 'system.network')
    to_check = [
        ('conn_established', 'count_established_conn.sh'),
        ('pkts_collapsed', 'count_pkts_collapsed.sh'),
Severity: Minor
Found in bin/statsd-agent.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 ban_globally has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def ban_globally(self, data: dict, act: Activity, rooms: dict, user_id: str, user_sids: list, namespace: str) -> None:
        try:
            message_ids = self.env.storage.get_undeleted_message_ids_for_user(user_id)
            for message_id in message_ids:
                self.env.storage.delete_message(message_id, clear_body=False)
Severity: Minor
Found in dino/endpoint/queue.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 mute_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def mute_user(self, room_id, user_id, mute_duration, mute_timestamp, room_name, muter_id, reason) -> None:
Severity: Major
Found in dino/db/redis.py - About 50 mins to fix

    Function activity_for_whisper has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def activity_for_whisper(
    Severity: Major
    Found in dino/utils/__init__.py - About 50 mins to fix

      Function activity_for_user_kicked has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def activity_for_user_kicked(
      Severity: Major
      Found in dino/utils/__init__.py - About 50 mins to fix

        Function ra has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function oa(a){return pa(a)?366:365}function pa(a){return a%4===0&&a%100!==0||a%400===0}function qa(){return pa(this.year())}function ra(a,b,c,d,e,f,g){
        Severity: Major
        Found in dino/admin/static/vendor/moment.min.js - About 50 mins to fix

          Function activity_for_user_banned has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def activity_for_user_banned(
          Severity: Major
          Found in dino/utils/__init__.py - About 50 mins to fix

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

                def create_room(self, room_name: str, room_id: str, channel_id: str, user_id: str, user_name: str, ephemeral: bool=True, sort_order: int=False) -> None:
            Severity: Major
            Found in dino/db/redis.py - About 50 mins to fix

              Function remove_user_from_room has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def remove_user_from_room(
              Severity: Major
              Found in dino/utils/__init__.py - About 50 mins to fix

                Function mute_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def mute_user(self, room_id, user_id, mute_duration, mute_timestamp, room_name, muter_id, reason) -> None:
                Severity: Major
                Found in dino/db/rdbms/handler.py - About 50 mins to fix

                  Function set_settings has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def set_settings(self, enabled, max_length, min_length, should_delete, should_save, threshold, ignore_emoji):
                  Severity: Major
                  Found in dino/db/manager/spam.py - About 50 mins to fix

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

                        def create_room(self, room_name: str, room_id: str, channel_id: str, user_id: str, user_name, ephemeral: bool=False, sort_order: int=999) -> None:
                    Severity: Major
                    Found in dino/db/__init__.py - About 50 mins to fix

                      Function mute_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def mute_user(self, room_id, user_id, mute_duration, mute_timestamp, room_name, muter_id, reason) -> None:
                      Severity: Major
                      Found in dino/db/__init__.py - About 50 mins to fix

                        Function ban_channel has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def ban_channel(self, data: dict, activity: Activity, rooms_in_channel, channel_id, user_id, user_sids: list, namespace):
                        Severity: Major
                        Found in dino/endpoint/queue.py - About 50 mins to fix

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

                                  if msg_content is None or len(msg_content.strip()) == 0:
                                      raise RuntimeError('content may not be blank')
                          Severity: Major
                          Found in dino/rest/resources/send.py and 2 other locations - About 50 mins to fix
                          dino/rest/resources/broadcast.py on lines 63..64
                          dino/rest/resources/broadcast.py on lines 69..70

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

                          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

                                  if body is None or len(body.strip()) == 0:
                                      raise RuntimeError('body may not be blank')
                          Severity: Major
                          Found in dino/rest/resources/broadcast.py and 2 other locations - About 50 mins to fix
                          dino/rest/resources/broadcast.py on lines 69..70
                          dino/rest/resources/send.py on lines 38..39

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

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

                              def __init__(self):
                                  super(BannedResource, self).__init__()
                                  self.last_cleared = datetime.utcnow()
                                  self.request = request
                          Severity: Major
                          Found in dino/rest/resources/banned.py and 5 other locations - About 50 mins to fix
                          dino/rest/resources/full_history.py on lines 31..34
                          dino/rest/resources/history.py on lines 32..35
                          dino/rest/resources/roles.py on lines 29..32
                          dino/rest/resources/rooms.py on lines 14..17
                          dino/rest/resources/rooms_for_users.py on lines 17..20

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

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

                              def __init__(self):
                                  super(RoomsForUsersResource, self).__init__()
                                  self.last_cleared = datetime.utcnow()
                                  self.request = request
                          Severity: Major
                          Found in dino/rest/resources/rooms_for_users.py and 5 other locations - About 50 mins to fix
                          dino/rest/resources/banned.py on lines 33..36
                          dino/rest/resources/full_history.py on lines 31..34
                          dino/rest/resources/history.py on lines 32..35
                          dino/rest/resources/roles.py on lines 29..32
                          dino/rest/resources/rooms.py on lines 14..17

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

                          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