tensorflow/models

View on GitHub
research/object_detection/builders/box_predictor_builder.py

Summary

Maintainability
F
5 days
Test Coverage

File box_predictor_builder.py has 898 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/builders/box_predictor_builder.py - About 2 days to fix

    Function build_weight_shared_convolutional_keras_box_predictor has 23 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def build_weight_shared_convolutional_keras_box_predictor(
    Severity: Major
    Found in research/object_detection/builders/box_predictor_builder.py - About 2 hrs to fix

      Function build_convolutional_keras_box_predictor has 18 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def build_convolutional_keras_box_predictor(is_training,
      Severity: Major
      Found in research/object_detection/builders/box_predictor_builder.py - About 2 hrs to fix

        Function build_mask_rcnn_keras_box_predictor has 17 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def build_mask_rcnn_keras_box_predictor(is_training,
        Severity: Major
        Found in research/object_detection/builders/box_predictor_builder.py - About 2 hrs to fix

          Function build_weight_shared_convolutional_box_predictor has 17 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def build_weight_shared_convolutional_box_predictor(
          Severity: Major
          Found in research/object_detection/builders/box_predictor_builder.py - About 2 hrs to fix

            Function build_mask_rcnn_box_predictor has 16 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def build_mask_rcnn_box_predictor(is_training,
            Severity: Major
            Found in research/object_detection/builders/box_predictor_builder.py - About 2 hrs to fix

              Function build_convolutional_box_predictor has 15 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def build_convolutional_box_predictor(is_training,
              Severity: Major
              Found in research/object_detection/builders/box_predictor_builder.py - About 1 hr to fix

                Function build_keras has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                def build_keras(hyperparams_fn, freeze_batchnorm, inplace_batchnorm_update,
                                num_predictions_per_location_list, box_predictor_config,
                                is_training, num_classes, add_background_class=True):
                  """Builds a Keras-based box predictor based on the configuration.
                
                
                Severity: Minor
                Found in research/object_detection/builders/box_predictor_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 build has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                def build(argscope_fn, box_predictor_config, is_training, num_classes,
                          add_background_class=True):
                  """Builds box predictor based on the configuration.
                
                  Builds box predictor based on the configuration. See box_predictor.proto for
                Severity: Minor
                Found in research/object_detection/builders/box_predictor_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 build_keras has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def build_keras(hyperparams_fn, freeze_batchnorm, inplace_batchnorm_update,
                Severity: Major
                Found in research/object_detection/builders/box_predictor_builder.py - About 1 hr to fix

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

                  def build(argscope_fn, box_predictor_config, is_training, num_classes,
                  Severity: Minor
                  Found in research/object_detection/builders/box_predictor_builder.py - About 35 mins to fix

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

                      return convolutional_keras_box_predictor.ConvolutionalBoxPredictor(
                    Severity: Major
                    Found in research/object_detection/builders/box_predictor_builder.py and 1 other location - About 1 hr to fix
                    research/object_detection/builders/box_predictor_builder.py on lines 299..299

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

                      return convolutional_box_predictor.WeightSharedConvolutionalBoxPredictor(
                    Severity: Major
                    Found in research/object_detection/builders/box_predictor_builder.py and 1 other location - About 1 hr to fix
                    research/object_detection/builders/box_predictor_builder.py on lines 217..217

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

                      return convolutional_box_predictor.ConvolutionalBoxPredictor(
                    Severity: Minor
                    Found in research/object_detection/builders/box_predictor_builder.py and 1 other location - About 45 mins to fix
                    official/nlp/modeling/networks/xlnet_base.py on lines 701..701

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

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

                      box_prediction_head = keras_box_head.MaskRCNNBoxHead(
                    Severity: Major
                    Found in research/object_detection/builders/box_predictor_builder.py and 5 other locations - About 40 mins to fix
                    official/projects/assemblenet/modeling/assemblenet_plus_test.py on lines 66..66
                    official/vision/modeling/retinanet_model_test.py on lines 117..117
                    research/object_detection/models/keras_models/inception_resnet_v2_tf2_test.py on lines 146..146
                    research/object_detection/models/keras_models/mobilenet_v1_tf2_test.py on lines 103..103
                    research/object_detection/models/keras_models/mobilenet_v2_tf2_test.py on lines 94..94

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

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

                        if config_box_predictor.HasField('box_encodings_clip_range'):
                          box_encodings_clip_range = BoxEncodingsClipRange(
                              min=config_box_predictor.box_encodings_clip_range.min,
                              max=config_box_predictor.box_encodings_clip_range.max)
                    Severity: Major
                    Found in research/object_detection/builders/box_predictor_builder.py and 3 other locations - About 30 mins to fix
                    research/object_detection/builders/box_predictor_builder.py on lines 744..747
                    research/object_detection/builders/box_predictor_builder.py on lines 870..873
                    research/object_detection/builders/box_predictor_builder.py on lines 910..913

                    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

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

                        if config_box_predictor.HasField('box_encodings_clip_range'):
                          box_encodings_clip_range = BoxEncodingsClipRange(
                              min=config_box_predictor.box_encodings_clip_range.min,
                              max=config_box_predictor.box_encodings_clip_range.max)
                    Severity: Major
                    Found in research/object_detection/builders/box_predictor_builder.py and 3 other locations - About 30 mins to fix
                    research/object_detection/builders/box_predictor_builder.py on lines 707..710
                    research/object_detection/builders/box_predictor_builder.py on lines 870..873
                    research/object_detection/builders/box_predictor_builder.py on lines 910..913

                    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

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

                        if config_box_predictor.HasField('box_encodings_clip_range'):
                          box_encodings_clip_range = BoxEncodingsClipRange(
                              min=config_box_predictor.box_encodings_clip_range.min,
                              max=config_box_predictor.box_encodings_clip_range.max)
                    Severity: Major
                    Found in research/object_detection/builders/box_predictor_builder.py and 3 other locations - About 30 mins to fix
                    research/object_detection/builders/box_predictor_builder.py on lines 707..710
                    research/object_detection/builders/box_predictor_builder.py on lines 744..747
                    research/object_detection/builders/box_predictor_builder.py on lines 910..913

                    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

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

                        if config_box_predictor.HasField('box_encodings_clip_range'):
                          box_encodings_clip_range = BoxEncodingsClipRange(
                              min=config_box_predictor.box_encodings_clip_range.min,
                              max=config_box_predictor.box_encodings_clip_range.max)
                    Severity: Major
                    Found in research/object_detection/builders/box_predictor_builder.py and 3 other locations - About 30 mins to fix
                    research/object_detection/builders/box_predictor_builder.py on lines 707..710
                    research/object_detection/builders/box_predictor_builder.py on lines 744..747
                    research/object_detection/builders/box_predictor_builder.py on lines 870..873

                    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