tensorflow/models

View on GitHub
research/object_detection/utils/config_util_test.py

Summary

Maintainability
F
1 wk
Test Coverage

File config_util_test.py has 880 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 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: Major
Found in research/object_detection/utils/config_util_test.py - About 2 days to fix

    ConfigUtilTest has 52 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ConfigUtilTest(tf.test.TestCase):
    
      def _create_and_load_test_configs(self, pipeline_config):
        pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
        _write_config(pipeline_config, pipeline_config_path)
    Severity: Major
    Found in research/object_detection/utils/config_util_test.py - About 7 hrs to fix

      Function _assertOptimizerWithNewLearningRate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def _assertOptimizerWithNewLearningRate(self, optimizer_name):
          """Asserts successful updating of all learning rate schemes."""
          original_learning_rate = 0.7
          learning_rate_scaling = 0.1
          warmup_learning_rate = 0.07
      Severity: Minor
      Found in research/object_detection/utils/config_util_test.py - About 1 hr to fix

        Function test_get_configs_from_multiple_files has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def test_get_configs_from_multiple_files(self):
            """Tests that proto configs can be read from multiple files."""
            temp_dir = self.get_temp_dir()
        
            # Write model config file.
        Severity: Minor
        Found in research/object_detection/utils/config_util_test.py - About 1 hr to fix

          Function testCheckAndParseInputConfigKey has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def testCheckAndParseInputConfigKey(self):
              pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
              pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
              pipeline_config.eval_input_reader.add().name = "eval_1"
              pipeline_config.eval_input_reader.add().name = "eval_2"
          Severity: Minor
          Found in research/object_detection/utils/config_util_test.py - About 1 hr to fix

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

              def testOverwriteAllEvalSampling(self):
                original_num_eval_examples = 1
                new_num_eval_examples = 10
            
                pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 1 day to fix
            research/object_detection/utils/config_util_test.py on lines 773..788

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

            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

              def testOverwriteAllEvalNumEpochs(self):
                original_num_epochs = 10
                new_num_epochs = 1
            
                pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 1 day to fix
            research/object_detection/utils/config_util_test.py on lines 753..771

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

            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

              @unittest.skipIf(tf_version.is_tf2(), "Skipping TF1.X only test.")
              def testNewBatchSize(self):
                """Tests that batch size is updated appropriately."""
                original_batch_size = 2
                hparams = contrib_training.HParams(batch_size=16)
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 1 day to fix
            research/object_detection/utils/config_util_test.py on lines 353..367

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

            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

              @unittest.skipIf(tf_version.is_tf2(), "Skipping TF1.X only test.")
              def testNewBatchSizeWithClipping(self):
                """Tests that batch size is clipped to 1 from below."""
                original_batch_size = 2
                hparams = contrib_training.HParams(batch_size=0.5)
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 1 day to fix
            research/object_detection/utils/config_util_test.py on lines 337..351

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

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

              def testTrainShuffle(self):
                """Tests that `train_shuffle` keyword arguments are applied correctly."""
                original_shuffle = True
                desired_shuffle = False
            
            
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 2 other locations - About 7 hrs to fix
            research/object_detection/utils/config_util_test.py on lines 733..751
            research/object_detection/utils/config_util_test.py on lines 949..970

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

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

              def testOverWriteRetainOriginalImages(self):
                """Tests that `train_shuffle` keyword arguments are applied correctly."""
                original_retain_original_images = True
                desired_retain_original_images = False
            
            
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 2 other locations - About 7 hrs to fix
            research/object_detection/utils/config_util_test.py on lines 716..731
            research/object_detection/utils/config_util_test.py on lines 949..970

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

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

              def testOverWriteRetainOriginalImageAdditionalChannels(self):
                """Tests that keyword arguments are applied correctly."""
                original_retain_original_image_additional_channels = True
                desired_retain_original_image_additional_channels = False
            
            
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 2 other locations - About 7 hrs to fix
            research/object_detection/utils/config_util_test.py on lines 716..731
            research/object_detection/utils/config_util_test.py on lines 733..751

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

            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

              def testGetSpatialImageSizeFromFixedShapeResizerConfig(self):
                image_resizer_config = image_resizer_pb2.ImageResizer()
                image_resizer_config.fixed_shape_resizer.height = 100
                image_resizer_config.fixed_shape_resizer.width = 200
                image_shape = config_util.get_spatial_image_size(image_resizer_config)
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 2 hrs to fix
            research/object_detection/utils/config_util_test.py on lines 673..678

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

            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

              def testGetSpatialImageSizeFromAspectPreservingResizerDynamic(self):
                image_resizer_config = image_resizer_pb2.ImageResizer()
                image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
                image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
                image_shape = config_util.get_spatial_image_size(image_resizer_config)
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 2 hrs to fix
            research/object_detection/utils/config_util_test.py on lines 658..663

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

            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

              def testGetContextFeatureLengthFromModelConfig(self):
                model_config = model_pb2.DetectionModel()
                model_config.faster_rcnn.context_config.context_feature_length = 100
                context_feature_length = config_util.get_context_feature_length(
                    model_config)
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 1 hr to fix
            research/object_detection/utils/config_util_test.py on lines 686..691

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

            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

              def testGetMaxNumContextFeaturesFromModelConfig(self):
                model_config = model_pb2.DetectionModel()
                model_config.faster_rcnn.context_config.max_num_context_features = 10
                max_num_context_features = config_util.get_max_num_context_features(
                    model_config)
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 1 hr to fix
            research/object_detection/utils/config_util_test.py on lines 693..698

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

            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

            def _write_config(config, config_path):
              """Writes a config object to disk."""
              config_text = text_format.MessageToString(config)
              with tf.gfile.Open(config_path, "wb") as f:
                f.write(config_text)
            Severity: Major
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 1 hr to fix
            research/lstm_object_detection/utils/config_util_test.py on lines 31..35

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

            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

                with self.assertRaisesRegexp(ValueError,
                                             "Duplicate input name found when overriding."):
                  config_util.update_input_reader_config(
            Severity: Minor
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 35 mins to fix
            research/object_detection/utils/config_util_test.py on lines 931..933

            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

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

                with self.assertRaisesRegexp(
                    ValueError, "Input name name_not_exist not found when overriding."):
                  config_util.update_input_reader_config(
            Severity: Minor
            Found in research/object_detection/utils/config_util_test.py and 1 other location - About 35 mins to fix
            research/object_detection/utils/config_util_test.py on lines 922..924

            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

            There are no issues that match your filters.

            Category
            Status