Showing 42 of 296 total issues
Function download
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def download(self, url, show_status=True):
"""
Download a file from the given url.
Show a progress indicator for the download status.
Based on: http://stackoverflow.com/a/15645088/1547223
- 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 get_latest_response
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_latest_response(self, conversation):
"""
Returns the latest response in a conversation if it exists.
Returns None if a matching conversation cannot be found.
"""
- 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 process
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process(self, statement, additional_response_selection_parameters=None):
response = Statement(text='')
input_text = statement.text
try:
# Use the result cached by the process method if it exists
- 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 len(row) > 0:
statement = Statement(
text=row[3],
in_response_to=previous_statement_text,
conversation='training',
Function date_from_duration
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def date_from_duration(base_date, number_as_string, unit, duration, base_time=None):
Function get_recent_repeated_responses
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_recent_repeated_responses(chatbot, conversation, sample=10, threshold=3, quantity=3):
Function datetime_parsing
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def datetime_parsing(text, base_date=datetime.now()):
"""
Extract datetime objects from a string of text.
"""
matches = []
- 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 create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create(self, **kwargs):
"""
Creates a new statement matching the keyword arguments specified.
Returns the created statement.
"""
- 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 too many return
statements within this function. Open
return datetime(relative_date.year, relative_date.month, relative_date.day, 23, 59, 59)
Avoid too many return
statements within this function. Open
return datetime(relative_date.year, relative_date.month - 1, relative_date.day)
Avoid too many return
statements within this function. Open
return datetime(year, month, day)
Avoid too many return
statements within this function. Open
return relative_date + timedelta(weeks=ord)
Avoid too many return
statements within this function. Open
return relative_date - timedelta(days=relative_date.weekday())
Avoid too many return
statements within this function. Open
return day_of_week + timedelta(days=6 - relative_date.weekday())
Avoid too many return
statements within this function. Open
return relative_date
Avoid too many return
statements within this function. Open
return relative_date - timedelta(weeks=1)
Avoid too many return
statements within this function. Open
return relative_date + timedelta(days=ord)
Avoid too many return
statements within this function. Open
return datetime(relative_date.year, relative_date.month + ord, relative_date.day)
Avoid too many return
statements within this function. Open
return relative_date - timedelta(days=1)
Avoid too many return
statements within this function. Open
return datetime(relative_date.year, relative_date.month, relative_date.day)