Unbabel/OpenKiwi

View on GitHub
kiwi/lib/evaluate.py

Summary

Maintainability
D
2 days
Test Coverage
B
87%

Function run has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

def run(config: Configuration) -> MetricsReport:
    """Runs the evaluation pipeline for evaluating a model's predictions. Essentially
    calculating metrics using `gold_targets` and `prediction_files`.

    Refer to configuration for a list of available options for this pipeline.
Severity: Minor
Found in kiwi/lib/evaluate.py - About 1 day 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 423 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#  OpenKiwi: Open-Source Machine Translation Quality Estimation
#  Copyright (C) 2020 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 6 hrs to fix

    Function normalize_prediction_files has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def normalize_prediction_files(
        predicted_files_config: List[OutputConfig], predicted_dir_config: List[Path],
    ):
        prediction_files = defaultdict(list)
        if predicted_files_config:
    Severity: Minor
    Found in kiwi/lib/evaluate.py - About 4 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

    Function to_numeric_values has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def to_numeric_values(
        predictions: Union[str, List[str], List[List[str]]]
    ) -> Union[int, float, List[int], List[float], List[List[int]], List[List[float]]]:
        """Convert text labels or string probabilities (for BAD) to int or float values,
        respectively."""
    Severity: Minor
    Found in kiwi/lib/evaluate.py - About 55 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 to_numeric_binary_labels has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def to_numeric_binary_labels(
        predictions: Union[
            str, float, List[str], List[List[str]], List[float], List[List[float]]
        ],
        threshold: float = 0.5,
    Severity: Minor
    Found in kiwi/lib/evaluate.py - About 55 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