debatelab/deepa2

View on GitHub
deepa2/builder/nli_builder.py

Summary

Maintainability
D
1 day
Test Coverage
A
95%

File nli_builder.py has 432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Defines Builders for creating DeepA2 datasets from NLI-type data."""

from __future__ import annotations

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

    Function populate_record has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def populate_record(  # pylint: disable=too-many-statements, too-many-locals
            self, idx: int
        ) -> None:
            """populates record at product index `int`"""
    
    
    Severity: Minor
    Found in deepa2/builder/nli_builder.py - About 2 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 preprocess has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def preprocess(dataset: datasets.Dataset) -> datasets.Dataset:
            df_esnli = pd.DataFrame(dataset.to_pandas())
            df_esnli = df_esnli.drop_duplicates()
            # count explanations per row
            df_esnli["n_explanations"] = 3 - df_esnli[
    Severity: Minor
    Found in deepa2/builder/nli_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 populate_record has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def populate_record(  # pylint: disable=too-many-statements, too-many-locals
            self, idx: int
        ) -> None:
            """populates record at product index `int`"""
    
    
    Severity: Minor
    Found in deepa2/builder/nli_builder.py - About 1 hr to fix

      Function preprocess has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def preprocess(dataset: datasets.Dataset) -> datasets.Dataset:
              df_esnli = pd.DataFrame(dataset.to_pandas())
              df_esnli = df_esnli.drop_duplicates()
              # count explanations per row
              df_esnli["n_explanations"] = 3 - df_esnli[
      Severity: Minor
      Found in deepa2/builder/nli_builder.py - About 1 hr to fix

        Function configure_product has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def configure_product(self) -> None:
                # populate product with configs
                i = 0
                for label in ["entailment", "contradiction"]:
                    # argument_mask specifies which part of argument will be dropped in source text:
        Severity: Minor
        Found in deepa2/builder/nli_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