debatelab/deepa2

View on GitHub
deepa2/builder/aifdb_builder.py

Summary

Maintainability
C
1 day
Test Coverage
D
67%

File aifdb_builder.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Defines Builders for creating DeepA2 datasets from AIFdb corpora."""

from __future__ import annotations

import dataclasses
Severity: Minor
Found in deepa2/builder/aifdb_builder.py - About 4 hrs to fix

    Function split_nodeset_per_inference has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def split_nodeset_per_inference(  # pylint: disable=too-many-locals, too-many-statements
            examples: Dict[str, List]
        ) -> Dict[str, List]:
            """extracts individual inferences from nodesets, and splits nodesets accordingly"""
    
    
    Severity: Minor
    Found in deepa2/builder/aifdb_builder.py - About 3 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 load_dataset has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_dataset(self) -> datasets.DatasetDict:
            splits = self._aifdb_config.splits
    
            # download and unpack corpora
            aifdb_dir = Path(self._aifdb_config.cache_dir)
    Severity: Minor
    Found in deepa2/builder/aifdb_builder.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 _read_textfile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _read_textfile(textfile: Path) -> str:
            """tries to read text file"""
            lines: List[str] = []
            if textfile.exists():
                for enc in ["utf8", "ascii", "windows-1252", "cp500"]:
    Severity: Minor
    Found in deepa2/builder/aifdb_builder.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 produce_da2item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def produce_da2item(self) -> None:
            # we produce a single da2item per input only
            record = self._product[0]
            record.source_text = str(self.input.text)
            if self.input.reasons:
    Severity: Minor
    Found in deepa2/builder/aifdb_builder.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