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
- Read upRead up
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
- Read upRead up
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:
- Read upRead up
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]
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
try:
result = str(json.load(urllib.urlopen(url))['result'])
except:
result = 0
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
try:
result = str(json.load(urllib.urlopen(url))['result'])
except:
result = 0
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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]
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Read upRead up
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)
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:
Avoid deeply nested control flow statements. Open
if "@" in each:
username = each[1:-1]
if username and username != "@":
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
- Read upRead up
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:
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")
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") % (
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)
Avoid deeply nested control flow statements. Open
if code:
gidstoping.append(chat_id)
feedsupdated.append({'name': name, 'gid': gid,
'dateitem': dateitemfor})
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:
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)