tensorflow/tensorflow

View on GitHub
tensorflow/python/ops/variable_scope.py

Summary

Maintainability
F
1 wk
Test Coverage

File variable_scope.py has 2288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2015 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 tensorflow/python/ops/variable_scope.py - About 6 days to fix

    Function _get_single_variable has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

      def _get_single_variable(self,
                               name,
                               shape=None,
                               dtype=dtypes.float32,
                               initializer=None,
    Severity: Minor
    Found in tensorflow/python/ops/variable_scope.py - About 6 hrs 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 _enter_scope_uncached has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

      def _enter_scope_uncached(self):
        """Enters the context manager when there is no cached scope yet.
    
        Returns:
          The entered variable scope.
    Severity: Minor
    Found in tensorflow/python/ops/variable_scope.py - About 5 hrs 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 _get_partitioned_variable has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

      def _get_partitioned_variable(self,
                                    name,
                                    partitioner,
                                    shape=None,
                                    dtype=dtypes.float32,
    Severity: Minor
    Found in tensorflow/python/ops/variable_scope.py - About 4 hrs 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 get_variable has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_variable(self,
                       name,
                       shape=None,
                       dtype=dtypes.float32,
                       initializer=None,
    Severity: Minor
    Found in tensorflow/python/ops/variable_scope.py - About 3 hrs 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 __enter__ has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def __enter__(self):
        """Begins the scope block.
    
        Returns:
          A VariableScope.
    Severity: Minor
    Found in tensorflow/python/ops/variable_scope.py - About 3 hrs 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

    VariableScope has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class VariableScope:
      """Variable scope object to carry defaults to provide to `get_variable`.
    
      Many of the arguments we need for `get_variable` in a variable store are most
      easily handled with a context. This object is used for the defaults.
    Severity: Minor
    Found in tensorflow/python/ops/variable_scope.py - About 3 hrs to fix

      Function get_variable has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_variable(self,
                         var_store,
                         name,
                         shape=None,
                         dtype=None,
      Severity: Minor
      Found in tensorflow/python/ops/variable_scope.py - About 2 hrs 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 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def __init__(self,
                     name_or_scope,
                     reuse=None,
                     initializer=None,
                     regularizer=None,
      Severity: Minor
      Found in tensorflow/python/ops/variable_scope.py - About 2 hrs 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 get_variable has 17 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def get_variable(self,
      Severity: Major
      Found in tensorflow/python/ops/variable_scope.py - About 2 hrs to fix

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

        def get_local_variable(  # pylint: disable=missing-docstring
        Severity: Major
        Found in tensorflow/python/ops/variable_scope.py - About 2 hrs to fix

          Function get_variable has 16 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def get_variable(self,
          Severity: Major
          Found in tensorflow/python/ops/variable_scope.py - About 2 hrs to fix

            Function _get_partitioned_variable has 15 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def _get_partitioned_variable(self,
            Severity: Major
            Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

              Function get_variable has 15 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def get_variable(name,
              Severity: Major
              Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

                Function _true_getter has 15 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def _true_getter(  # pylint: disable=missing-docstring
                Severity: Major
                Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

                  Function _get_partitioned_variable has 15 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def _get_partitioned_variable(self,
                  Severity: Major
                  Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

                    Function _get_single_variable has 15 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def _get_single_variable(self,
                    Severity: Major
                    Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

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

                      def _get_partitioned_variable(name,
                      Severity: Major
                      Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

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

                          def __init__(self,
                        Severity: Major
                        Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

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

                          def variable_op_scope(values,
                          Severity: Major
                          Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

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

                              def __init__(self,
                            Severity: Major
                            Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

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

                                def __init__(self,
                              Severity: Major
                              Found in tensorflow/python/ops/variable_scope.py - About 1 hr to fix

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

                                  def __enter__(self):
                                    # If the default graph is building a function, then we should not replace it
                                    # with the cached graph.
                                    if ops.get_default_graph().building_function:
                                      self._building_function = True
                                Severity: Minor
                                Found in tensorflow/python/ops/variable_scope.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 _get_partitioned_variable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def _get_partitioned_variable(self,
                                                                var_store,
                                                                name,
                                                                shape=None,
                                                                dtype=None,
                                Severity: Minor
                                Found in tensorflow/python/ops/variable_scope.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 single_slice_dim has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def single_slice_dim(self, shape):
                                    """Returns the slice dim when the variable is partitioned only in one dim.
                                
                                    Args:
                                      shape: Tuple or list of `int` indicating the shape of one specific
                                Severity: Minor
                                Found in tensorflow/python/ops/variable_scope.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 close_variable_subscopes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def close_variable_subscopes(self, scope_name):
                                    if scope_name is None:
                                      for k in self.variable_scopes_count:
                                        self.variable_scopes_count[k] = 0
                                    else:
                                Severity: Minor
                                Found in tensorflow/python/ops/variable_scope.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 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def __init__(self,
                                               name_or_scope,
                                               default_name=None,
                                               values=None,
                                               initializer=None,
                                Severity: Minor
                                Found in tensorflow/python/ops/variable_scope.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, full_shape, var_offset):
                                    """Constructor.
                                
                                    Args:
                                      full_shape: Tuple or list of `int` indicating the full combined shape of
                                Severity: Minor
                                Found in tensorflow/python/ops/variable_scope.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_partitioner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def _call_partitioner(partitioner, shape, dtype):
                                  """Call partitioner validating its inputs/output.
                                
                                  Args:
                                    partitioner: a function mapping `Tensor` shape and dtype to a list of
                                Severity: Minor
                                Found in tensorflow/python/ops/variable_scope.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