Showing 8 of 8 total issues
Function pluralize
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def pluralize(key, translation, count):
return_value = key
try:
if type(translation) != dict:
return_value = translation
- 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 t
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def t(key, **kwargs):
locale = kwargs.pop('locale', config.get('locale'))
if translations.has(key, locale):
return translate(key, locale=locale, **kwargs)
else:
- 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 load_translation_dic
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def load_translation_dic(dic, namespace, locale):
if namespace:
namespace += config.get('namespace_delimiter')
for key, value in dic.items():
if type(value) == dict and len(set(PLURALS).intersection(value)) < 2:
- 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 search_translation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def search_translation(key, locale=config.get('locale')):
splitted_key = key.split(config.get('namespace_delimiter'))
if not splitted_key:
return
namespace = splitted_key[:-1]
- 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 translation['many']
Avoid too many return
statements within this function. Open
return return_value
Avoid too many return
statements within this function. Open
return key
Function load_directory
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def load_directory(directory, locale=config.get('locale')):
for f in os.listdir(directory):
path = os.path.join(directory, f)
if os.path.isfile(path) and path.endswith(config.get('file_format')):
if '{locale}' in config.get('filename_format') and not locale in f:
- 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"