tensorflow/models

View on GitHub
official/projects/waste_identification_ml/model_inference/postprocessing.py

Summary

Maintainability
D
1 day
Test Coverage

File postprocessing.py has 413 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

    Function find_similar_masks has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_similar_masks(
        results_1: DetectionResult,
        results_2: DetectionResult,
        num_detections: int,
        min_score_thresh: float,

    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 filter_bounding_boxes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def filter_bounding_boxes(
        bounding_boxes: List[Tuple[int, int, int, int]],
        iou_threshold: float = 0.5,
        area_ratio_threshold: float = 0.8,
    ) -> Tuple[List[Tuple[int, int, int, int]], List[int]]:

    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 find_similar_masks has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def find_similar_masks(

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

      def calculate_combined_scores_boxes_classes(

        Avoid deeply nested control flow statements.
        Open

                  if iou > iou_threshold:
                    aligned_masks += 1
                    is_similar = True
                    matched_masks_list2[j] = True
                    matched_masks_list1[i] = True

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

          def reframe_box_masks_to_image_masks(

            There are no issues that match your filters.

            Category
            Status