Unbabel/OpenKiwi

View on GitHub
kiwi/lib/evaluate.py

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Function retrieve_predictions has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

def retrieve_predictions(pipeline_options, is_wmt18_pred_format):
    pred_files = {target: [] for target in const.TARGETS}
    if pipeline_options.pred_target:
        for pred_file in pipeline_options.pred_target:
            pred_target = read_file(pred_file)
Severity: Minor
Found in kiwi/lib/evaluate.py - About 5 hrs 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

File evaluate.py has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#  OpenKiwi: Open-Source Machine Translation Quality Estimation
#  Copyright (C) 2019 Unbabel <openkiwi@unbabel.com>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Affero General Public License as published
Severity: Minor
Found in kiwi/lib/evaluate.py - About 3 hrs to fix

    Function evaluate_from_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def evaluate_from_options(options):
        """
        Evaluates a model's predictions based on the flags received from
         the configuration files. Refer to configuration for a list of
        available configuration flags for the evaluate pipeline.
    Severity: Minor
    Found in kiwi/lib/evaluate.py - About 1 hr 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