tensorflow/models

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

Summary

Maintainability
F
4 days
Test Coverage

File nn_layers.py has 1132 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/nn_layers.py - About 2 days to fix

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

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

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

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

        Function _compute_attention has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def _compute_attention(
              self,
              query: tf.Tensor,
              key: tf.Tensor,
              value: tf.Tensor,
        Severity: Minor
        Found in official/vision/modeling/layers/nn_layers.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 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

            def __init__(
                self,
                min_level: int = 2,
                max_level: int = 5,
                target_level: int = 2,
          Severity: Minor
          Found in official/vision/modeling/layers/nn_layers.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 round_filters has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def round_filters(filters: int,
          Severity: Minor
          Found in official/vision/modeling/layers/nn_layers.py - About 45 mins to fix

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

              def __init__(self,
                           in_filters,
                           out_filters,
                           se_ratio,
                           divisible_by=1,
            Severity: Minor
            Found in official/vision/modeling/layers/nn_layers.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 _compute_attention has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

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

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

                  def call(self,
                           inputs: tf.Tensor,
                           training: Optional[bool] = None) -> tf.Tensor:
                    if training is None:
                      training = tf_keras.backend.learning_phase()
                Severity: Minor
                Found in official/vision/modeling/layers/nn_layers.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def call(self,
                           inputs: tf.Tensor,
                           states: Optional[States] = None,
                           output_states: bool = False
                           ) -> Union[tf.Tensor, Tuple[tf.Tensor, States]]:
                Severity: Minor
                Found in official/vision/modeling/layers/nn_layers.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