tensorflow/models

View on GitHub
research/object_detection/data_decoders/tf_sequence_example_decoder.py

Summary

Maintainability
D
2 days
Test Coverage

File tf_sequence_example_decoder.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2020 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

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

      def __init__(self,
    Severity: Minor
    Found in research/object_detection/data_decoders/tf_sequence_example_decoder.py - About 35 mins to fix

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

        def __init__(self,
      Severity: Minor
      Found in research/object_detection/data_decoders/tf_sequence_example_decoder.py - About 35 mins to fix

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

          def _reshape_context_features(self, keys_to_tensors):
            """Reshape context features.
        
            The instance context_features are reshaped to
              [num_context_features, context_feature_length]
        research/object_detection/data_decoders/tf_example_decoder.py on lines 892..910

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

        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

            name_to_id_table = hash_table_class(
                initializer=lookup.KeyValueTensorInitializer(
                    keys=tf.constant(list(name_to_id.keys())),
                    values=tf.constant(list(name_to_id.values()), dtype=tf.int64)),
        research/object_detection/data_decoders/tf_example_decoder.py on lines 103..106
        research/object_detection/data_decoders/tf_example_decoder.py on lines 112..116

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 59.

        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

            try:
              # Dynamically try to load the tf v2 lookup, falling back to contrib
              lookup = tf.compat.v2.lookup
              hash_table_class = tf.compat.v2.lookup.StaticHashTable
            except AttributeError:
        research/object_detection/builders/dataset_builder_test.py on lines 542..548
        research/object_detection/data_decoders/tf_example_decoder.py on lines 96..102
        research/object_detection/data_decoders/tf_example_decoder.py on lines 316..322

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

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

            tensor_dict[fields.InputDataFields.num_groundtruth_boxes] = tf.cast(
                tensor_dict[fields.InputDataFields.num_groundtruth_boxes],
                dtype=tf.int32)
        research/object_detection/data_decoders/tf_example_decoder.py on lines 709..711
        research/object_detection/data_decoders/tf_example_decoder.py on lines 712..714
        research/object_detection/data_decoders/tf_example_decoder.py on lines 716..719
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 271..272
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 302..305
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 302..308

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

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

            tensor_dict[fields.InputDataFields.groundtruth_classes] = tf.cast(
                tensor_dict[fields.InputDataFields.groundtruth_classes], dtype=tf.int32)
        research/object_detection/data_decoders/tf_example_decoder.py on lines 709..711
        research/object_detection/data_decoders/tf_example_decoder.py on lines 712..714
        research/object_detection/data_decoders/tf_example_decoder.py on lines 716..719
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 268..270
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 302..305
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 302..308

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

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

            if self._fully_annotated:
              tensor_dict[fields.InputDataFields.is_annotated] = tf.ones_like(
                  tensor_dict[fields.InputDataFields.num_groundtruth_boxes],
                  dtype=tf.bool)
        research/object_detection/data_decoders/tf_example_decoder.py on lines 709..711
        research/object_detection/data_decoders/tf_example_decoder.py on lines 712..714
        research/object_detection/data_decoders/tf_example_decoder.py on lines 716..719
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 268..270
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 271..272
        research/object_detection/data_decoders/tf_sequence_example_decoder.py on lines 302..308

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

        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