danhper/python-i18n

View on GitHub
i18n/resource_loader.py

Summary

Maintainability
A
1 hr
Test Coverage

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]
Severity: Minor
Found in i18n/resource_loader.py - About 35 mins to fix

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:
Severity: Minor
Found in i18n/resource_loader.py - About 35 mins to fix

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_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:
Severity: Minor
Found in i18n/resource_loader.py - About 25 mins to fix

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

There are no issues that match your filters.

Category
Status