debatelab/deepa2

View on GitHub

Showing 44 of 44 total issues

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 _format_field has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _format_field(  # pylint: disable=too-many-return-statements
            self, data: Any, field: dataclasses.Field
        ) -> Optional[str]:
            """formats field"""
            if data is None:
    Severity: Minor
    Found in deepa2/parsers.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 _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 serve has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def serve(  # pylint: disable=too-many-arguments
    Severity: Major
    Found in deepa2/main.py - About 1 hr to fix

      Function parse_argdown_block has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_argdown_block(self, ad_raw: str) -> Optional[List[ArgumentStatement]]:
              """parses argdown block"""
              # preprocess
              ad_raw = self.preprocess_ad(ad_raw)
              regex = self.INFERENCE_PATTERN_REGEX
      Severity: Minor
      Found in deepa2/parsers.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 from_batch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_batch(cls, batched_data: Dict[str, List]):
              """Unbatches data and returns a DeepA2Item"""
              unbatched_data = {k: v[0] for k, v in batched_data.items()}
      
              for field in dataclasses.fields(cls):
      Severity: Minor
      Found in deepa2/datastructures.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 bake has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def bake(  # noqa: C901  pylint: disable=too-many-arguments,too-many-branches,too-many-statements
      Severity: Major
      Found in deepa2/main.py - About 50 mins to fix

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

            def process(self, batched_input: Dict[str, List]) -> Dict[str, List]:
                """
                The Director provides a function that can be mapped over a dataset
                (requiring batches of size 1).
                """
        Severity: Minor
        Found in deepa2/builder/core.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 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

        Function _generate_source has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _generate_source(
        Severity: Minor
        Found in deepa2/builder/arg_q_builder.py - About 45 mins to fix

          Function _generate_source has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _generate_source(
          Severity: Minor
          Found in deepa2/builder/entailmentbank_builder.py - About 35 mins to fix

            Function transform has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def transform(
            Severity: Minor
            Found in deepa2/builder/core.py - About 35 mins to fix

              Function _generate_source has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _generate_source(
                      self,
                      triples: Dict[str, str],
                      question_text: str,
                      answer_text: str,
              Severity: Minor
              Found in deepa2/builder/entailmentbank_builder.py - About 35 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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __init__(self, **config) -> None:
                      self._sources: Dict = config["sources"]
                      self._export_path: str = config["export_path"]
                      self._export_format: str = config["export_format"]
                      self._mask_probability: float = config["mask_probability"]
              Severity: Minor
              Found in deepa2/preptrain/t2tpreprocessor.py - About 35 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._format_list(da2list)
              Severity: Major
              Found in deepa2/parsers.py - About 30 mins to fix

                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

                    Avoid too many return statements within this function.
                    Open

                                return self._format_dict(dictdata)
                    Severity: Major
                    Found in deepa2/parsers.py - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language