tensorflow/models

View on GitHub
official/nlp/finetuning/binary_helper.py

Summary

Maintainability
D
2 days
Test Coverage

File binary_helper.py has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Minor
Found in official/nlp/finetuning/binary_helper.py - About 5 hrs to fix

    Function override_qa_task_config has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def override_qa_task_config(
    Severity: Major
    Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

      Function override_sentence_prediction_task_config has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def override_sentence_prediction_task_config(
      Severity: Major
      Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

        Function override_trainer_cfg has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def override_trainer_cfg(trainer_cfg: cfg.TrainerConfig, learning_rate: float,
        Severity: Major
        Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

          Function write_glue_classification has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def write_glue_classification(task,
          Severity: Major
          Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

            Function write_question_answering has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def write_question_answering(task,
            Severity: Major
            Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

              Function write_xtreme_classification has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def write_xtreme_classification(task,
              Severity: Major
              Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

                Function override_tagging_task_config has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def override_tagging_task_config(task_cfg: tagging.TaggingConfig,
                Severity: Major
                Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

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

                  def write_glue_classification(task,
                                                model,
                                                input_file,
                                                output_file,
                                                predict_batch_size,
                  Severity: Minor
                  Found in official/nlp/finetuning/binary_helper.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 write_superglue_classification has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def write_superglue_classification(task,
                  Severity: Major
                  Found in official/nlp/finetuning/binary_helper.py - About 1 hr to fix

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

                    def load_model_config_file(model_config_file: str) -> Dict[str, Any]:
                      """Loads bert config json file or `encoders.EncoderConfig` in yaml file."""
                      if not model_config_file:
                        # model_config_file may be empty when using tf.hub.
                        return {}
                    Severity: Minor
                    Found in official/nlp/finetuning/binary_helper.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 write_tagging has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def write_tagging(task, model, input_file, output_file, predict_batch_size,
                    Severity: Minor
                    Found in official/nlp/finetuning/binary_helper.py - About 45 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status