debatelab/deepa2

View on GitHub
deepa2/metrics/metric_handler.py

Summary

Maintainability
C
1 day
Test Coverage
A
96%

File metric_handler.py has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""metric handlers and basic class for calculating metrics"""

from __future__ import annotations
from abc import ABC, abstractmethod
import re
Severity: Minor
Found in deepa2/metrics/metric_handler.py - About 2 hrs to fix

    Function no_petitio has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def no_petitio(parsed_pred: Optional[Argument]) -> Optional[int]:
            """checks if a reconstruction is no petitio
            i.e. no conclusion is a premise,
            petitio is a special case of redundancy"""
    
    
    Severity: Minor
    Found in deepa2/metrics/metric_handler.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

    Function compute_metrics has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def compute_metrics(self, predictions: List[str], references: List[str]):
            """
            compute da2 metrics of predictions given references
    
            Args:
    Severity: Minor
    Found in deepa2/metrics/metric_handler.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

    Function consistent_usage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def consistent_usage(parsed_pred: Optional[Argument]) -> Optional[int]:
            """checks if info about used statements is consistent"""
    
            if parsed_pred is None:
                return None
    Severity: Minor
    Found in deepa2/metrics/metric_handler.py - About 45 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 score has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def score(
            self,
            pred_as_formulae: Optional[List[Optional[Formalization]]],
            ref_as_formulae: Optional[List[Optional[Formalization]]],
        ):
    Severity: Minor
    Found in deepa2/metrics/metric_handler.py - About 45 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

    Avoid too many return statements within this function.
    Open

                return self._MIN_SCORES
    Severity: Major
    Found in deepa2/metrics/metric_handler.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return scores
      Severity: Major
      Found in deepa2/metrics/metric_handler.py - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status