tensorflow/models

View on GitHub
official/vision/modeling/maskrcnn_model_test.py

Summary

Maintainability
F
4 days
Test Coverage

File maskrcnn_model_test.py has 365 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/modeling/maskrcnn_model_test.py - About 4 hrs to fix

    Function test_forward has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def test_forward(self, strategy, include_mask, build_anchor_boxes, training,
                       use_cascade_heads):
        num_classes = 3
        min_level = 3
        max_level = 4
    Severity: Minor
    Found in official/vision/modeling/maskrcnn_model_test.py - About 2 hrs 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 test_build_model has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def test_build_model(self, include_mask, use_separable_conv,
                           build_anchor_boxes, use_outer_boxes, is_training):
        num_classes = 3
        min_level = 3
        max_level = 7
    Severity: Minor
    Found in official/vision/modeling/maskrcnn_model_test.py - About 1 hr to fix

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

        def test_build_model(self, include_mask, use_separable_conv,
                             build_anchor_boxes, use_outer_boxes, is_training):
          num_classes = 3
          min_level = 3
          max_level = 7
      Severity: Minor
      Found in official/vision/modeling/maskrcnn_model_test.py - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

        def test_build_model(self, include_mask, use_separable_conv,
      Severity: Minor
      Found in official/vision/modeling/maskrcnn_model_test.py - About 35 mins to fix

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

          def test_forward(self, strategy, include_mask, build_anchor_boxes, training,
        Severity: Minor
        Found in official/vision/modeling/maskrcnn_model_test.py - About 35 mins to fix

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

              if include_mask:
                mask_head = instance_heads.MaskHead(
                    num_classes=num_classes, upsample_factor=2)
                mask_sampler_obj = mask_sampler.MaskSampler(
                    mask_target_size=28, num_sampled_masks=1)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 1 other location - About 3 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 219..228

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

          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

              if include_mask:
                mask_head = instance_heads.MaskHead(num_classes=2, upsample_factor=2)
                mask_sampler_obj = mask_sampler.MaskSampler(
                    mask_target_size=28, num_sampled_masks=1)
                mask_roi_aligner_obj = roi_aligner.MultilevelROIAligner(crop_size=14)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 1 other location - About 3 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 358..366

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

          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

                if include_mask:
                  mask_head = instance_heads.MaskHead(
                      num_classes=num_classes, upsample_factor=2)
                  mask_sampler_obj = mask_sampler.MaskSampler(
                      mask_target_size=28, num_sampled_masks=1)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 1 other location - About 3 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 91..100

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

          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

              if include_mask:
                mask_head = instance_heads.MaskHead(num_classes=2, upsample_factor=2)
                mask_sampler_obj = mask_sampler.MaskSampler(
                    mask_target_size=28, num_sampled_masks=1)
                mask_roi_aligner_obj = roi_aligner.MultilevelROIAligner(crop_size=14)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 1 other location - About 3 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 306..314

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

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

              gt_boxes = np.array(
                  [[[10, 10, 15, 15], [2.5, 2.5, 7.5, 7.5], [-1, -1, -1, -1]],
                   [[100, 100, 150, 150], [-1, -1, -1, -1], [-1, -1, -1, -1]]],
                  dtype=np.float32)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 4 other locations - About 2 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 124..128
          official/vision/modeling/maskrcnn_model_test.py on lines 249..252
          official/vision/modeling/maskrcnn_model_test.py on lines 253..256
          research/object_detection/core/preprocessor_test.py on lines 153..163

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

                gt_outer_boxes = np.array(
                    [[[11, 11, 16.5, 16.5], [2.75, 2.75, 8.25, 8.25], [-1, -1, -1, -1]],
                     [[110, 110, 165, 165], [-1, -1, -1, -1], [-1, -1, -1, -1]]],
                    dtype=np.float32)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 4 other locations - About 2 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 119..122
          official/vision/modeling/maskrcnn_model_test.py on lines 124..128
          official/vision/modeling/maskrcnn_model_test.py on lines 249..252
          research/object_detection/core/preprocessor_test.py on lines 153..163

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

              if use_outer_boxes:
                gt_outer_boxes = np.array(
                    [[[11, 11, 16.5, 16.5], [2.75, 2.75, 8.25, 8.25], [-1, -1, -1, -1]],
                     [[110, 110, 165, 165], [-1, -1, -1, -1], [-1, -1, -1, -1]]],
                    dtype=np.float32)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 4 other locations - About 2 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 119..122
          official/vision/modeling/maskrcnn_model_test.py on lines 249..252
          official/vision/modeling/maskrcnn_model_test.py on lines 253..256
          research/object_detection/core/preprocessor_test.py on lines 153..163

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

                gt_boxes = np.array(
                    [[[10, 10, 15, 15], [2.5, 2.5, 7.5, 7.5], [-1, -1, -1, -1]],
                     [[100, 100, 150, 150], [-1, -1, -1, -1], [-1, -1, -1, -1]]],
                    dtype=np.float32)
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 4 other locations - About 2 hrs to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 119..122
          official/vision/modeling/maskrcnn_model_test.py on lines 124..128
          official/vision/modeling/maskrcnn_model_test.py on lines 253..256
          research/object_detection/core/preprocessor_test.py on lines 153..163

          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

                for l in anchor_boxes:
                  anchor_boxes[l] = tf.tile(
                      tf.expand_dims(anchor_boxes[l], axis=0), [2, 1, 1, 1])
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 2 other locations - About 1 hr to fix
          official/vision/modeling/retinanet_model_test.py on lines 96..98
          official/vision/modeling/retinanet_model_test.py on lines 178..180

          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

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

              model = maskrcnn_model.MaskRCNNModel(
                  backbone,
                  decoder,
                  rpn_head,
                  detection_head,
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 1 other location - About 1 hr to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 315..330

          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

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

              model = maskrcnn_model.MaskRCNNModel(
                  backbone,
                  decoder,
                  rpn_head,
                  detection_head,
          Severity: Major
          Found in official/vision/modeling/maskrcnn_model_test.py and 1 other location - About 1 hr to fix
          official/vision/modeling/maskrcnn_model_test.py on lines 367..382

          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

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

            @combinations.generate(
                combinations.combine(
                    include_mask=[True, False],
                    use_separable_conv=[True, False],
                    build_anchor_boxes=[True, False],
          Severity: Minor
          Found in official/vision/modeling/maskrcnn_model_test.py and 1 other location - About 50 mins to fix
          official/vision/data/tf_example_builder_test.py on lines 186..191

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

          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