tensorflow/models

View on GitHub
official/projects/mosaic/modeling/mosaic_blocks.py

Summary

Maintainability
F
3 days
Test Coverage

File mosaic_blocks.py has 783 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/mosaic/modeling/mosaic_blocks.py - About 1 day to fix

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

      def __init__(
    Severity: Major
    Found in official/projects/mosaic/modeling/mosaic_blocks.py - About 1 hr to fix

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

        def __init__(
      Severity: Major
      Found in official/projects/mosaic/modeling/mosaic_blocks.py - About 1 hr to fix

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

          def build(
              self, input_shape: Union[tf.TensorShape, Dict[str,
                                                            tf.TensorShape]]) -> None:
            """Builds this MOSAIC encoder block with the given single input shape."""
            input_shape = (
        Severity: Minor
        Found in official/projects/mosaic/modeling/mosaic_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 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def __init__(
        Severity: Major
        Found in official/projects/mosaic/modeling/mosaic_blocks.py - About 1 hr to fix

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

            def __init__(
          Severity: Major
          Found in official/projects/mosaic/modeling/mosaic_blocks.py - About 1 hr to fix

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

              def call(self,
                       inputs: Union[tf.Tensor, Dict[str, tf.Tensor]],
                       training: Optional[bool] = None) -> tf.Tensor:
                """Calls this MOSAIC encoder block with the given input."""
                if training is None:
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_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: Tuple[tf.TensorShape, tf.TensorShape]) -> None:
                """Builds the block with the given input shape."""
                # Assume backbone features of the same level are concated before input.
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_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 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def __init__(
                  self,
                  encoder_input_level: Optional[Union[str, int]] = '4',
                  branch_filter_depths: Optional[List[int]] = None,
                  conv_kernel_sizes: Optional[List[int]] = None,
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_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: Tuple[tf.Tensor, tf.Tensor],
                       training: Optional[bool] = None) -> tf.Tensor:
                """Calls this decoder sum-merge block with the given input.
            
            
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_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 build has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def build(
                  self,
                  input_shape: Tuple[tf.TensorShape, tf.TensorShape]) -> None:
                """Builds this block with the given input shape."""
                # Assume backbone features of the same level are concated before input.
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_blocks.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def __init__(
                  self,
                  output_filter_depths: Optional[List[int]] = None,
                  kernel_sizes: Optional[List[int]] = None,
                  use_sync_bn: bool = False,
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_blocks.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 build has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def build(self, input_shape: tf.TensorShape) -> None:
                """Builds the block with the given input shape."""
                input_channels = input_shape[self._group_split_axis]
                if input_channels % self._num_groups != 0:
                  raise ValueError('The number of input channels must be divisible by '
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_blocks.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,
                       training: Optional[bool] = None) -> tf.Tensor:
                """Calls this group convolution block with the given inputs."""
                inputs_splits = tf.split(inputs,
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_blocks.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 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def call(self,
                       inputs: Tuple[tf.Tensor, tf.Tensor],
                       training: Optional[bool] = None) -> tf.Tensor:
                """Calls this concat-merge block with the given inputs.
            
            
            Severity: Minor
            Found in official/projects/mosaic/modeling/mosaic_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