thenetcircle/dino

View on GitHub

Showing 809 of 809 total issues

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

    def __init__(self):
        super(RolesResource, self).__init__()
        self.last_cleared = datetime.utcnow()
        self.request = request
Severity: Major
Found in dino/rest/resources/roles.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/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(FullHistoryResource, self).__init__()
        self.last_cleared = datetime.utcnow()
        self.request = request
Severity: Major
Found in dino/rest/resources/full_history.py and 5 other locations - About 50 mins to fix
dino/rest/resources/banned.py on lines 33..36
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(RoomsResource, self).__init__()
        self.last_cleared = datetime.utcnow()
        self.request = request
Severity: Major
Found in dino/rest/resources/rooms.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_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(HistoryResource, self).__init__()
        self.last_cleared = datetime.utcnow()
        self.request = request
Severity: Major
Found in dino/rest/resources/history.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/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 3 locations. Consider refactoring.
Open

        if verb is None or len(verb.strip()) == 0:
            raise RuntimeError('verb 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 63..64
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

Avoid deeply nested control flow statements.
Open

                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
Severity: Major
Found in dino/templates/js/json2.js - About 45 mins to fix

    Function activity_for_request_admin has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def activity_for_request_admin(user_id: str, user_name: str, room_id: str, room_name: str, message: str, admin_room_id: str):
    Severity: Minor
    Found in dino/utils/__init__.py - About 45 mins to fix

      Function create_room_acl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_room_acl(room_uuid: str):
          form = request.get_json()
          action = form['action']
          acl_type = form['type']
          acl_value = form['value']
      Severity: Minor
      Found in dino/admin/routes.py - About 45 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 activity_for_get_acl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def activity_for_get_acl(activity: Activity, acl_values: dict, ignore: set = None) -> dict:
          response = ActivityBuilder.enrich({
              'object': {
                  'objectType': 'acl'
              },
      Severity: Minor
      Found in dino/utils/__init__.py - About 45 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

      Avoid deeply nested control flow statements.
      Open

                              if (v) {
                                  partial.push(quote(k) + (gap ? ': ' : ':') + v);
                              }
      Severity: Major
      Found in dino/templates/js/json2.js - About 45 mins to fix

        Function count_connections has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def count_connections(connect_type=None):
            def factory(view_func):
                @wraps(view_func)
                def decorator(*args, **kwargs):
                    try:
        Severity: Minor
        Found in dino/utils/decorators.py - About 45 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 set_user_online_if_not_previously_invisible has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_user_online_if_not_previously_invisible(arg: tuple) -> None:
                data, activity = arg
                user_id = activity.actor.id
                user_status = utils.get_user_status(user_id, skip_cache=True)
                invisible_login = False
        Severity: Minor
        Found in dino/hooks/login.py - About 45 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 _contains_blacklisted_word has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _contains_blacklisted_word(self, activity: Activity):
                message = activity.object.content
                blacklist = self._get_black_list()
        
                if blacklist is None or len(blacklist) == 0:
        Severity: Minor
        Found in dino/utils/blacklist.py - About 45 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_user_room has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def ban_user_room(self, user_id: str, ban_timestamp: str, ban_duration: str, room_id: str, reason: str=None, banner_id: str=None):
        Severity: Minor
        Found in dino/db/redis.py - About 45 mins to fix

          Function remove_room has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def remove_room(channel_id, room_id, user_id, user_name, room_name, is_delayed_removal: bool = False):
          Severity: Minor
          Found in dino/utils/__init__.py - About 45 mins to fix

            Function activity_for_login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def activity_for_login(
                    user_id: str, user_name: str,
                    include_unread_history: bool = False,
                    encode_attachments: bool = True,
                    heartbeat_sid=False,
            Severity: Minor
            Found in dino/utils/__init__.py - About 45 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 activity_for_invite has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def activity_for_invite(
            Severity: Minor
            Found in dino/utils/__init__.py - About 45 mins to fix

              Function set_user_online_if_not_previously_invisible has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def set_user_online_if_not_previously_invisible(arg: tuple) -> None:
                      data, activity = arg
                      user_id = activity.actor.id
                      user_status = utils.get_user_status(user_id)
                      environ.env.cache.check_heartbeat(user_id)
              Severity: Minor
              Found in dino/hooks/heartbeat.py - About 45 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_user_channel has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def ban_user_channel(self, user_id: str, ban_timestamp: str, ban_duration: str, channel_id: str, reason: str=None, banner_id: str=None):
              Severity: Minor
              Found in dino/db/redis.py - About 45 mins to fix

                Function activity_for_login has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def activity_for_login(
                Severity: Minor
                Found in dino/utils/__init__.py - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language