Showing 9 of 17 total issues
Function update_flow_control
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def update_flow_control(self, **kwargs):
fields = ['flow_name', 'flow_step', 'school', 'age', 'comment',
'menu_date', 'satisfied', 'evaluation', 'meal']
user = self._get_user()
# TODO refatorar isso.
- 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 _flow_evaluate_meal
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _flow_evaluate_meal(self, step):
current_flow = BotFlowEnum.AVALIAR_REFEICAO.value
if step == self.STEP_MENU_SHOWN:
self._show_menu(has_buttons=True)
self.bot.set_flow(current_flow, self.STEP_MENU_SHOWN2)
- 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 validate_payload
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_payload(payload, platform):
# TODO: improve this validator
if platform == 'facebook':
messaging = payload['entry'][0]['messaging'][0]
if messaging.get('message'):
- 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 _show_menu
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _show_menu(self, has_buttons=False):
user_data = self.bot.get_user_data()
flow_control = user_data['flow_control']
timestamp = str(flow_control['menu_date']['$date'])[:10]
menu_date = datetime.datetime.utcfromtimestamp(int(timestamp)).strftime('%Y%m%d')
- 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 _print_menu
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _print_menu(self, menu, has_buttons=False, school_meals=[]):
# XXX: because of poor REST API
menu_str = ''
buttons = []
meals = menu[0]['cardapio']
- 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 _base_menu_flow
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _base_menu_flow(self, current_flow, step):
"""Search for school and returns menu"""
if step == self.STEP_SEARCH_SCHOOL:
self.bot.send_message('Digite o nome da escola')
self.bot.set_flow(current_flow, self.STEP_SEARCH_SCHOOL2)
- 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 False
Function _flow_meal_alert
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _flow_meal_alert(self, step):
current_flow = BotFlowEnum.RECEBER_NOTIFICACAO.value
if step == self.STEP_SEARCH_SCHOOL:
self.bot.send_message('Digite o nome da escola')
self.bot.set_flow(current_flow, self.STEP_SEARCH_SCHOOL2)
- 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 send_notifications
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def send_notifications(self):
for user_data in self.users_with_notification:
if self._validate_user_notification(user_data):
notification = user_data.notification
today_api_format = datetime.datetime.today().strftime('%Y%m%d')
- 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"