tensorflow/models

View on GitHub
official/vision/data/tf_example_builder_test.py

Summary

Maintainability
F
5 days
Test Coverage

File tf_example_builder_test.py has 557 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: Major
Found in official/vision/data/tf_example_builder_test.py - About 1 day to fix

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

      def test_add_image_matrix_feature_success(self, height, width, num_channels,
    Severity: Minor
    Found in official/vision/data/tf_example_builder_test.py - About 35 mins to fix

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

        def test_add_encoded_image_feature_success(self, miss_image_format,
      Severity: Minor
      Found in official/vision/data/tf_example_builder_test.py - About 35 mins to fix

        Function test_add_encoded_image_feature_success has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def test_add_encoded_image_feature_success(self, miss_image_format,
                                                     miss_height, miss_width,
                                                     miss_num_channels,
                                                     miss_label):
            height = 64
        Severity: Minor
        Found in official/vision/data/tf_example_builder_test.py - About 25 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

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

            self.assertProtoEquals(
                tf.train.Example(
                    features=tf.train.Features(
                        feature={
                            'image/object/bbox/xmin':
        Severity: Major
        Found in official/vision/data/tf_example_builder_test.py and 1 other location - About 1 day to fix
        official/vision/data/tf_example_builder_test.py on lines 302..321

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

        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

            self.assertProtoEquals(
                tf.train.Example(
                    features=tf.train.Features(
                        feature={
                            'image/object/bbox/xmin_pixels':
        Severity: Major
        Found in official/vision/data/tf_example_builder_test.py and 1 other location - About 1 day to fix
        official/vision/data/tf_example_builder_test.py on lines 267..286

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

        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

            expected_feature_dict = {
                'image/segmentation/class/encoded':
                    tf.train.Feature(
                        bytes_list=tf.train.BytesList(value=[
                            image_utils.encode_image(semantic_mask_np, image_format)
        Severity: Major
        Found in official/vision/data/tf_example_builder_test.py and 1 other location - About 3 hrs to fix
        official/vision/data/tf_example_builder_test.py on lines 463..473

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

        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

              expected_feature_dict.update({
                  'image/segmentation/class/visualization/encoded':
                      tf.train.Feature(
                          bytes_list=tf.train.BytesList(value=[
                              image_utils.encode_image(visualization_mask_np,
        Severity: Major
        Found in official/vision/data/tf_example_builder_test.py and 1 other location - About 3 hrs to fix
        official/vision/data/tf_example_builder_test.py on lines 448..457

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

        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

              expected_feature_dict.update({
                  'image/segmentation/class/visualization/encoded':
                      tf.train.Feature(
                          bytes_list=tf.train.BytesList(
                              value=[encoded_visualization_mask])),
        Severity: Major
        Found in official/vision/data/tf_example_builder_test.py and 1 other location - About 2 hrs to fix
        official/vision/data/tf_example_builder_test.py on lines 498..505

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 56.

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

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

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

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

        Refactorings

        Further Reading

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

            expected_feature_dict = {
                'image/segmentation/class/encoded':
                    tf.train.Feature(
                        bytes_list=tf.train.BytesList(value=[encoded_semantic_mask])),
                'image/segmentation/class/format':
        Severity: Major
        Found in official/vision/data/tf_example_builder_test.py and 1 other location - About 2 hrs to fix
        official/vision/data/tf_example_builder_test.py on lines 513..521

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 56.

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

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

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

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

        Refactorings

        Further Reading

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

          @parameterized.product(
              miss_image_format=(True, False),
              miss_height=(True, False),
              miss_width=(True, False),
              miss_num_channels=(True, False),
        Severity: Minor
        Found in official/vision/data/tf_example_builder_test.py and 1 other location - About 50 mins to fix
        official/vision/modeling/maskrcnn_model_test.py on lines 40..46

        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