iranzo/stampython

View on GitHub

Showing 154 of 154 total issues

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

def kick(chat_id=False, user_id=False, ban=False):
    """
    Use API call to have the bot kick out of chat
    :param chat_id:  chat id to locate user into
    :param user_id:  user id to kick out of chat
Severity: Minor
Found in stampy/plugin/irccommands.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 dokarmacleanup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def dokarmacleanup(word=False, maxage=int(stampy.plugin.config.config("maxage", default=180))):
    """
    Checks on the karma database the date of the last update in the word
    :param word: word to query in database
    :param maxage: defines maximum number of days to allow karma to be inactive
Severity: Minor
Found in stampy/plugin/karma.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 forwardmessage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def forwardmessage(message):
    """
    Forwards a message based on id/chatid to target chatid
    :param message: Message to process (contaning all details)
    :return:
Severity: Minor
Found in stampy/plugin/forward.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

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

            if name:
                for each in name.split():
                    if "@" in each:
                        username = each[1:-1]
Severity: Minor
Found in stampy/plugin/stats.py and 1 other location - About 55 mins to fix
stampy/plugin/stats.py on lines 633..636

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

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

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

    try:
        result = str(json.load(urllib.urlopen(url))['result'])
    except:
        result = 0
Severity: Minor
Found in stampy/plugin/stats.py and 1 other location - About 55 mins to fix
stampy/plugin/stats.py on lines 425..428

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

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

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

    try:
        result = str(json.load(urllib.urlopen(url))['result'])
    except:
        result = 0
Severity: Minor
Found in stampy/plugin/stats.py and 1 other location - About 55 mins to fix
stampy/plugin/stats.py on lines 406..409

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

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

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

            if name:
                for each in name.split():
                    if "@" in each:
                        username = each[1:-1]
Severity: Minor
Found in stampy/plugin/stats.py and 1 other location - About 55 mins to fix
stampy/plugin/stats.py on lines 722..725

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

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

def shouldrun(name):
    """
    Checks name on database to see if it should run or not and updates as executed
    :param name: Name to check on database
    :return: Bool
Severity: Minor
Found in stampy/stampy.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 getitems has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def getitems(var):
    """
    Returns list of items even if provided args are lists of lists
    :param var: list or value to pass
    :return: unique list of values
Severity: Minor
Found in stampy/stampy.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

Avoid deeply nested control flow statements.
Open

                    if result['ok'] is True or result['ok'] == 'True':
                        text = _("User %s kicked out of chat %s") % (user_id, chat_id)
                    else:
                        text = _("Error kicking 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 hilight in gethilightwords(uid=uid):
                            logger.debug(msg=_L('Word %s is in text and forwarding for user') % hilight)
                            forward = True
            else:
    Severity: Major
    Found in stampy/plugin/highlight.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

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

        def topic(chat_id=False, title=False):
            """
            Use API call to have the bot change topic
            :param chat_id:  chat id to locate user into
            :param title: new title to set
        Severity: Minor
        Found in stampy/plugin/irccommands.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 stampy.plugin.alias.getalias(word, gid=gid):
                                word = stampy.plugin.alias.getalias(word, gid=gid).split(" ")
                            for item in word:
        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 kicked and banned out of chat %s") % (user_id, chat_id)
                              else:
                                  text = _("Error kick+ban 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 result['ok'] is True or result['ok'] == 'True':
                                    text = _("User %s muted on chat %s") % (user_id,
                                                                            chat_id)
                                else:
                                    text = _("Error muting user %s from chat %s: %s") % (
            Severity: Major
            Found in stampy/plugin/irccommands.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if len(newadmin) != 0:
                                      stampy.plugin.config.setconfig(key='admin',
                                                                     value=newadmin, gid=id)
                                  else:
                                      stampy.plugin.config.deleteconfig(key='admin', gid=id)
              Severity: Major
              Found in stampy/plugin/stats.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if code:
                                        gidstoping.append(chat_id)
                                        feedsupdated.append({'name': name, 'gid': gid,
                                                             'dateitem': dateitemfor})
                
                
                Severity: Major
                Found in stampy/plugin/feed.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if key in validkeys or gid == 0:
                                          value = "=".join(word.split('=')[1:])
                                          setconfig(key=key, value=value, gid=gid)
                                          text = _("Setting config for `%s` to `%s`") % (key, value)
                                      else:
                  Severity: Major
                  Found in stampy/plugin/config.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

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