tensorflow/models

View on GitHub
official/projects/yt8m/dataloaders/yt8m_input.py

Summary

Maintainability
D
1 day
Test Coverage

File yt8m_input.py has 440 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/projects/yt8m/dataloaders/yt8m_input.py - About 6 hrs to fix

    Function __init__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def __init__(
          self,
          input_params: exp_cfg.DataConfig,
      ):
    
    
    Severity: Minor
    Found in official/projects/yt8m/dataloaders/yt8m_input.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 parse_fn has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_fn(self, is_training):
        """Returns a parse fn that reads and parses raw tensors from the decoder.
    
        Args:
          is_training: a `bool` to indicate whether it is in training mode.
    Severity: Minor
    Found in official/projects/yt8m/dataloaders/yt8m_input.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 _concat_features has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _concat_features(
    Severity: Major
    Found in official/projects/yt8m/dataloaders/yt8m_input.py - About 1 hr to fix

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

      def _get_video_matrix(features, feature_size, dtype, max_frames,
      Severity: Minor
      Found in official/projects/yt8m/dataloaders/yt8m_input.py - About 45 mins to fix

        Function _process_segment_and_label has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def _process_segment_and_label(video_matrix, num_frames, contexts,
                                       segment_labels, segment_size,
                                       num_classes) -> Dict[str, tf.Tensor]:
          """Processes a batched Tensor of frames.
        
        
        Severity: Minor
        Found in official/projects/yt8m/dataloaders/yt8m_input.py - About 45 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 _process_segment_and_label has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _process_segment_and_label(video_matrix, num_frames, contexts,
        Severity: Minor
        Found in official/projects/yt8m/dataloaders/yt8m_input.py - About 45 mins to fix

          Function decode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def decode(self,
                       serialized_example: tf.train.SequenceExample) -> Dict[str, Any]:
              """Parses a single tf.train.SequenceExample into video and label tensors."""
              contexts, features = tf.io.parse_single_sequence_example(
                  serialized_example,
          Severity: Minor
          Found in official/projects/yt8m/dataloaders/yt8m_input.py - About 35 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 post_fn has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def post_fn(self, batched_tensors: Dict[str,
                                                    tf.Tensor]) -> Dict[str, tf.Tensor]:
              """Processes batched Tensors."""
              video_ids = batched_tensors.get("video_ids", None)
              video_matrix = batched_tensors["video_matrix"]
          Severity: Minor
          Found in official/projects/yt8m/dataloaders/yt8m_input.py - About 35 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

          There are no issues that match your filters.

          Category
          Status