tensorflow/models

View on GitHub
official/vision/modeling/layers/detection_generator.py

Summary

Maintainability
F
6 days
Test Coverage

File detection_generator.py has 1420 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/modeling/layers/detection_generator.py - About 3 days to fix

    Function __call__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def __call__(
          self,
          raw_boxes: Mapping[str, tf.Tensor],
          raw_scores: Mapping[str, tf.Tensor],
          anchor_boxes: Mapping[str, tf.Tensor],
    Severity: Minor
    Found in official/vision/modeling/layers/detection_generator.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 __init__ has 16 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(
    Severity: Major
    Found in official/vision/modeling/layers/detection_generator.py - About 2 hrs to fix

      Function _generate_detections_per_image has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def _generate_detections_per_image(
          boxes: tf.Tensor,
          scores: tf.Tensor,
          attributes: Optional[Mapping[str, tf.Tensor]] = None,
          pre_nms_top_k: int = 5000,
      Severity: Minor
      Found in official/vision/modeling/layers/detection_generator.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 _generate_detections_v1 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def _generate_detections_v1(
          boxes: tf.Tensor,
          scores: tf.Tensor,
          attributes: Optional[Mapping[str, tf.Tensor]] = None,
          pre_nms_top_k: int = 5000,
      Severity: Minor
      Found in official/vision/modeling/layers/detection_generator.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 __call__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def __call__(
            self,
            raw_boxes: tf.Tensor,
            raw_scores: tf.Tensor,
            anchor_boxes: tf.Tensor,
      Severity: Minor
      Found in official/vision/modeling/layers/detection_generator.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 _decode_multilevel_outputs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def _decode_multilevel_outputs(
            self,
            raw_boxes: Mapping[str, tf.Tensor],
            raw_scores: Mapping[str, tf.Tensor],
            anchor_boxes: Mapping[str, tf.Tensor],
      Severity: Minor
      Found in official/vision/modeling/layers/detection_generator.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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def __init__(
      Severity: Major
      Found in official/vision/modeling/layers/detection_generator.py - About 1 hr to fix

        Function _generate_detections_v1 has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _generate_detections_v1(
        Severity: Major
        Found in official/vision/modeling/layers/detection_generator.py - About 1 hr to fix

          Function _generate_detections_per_image has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def _generate_detections_per_image(
          Severity: Major
          Found in official/vision/modeling/layers/detection_generator.py - About 1 hr to fix

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

              def _decode_multilevel_outputs_and_pre_nms_top_k(
                  self,
                  raw_boxes: Mapping[str, tf.Tensor],
                  raw_scores: Mapping[str, tf.Tensor],
                  anchor_boxes: Mapping[str, tf.Tensor],
            Severity: Minor
            Found in official/vision/modeling/layers/detection_generator.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 __call__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def __call__(
            Severity: Major
            Found in official/vision/modeling/layers/detection_generator.py - About 50 mins to fix

              Function _generate_detections_v2 has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def _generate_detections_v2(
              Severity: Major
              Found in official/vision/modeling/layers/detection_generator.py - About 50 mins to fix

                Function _generate_detections_v2_class_aware has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def _generate_detections_v2_class_aware(
                Severity: Minor
                Found in official/vision/modeling/layers/detection_generator.py - About 45 mins to fix

                  Function _generate_detections_v2_class_agnostic has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def _generate_detections_v2_class_agnostic(
                  Severity: Minor
                  Found in official/vision/modeling/layers/detection_generator.py - About 45 mins to fix

                    Function _decode_multilevel_outputs has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def _decode_multilevel_outputs(
                    Severity: Minor
                    Found in official/vision/modeling/layers/detection_generator.py - About 45 mins to fix

                      Function _generate_detections_v3 has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def _generate_detections_v3(
                      Severity: Minor
                      Found in official/vision/modeling/layers/detection_generator.py - About 45 mins to fix

                        Function __call__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def __call__(
                        Severity: Minor
                        Found in official/vision/modeling/layers/detection_generator.py - About 45 mins to fix

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

                            def _decode_multilevel_outputs_and_pre_nms_top_k(
                          Severity: Minor
                          Found in official/vision/modeling/layers/detection_generator.py - About 35 mins to fix

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

                            def _generate_detections_batched(
                            Severity: Minor
                            Found in official/vision/modeling/layers/detection_generator.py - About 35 mins to fix

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

                              def _generate_detections_tflite(
                              Severity: Minor
                              Found in official/vision/modeling/layers/detection_generator.py - About 35 mins to fix

                                There are no issues that match your filters.

                                Category
                                Status