if flask.request.form['token'] == stored_token:
if size_of_file > 10000:
logging.info('data ' + filename + ' is compressed and sent')
return gzip_compress(resp(200, data))
else:
logging.info(filename + ' data copy')
return resp(200, data)
else:
logging.info(' data ' + filename + ' is not compressed, but copied and sent')
return resp(401, {})
I do not like how this code looks to help fix it. Or tell me that this is a good code.
pptaszni
9,4067 gold badges35 silver badges60 bronze badges
1 Answer 1
Here you go:
if flask.request.form['token'] != stored_token:
logging.info(' data ' + filename + ' is not compressed, but copied and sent')
return resp(401, {})
if size_of_file <= 10000:
logging.info(filename + ' data copy')
return resp(200, data)
logging.info('data ' + filename + ' is compressed and sent')
return gzip_compress(resp(200, data))
In google testing blog there is an article describing why nested if statements are considered bad and how can you reduce your code complexity.
answered Sep 24, 2018 at 7:11
pptaszni
9,4067 gold badges35 silver badges60 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
ifstatement. who said it is bad??