tensorflow/models

View on GitHub
official/vision/dataloaders/tf_example_decoder_test.py

Summary

Maintainability
F
3 days
Test Coverage

File tf_example_decoder_test.py has 270 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/vision/dataloaders/tf_example_decoder_test.py - About 2 hrs to fix

    Function test_result_content has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def test_result_content(self):
        decoder = tf_example_decoder.TfExampleDecoder(
            include_mask=True, attribute_names=['attr1', 'attr2']
        )
    
    
    Severity: Minor
    Found in official/vision/dataloaders/tf_example_decoder_test.py - About 1 hr to fix

      Function test_handling_missing_fields has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def test_handling_missing_fields(self):
          decoder = tf_example_decoder.TfExampleDecoder(include_mask=True)
      
          image_content = [[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]],
                           [[0, 0, 0], [255, 255, 255], [255, 255, 255], [0, 0, 0]],
      Severity: Minor
      Found in official/vision/dataloaders/tf_example_decoder_test.py - About 1 hr to fix

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

          def test_result_shape(self, image_height, image_width, num_instances,
        Severity: Minor
        Found in official/vision/dataloaders/tf_example_decoder_test.py - About 35 mins to fix

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

              image_content = [[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]],
                               [[0, 0, 0], [255, 255, 255], [255, 255, 255], [0, 0, 0]],
                               [[0, 0, 0], [255, 255, 255], [255, 255, 255], [0, 0, 0]],
                               [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]
          Severity: Major
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 2 other locations - About 5 hrs to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 84..87
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 89..92

          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 94.

          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 3 locations. Consider refactoring.
          Open

              image_content = [[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]],
                               [[0, 0, 0], [255, 255, 255], [255, 255, 255], [0, 0, 0]],
                               [[0, 0, 0], [255, 255, 255], [255, 255, 255], [0, 0, 0]],
                               [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]
          Severity: Major
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 2 other locations - About 5 hrs to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 212..215
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 89..92

          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 94.

          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 24 locations. Consider refactoring.
          Open

              mask_content = [[[255, 255, 0, 0],
                               [255, 255, 0, 0],
                               [0, 0, 0, 0],
                               [0, 0, 0, 0]],
                              [[0, 255, 255, 255],
          Severity: Major
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 23 other locations - About 2 hrs to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 225..232
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 106..113
          research/object_detection/core/batch_multiclass_nms_test.py on lines 453..460
          research/object_detection/core/batch_multiclass_nms_test.py on lines 528..535
          research/object_detection/core/target_assigner_test.py on lines 534..541
          research/object_detection/core/target_assigner_test.py on lines 583..590
          research/object_detection/core/target_assigner_test.py on lines 591..598
          research/object_detection/core/target_assigner_test.py on lines 599..606
          research/object_detection/core/target_assigner_test.py on lines 658..665
          research/object_detection/core/target_assigner_test.py on lines 666..673
          research/object_detection/core/target_assigner_test.py on lines 674..681
          research/object_detection/core/target_assigner_test.py on lines 763..770
          research/object_detection/core/target_assigner_test.py on lines 970..977
          research/object_detection/core/target_assigner_test.py on lines 1025..1032
          research/object_detection/core/target_assigner_test.py on lines 1033..1040
          research/object_detection/core/target_assigner_test.py on lines 1041..1048
          research/object_detection/core/target_assigner_test.py on lines 1107..1114
          research/object_detection/core/target_assigner_test.py on lines 1115..1122
          research/object_detection/core/target_assigner_test.py on lines 1123..1130
          research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1069..1072
          research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1159..1162
          research/object_detection/meta_architectures/ssd_meta_arch_test.py on lines 251..254
          research/object_detection/meta_architectures/ssd_meta_arch_test.py on lines 290..301

          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 24 locations. Consider refactoring.
          Open

              mask_content = [[[255, 255, 0, 0],
                               [255, 255, 0, 0],
                               [0, 0, 0, 0],
                               [0, 0, 0, 0]],
                              [[0, 255, 255, 255],
          Severity: Major
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 23 other locations - About 2 hrs to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 103..110
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 106..113
          research/object_detection/core/batch_multiclass_nms_test.py on lines 453..460
          research/object_detection/core/batch_multiclass_nms_test.py on lines 528..535
          research/object_detection/core/target_assigner_test.py on lines 534..541
          research/object_detection/core/target_assigner_test.py on lines 583..590
          research/object_detection/core/target_assigner_test.py on lines 591..598
          research/object_detection/core/target_assigner_test.py on lines 599..606
          research/object_detection/core/target_assigner_test.py on lines 658..665
          research/object_detection/core/target_assigner_test.py on lines 666..673
          research/object_detection/core/target_assigner_test.py on lines 674..681
          research/object_detection/core/target_assigner_test.py on lines 763..770
          research/object_detection/core/target_assigner_test.py on lines 970..977
          research/object_detection/core/target_assigner_test.py on lines 1025..1032
          research/object_detection/core/target_assigner_test.py on lines 1033..1040
          research/object_detection/core/target_assigner_test.py on lines 1041..1048
          research/object_detection/core/target_assigner_test.py on lines 1107..1114
          research/object_detection/core/target_assigner_test.py on lines 1115..1122
          research/object_detection/core/target_assigner_test.py on lines 1123..1130
          research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1069..1072
          research/object_detection/meta_architectures/faster_rcnn_meta_arch_test_lib.py on lines 1159..1162
          research/object_detection/meta_architectures/ssd_meta_arch_test.py on lines 251..254
          research/object_detection/meta_architectures/ssd_meta_arch_test.py on lines 290..301

          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

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

              self.assertNDArrayNear(
                  [0.25 * image_height * image_width, 0.75 * image_height * image_width],
                  results['groundtruth_area'], 1e-4)
          Severity: Major
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 2 other locations - About 1 hr to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 289..291
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 175..177

          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

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

              self.assertNDArrayNear(
                  [0.25 * image_height * image_width, 0.75 * image_height * image_width],
                  results['groundtruth_area'], 1e-4)
          Severity: Major
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 2 other locations - About 1 hr to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 198..200
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 175..177

          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

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

              masks = [
                  tfexample_utils.encode_image(np.uint8(m), fmt='PNG')
                  for m in list(mask_content)
          Severity: Minor
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 2 other locations - About 35 mins to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 111..113
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 114..116

          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 33.

          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 3 locations. Consider refactoring.
          Open

              masks = [
                  tfexample_utils.encode_image(np.uint8(m), fmt='PNG')
                  for m in list(mask_content)
          Severity: Minor
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 2 other locations - About 35 mins to fix
          official/vision/dataloaders/tf_example_decoder_test.py on lines 233..235
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 114..116

          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 33.

          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

              areas = [
                  0.25 * image_height * image_width, 0.75 * image_height * image_width
          Severity: Minor
          Found in official/vision/dataloaders/tf_example_decoder_test.py and 1 other location - About 30 mins to fix
          official/vision/dataloaders/tf_example_label_map_decoder_test.py on lines 102..103

          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 32.

          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