mrDoctorWho/vk4xmpp

View on GitHub
extensions/groupchats.py

Summary

Maintainability
D
2 days
Test Coverage

File groupchats.py has 493 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding: utf-8
# This file is a part of VK4XMPP transport
# © simpleApps, 2013 — 2018.

# Installation:
Severity: Minor
Found in extensions/groupchats.py - About 7 hrs to fix

    Function handleOutgoingChatMessage has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def handleOutgoingChatMessage(user, vkChat):
        """
        Handles outging VK messages and sends them to XMPP
        """
        # peer_id for newer APIs
    Severity: Minor
    Found in extensions/groupchats.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 exterminateChats has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def exterminateChats(user=None, chats=[]):
        """
        Calls a Dalek for exterminate the chat
        The chats argument must be a list of tuples
        """
    Severity: Minor
    Found in extensions/groupchats.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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def update(self, userObject):
            """
            Updates chat users and sends messages
            Uses two user lists to prevent losing of any of them
            """
    Severity: Minor
    Found in extensions/groupchats.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 handleMessage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def handleMessage(self, user, vkChat, retry=True):
            """
            Handle incoming (VK -> XMPP) messages
            """
            if self.created:
    Severity: Minor
    Found in extensions/groupchats.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 init has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def init(self, owner, id, jid, subject, date, users=[]):
    Severity: Minor
    Found in extensions/groupchats.py - About 45 mins to fix

      Function setChatConfig has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def setChatConfig(chat, jidFrom, exterminate=False, cb=None, args={}):
      Severity: Minor
      Found in extensions/groupchats.py - About 35 mins to fix

        Function setAffiliation has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def setAffiliation(chat, afl, jid, jidFrom=TransportID, reason=None):
        Severity: Minor
        Found in extensions/groupchats.py - About 35 mins to fix

          Function chatMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def chatMessage(chat, text, jidFrom, subj=None, timestamp=0):
          Severity: Minor
          Found in extensions/groupchats.py - About 35 mins to fix

            Function cleanTheChatsUp has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def cleanTheChatsUp():
                """
                Calls Dalek(s) to exterminate inactive users or their chats, whatever they catch
                """
                chats = runDatabaseQuery("select jid, owner, last_used, user from groupchats")
            Severity: Minor
            Found in extensions/groupchats.py - About 35 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 getUserObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def getUserObject(source):
                    """
                    Gets user object by chat jid
                    """
                    user = None
            Severity: Minor
            Found in extensions/groupchats.py - About 35 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 getUserByID has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def getUserByID(id):
                    for user in Users.values():
                        if hasattr(user, "vk"):
                            if user.vk.getUserPreferences()[0] == id:
                                return user
            Severity: Minor
            Found in extensions/groupchats.py - About 25 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

            There are no issues that match your filters.

            Category
            Status