iranzo/stampython

View on GitHub

Showing 154 of 154 total issues

Avoid deeply nested control flow statements.
Open

                    if len(word) == 2:
                        oper = word[-2:]
                        try:
                            word = msgdetail["replyto"].lower()
                        except:
Severity: Major
Found in stampy/plugin/karma.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if result['ok'] is True or result['ok'] == 'True':
                            text = _("User %s unbanned out of chat %s") % (user_id, chat_id)
                        else:
                            text = _("Error unbanning user %s from chat %s: %s") % (user_id, chat_id, result['description'])
                        stampy.stampy.sendmessage(chat_id=chat_id, text=text, reply_to_message_id=message_id, disable_web_page_preview=True, parse_mode="Markdown")
    Severity: Major
    Found in stampy/plugin/irccommands.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if token:
                                  chanlinkslave(message=message, token=token)
                          except:
      Severity: Major
      Found in stampy/plugin/admin.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if url and 'USA-' in title:
                                url = url = "https://us-redhat.icims.com/jobs/%s/job?iis=A+Red+Hat+Employee&iispid=21098" % jobid
        
        
        Severity: Major
        Found in stampy/plugin/feed.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if gid > 0:  # user private chat
                                  validkeys = ['language', 'currency', 'modulo',
                                               'stock', 'espp', 'cleanlink', 'cleankey']
                              elif gid < 0:  # group chat or channel
                                  validkeys = ['language', 'currency', 'modulo',
          Severity: Major
          Found in stampy/plugin/config.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if key == 'gid':
                                    value = texto.split('=')[1:][0].lower()
                                    text = _("Setting gid for sudo to `%s`") % value
                                    stampy.stampy.sendmessage(chat_id=chat_id, text=text,
                                                              reply_to_message_id=message_id,
            Severity: Major
            Found in stampy/plugin/sudo.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if command == trigger[1:]:
                                      runplugin = True
                                      break
                              elif trigger in texto:
              Severity: Major
              Found in stampy/stampy.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if result['ok'] is True or result['ok'] == 'True':
                                        text = _("Users opped on chat %s") % chat_id
                                    else:
                                        text = _("Error opping users from chat %s: %s") % (chat_id, result)
                
                
                Severity: Major
                Found in stampy/plugin/irccommands.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if result['ok'] is True or result['ok'] == 'True':
                                          text = _("User %s oped on chat %s") % (user_id, chat_id)
                                      else:
                                          text = _("Error oping user %s from chat %s: %s") % (user_id, chat_id, result)
                  
                  
                  Severity: Major
                  Found in stampy/plugin/irccommands.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if newurl != url:
                                            delete = True
                    
                                        # Check if url has to be cleaned
                                        if cleankey:
                    Severity: Major
                    Found in stampy/plugin/cleanlink.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          for item in word:
                                              if stampy.plugin.alias.getalias(item, gid=gid):
                                                  item = stampy.plugin.alias.getalias(item, gid=gid)
                                              if oper == "++" and item not in wordadd:
                                                  wordadd.append(item)
                      Severity: Major
                      Found in stampy/plugin/karma.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if stampy.plugin.config.config(key='sudo'):
                                                # "=" was not in first command, so consider a command to use as 'sudo'
                        
                                                # It is a new list, with unique message, so we can alter it
                                                stampy.plugin.config.setconfig(key='overridegid', gid=0, value=message['message']['chat']['id'])
                        Severity: Major
                        Found in stampy/plugin/sudo.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if "@" in each:
                                                  username = each[1:-1]
                                      if username and username != "@":
                          Severity: Major
                          Found in stampy/plugin/stats.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if result['ok'] is True or result['ok'] == 'True':
                                                    text = _("User %s unmuted on chat %s") % (user_id, chat_id)
                                                else:
                                                    text = _("Error unmuting %s from chat %s: %s") % (
                                                        user_id, chat_id, result)
                            Severity: Major
                            Found in stampy/plugin/irccommands.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if result['ok'] is True or result['ok'] == 'True':
                                                      text = _("User %s information: %s") % (user_id, result['result'])
                                                  else:
                                                      text = _("Error querying user %s information: %s") % (user_id, result)
                              
                              
                              Severity: Major
                              Found in stampy/plugin/irccommands.py - About 45 mins to fix

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

                                def sendmessage(chat_id=0, text="", reply_to_message_id=False,
                                Severity: Minor
                                Found in stampy/stampy.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if result['ok'] is True or result['ok'] == 'True':
                                                          text = _("User %s deoped on chat %s") % (user_id, chat_id)
                                                      else:
                                                          text = _("Error deoping %s from chat %s: %s") % (user_id, chat_id, result)
                                  
                                  
                                  Severity: Major
                                  Found in stampy/plugin/irccommands.py - About 45 mins to fix

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

                                    def stock(message):
                                        """
                                        Processes stock commands
                                        :param message: Message with the command
                                        :return:
                                    Severity: Minor
                                    Found in stampy/plugin/stock.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 cleankey:
                                                            renewurl = re.sub(cleankey, '', newurl)
                                                            if renewurl != newurl:
                                                                delete = True
                                    
                                    
                                    Severity: Major
                                    Found in stampy/plugin/cleanlink.py - About 45 mins to fix

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

                                      def sendimage(chat_id=0, image="", text="", reply_to_message_id=""):
                                          """
                                          Sends an image to chat_id as a reply to a message received
                                          :param chat_id: ID of the chat
                                          :param image: image URI
                                      Severity: Minor
                                      Found in stampy/stampy.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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language