tensorflow/models

View on GitHub
research/object_detection/legacy/evaluator.py

Summary

Maintainability
D
2 days
Test Coverage

Function evaluate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def evaluate(create_input_dict_fn, create_model_fn, eval_config, categories,
             checkpoint_dir, eval_dir, graph_hook_fn=None, evaluator_list=None):
  """Evaluation function for detection models.

  Args:
Severity: Minor
Found in research/object_detection/legacy/evaluator.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 evaluate has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def evaluate(create_input_dict_fn, create_model_fn, eval_config, categories,
Severity: Major
Found in research/object_detection/legacy/evaluator.py - About 1 hr to fix

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

    def get_evaluators(eval_config, categories):
      """Returns the evaluator class according to eval_config, valid for categories.
    
      Args:
        eval_config: evaluation configurations.
    Severity: Minor
    Found in research/object_detection/legacy/evaluator.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 _process_batch has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def _process_batch(tensor_dict, sess, batch_index, counters,
    Severity: Minor
    Found in research/object_detection/legacy/evaluator.py - About 35 mins to fix

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

      def _extract_predictions_and_losses(model,
                                          create_input_dict_fn,
                                          ignore_groundtruth=False):
        """Constructs tensorflow detection graph and returns output tensors.
      
      
      Severity: Minor
      Found in research/object_detection/legacy/evaluator.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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

            eval_util.visualize_detection_results(
                result_dict,
                tag,
                global_step,
                categories=categories,
      Severity: Major
      Found in research/object_detection/legacy/evaluator.py and 1 other location - About 2 hrs to fix
      research/lstm_object_detection/evaluator.py on lines 270..285

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 58.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if fields.DetectionResultFields.detection_keypoints in detections:
            groundtruth[fields.InputDataFields.groundtruth_keypoints] = (
                input_dict[fields.InputDataFields.groundtruth_keypoints])
            groundtruth_keypoints_list = [
                input_dict[fields.InputDataFields.groundtruth_keypoints]]
      Severity: Major
      Found in research/object_detection/legacy/evaluator.py and 1 other location - About 2 hrs to fix
      research/object_detection/legacy/evaluator.py on lines 109..113

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if fields.DetectionResultFields.detection_masks in detections:
            groundtruth[fields.InputDataFields.groundtruth_instance_masks] = (
                input_dict[fields.InputDataFields.groundtruth_instance_masks])
            groundtruth_masks_list = [
                input_dict[fields.InputDataFields.groundtruth_instance_masks]]
      Severity: Major
      Found in research/object_detection/legacy/evaluator.py and 1 other location - About 2 hrs to fix
      research/object_detection/legacy/evaluator.py on lines 115..119

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 7 locations. Consider refactoring.
      Open

      EVAL_METRICS_CLASS_DICT = {
          'pascal_voc_detection_metrics':
              object_detection_evaluation.PascalDetectionEvaluator,
          'weighted_pascal_voc_detection_metrics':
              object_detection_evaluation.WeightedPascalDetectionEvaluator,
      Severity: Major
      Found in research/object_detection/legacy/evaluator.py and 6 other locations - About 2 hrs to fix
      official/nlp/modeling/models/seq2seq_transformer.py on lines 96..107
      official/projects/yolo/modeling/layers/nn_blocks.py on lines 321..332
      official/projects/yolo/modeling/layers/nn_blocks.py on lines 494..505
      official/projects/yolo/modeling/layers/nn_blocks.py on lines 643..654
      official/projects/yolo/modeling/layers/nn_blocks.py on lines 777..788
      official/projects/yolo/modeling/layers/nn_blocks.py on lines 1072..1083

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 51.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          try:
            if not losses_dict:
              losses_dict = {}
            result_dict, result_losses_dict = sess.run([tensor_dict, losses_dict])
            counters['success'] += 1
      Severity: Major
      Found in research/object_detection/legacy/evaluator.py and 1 other location - About 1 hr to fix
      research/object_detection/eval_util.py on lines 344..349

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 44.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 7 locations. Consider refactoring.
      Open

          if fields.InputDataFields.groundtruth_group_of in input_dict:
            groundtruth[fields.InputDataFields.groundtruth_group_of] = (
                input_dict[fields.InputDataFields.groundtruth_group_of])
      Severity: Major
      Found in research/object_detection/legacy/evaluator.py and 6 other locations - About 1 hr to fix
      research/object_detection/inputs.py on lines 737..739
      research/object_detection/inputs.py on lines 740..742
      research/object_detection/inputs.py on lines 743..745
      research/object_detection/inputs.py on lines 746..748
      research/object_detection/inputs.py on lines 749..751
      research/object_detection/model_lib.py on lines 671..673

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status