tensorflow/models

View on GitHub
official/projects/qat/vision/modeling/layers/nn_blocks.py

Summary

Maintainability
F
4 days
Test Coverage

File nn_blocks.py has 950 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/projects/qat/vision/modeling/layers/nn_blocks.py - About 2 days to fix

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

      def __init__(self,
    Severity: Major
    Found in official/projects/qat/vision/modeling/layers/nn_blocks.py - About 3 hrs to fix

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

        def __init__(
      Severity: Major
      Found in official/projects/qat/vision/modeling/layers/nn_blocks.py - About 3 hrs to fix

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

          def __init__(self,
        Severity: Major
        Found in official/projects/qat/vision/modeling/layers/nn_blocks.py - About 2 hrs to fix

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

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

            Function build has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def build(self, input_shape: Optional[Union[Sequence[int], tf.Tensor]]):
                """Build variables and child layers to prepare for calling."""
                expand_filters = self._in_filters
                if self._expand_ratio > 1:
                  # First 1x1 conv for channel expansion.
            Severity: Minor
            Found in official/projects/qat/vision/modeling/layers/nn_blocks.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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def __init__(
                  self,
                  in_filters: int,
                  out_filters: int,
                  expand_ratio: float,
            Severity: Minor
            Found in official/projects/qat/vision/modeling/layers/nn_blocks.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 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def __init__(
                  self,
                  in_filters: int,
                  out_filters: int,
                  expand_ratio: float,
            Severity: Minor
            Found in official/projects/qat/vision/modeling/layers/nn_blocks.py - About 1 hr to fix

              Function __init__ has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def __init__(self,
                             in_filters,
                             out_filters,
                             expand_ratio,
                             strides,
              Severity: Minor
              Found in official/projects/qat/vision/modeling/layers/nn_blocks.py - About 1 hr to fix

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

                  def call(
                      self,
                      inputs: tf.Tensor,
                      training: Optional[Union[bool, tf.Tensor]] = None
                  ) -> Union[tf.Tensor, Tuple[tf.Tensor, Dict[str, tf.Tensor]]]:
                Severity: Minor
                Found in official/projects/qat/vision/modeling/layers/nn_blocks.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 build has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  def build(self, input_shape):
                    # Starting depthwise conv.
                    if self._start_dw_kernel_size:
                      self._start_dw_conv = helper.DepthwiseConv2DQuantized(
                          kernel_size=self._start_dw_kernel_size,
                Severity: Minor
                Found in official/projects/qat/vision/modeling/layers/nn_blocks.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 build has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def build(self, input_shape: Optional[Union[Sequence[int], tf.Tensor]]):
                    """Build variables and child layers to prepare for calling."""
                    if self._use_projection:
                      if self._resnetd_shortcut:
                        self._shortcut0 = tf_keras.layers.AveragePooling2D(
                Severity: Minor
                Found in official/projects/qat/vision/modeling/layers/nn_blocks.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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def call(self, inputs, training=None):
                    shortcut = inputs
                    x = inputs
                    if self._start_dw_kernel_size:
                      x = self._start_dw_conv(x)
                Severity: Minor
                Found in official/projects/qat/vision/modeling/layers/nn_blocks.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def __init__(self,
                               in_filters,
                               out_filters,
                               expand_ratio,
                               strides,
                Severity: Minor
                Found in official/projects/qat/vision/modeling/layers/nn_blocks.py - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def call(
                      self,
                      inputs: tf.Tensor,
                      training: Optional[Union[bool, tf.Tensor]] = None) -> tf.Tensor:
                    """Run the BottleneckBlockQuantized logics."""
                Severity: Minor
                Found in official/projects/qat/vision/modeling/layers/nn_blocks.py - About 25 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