tensorflow/tensorflow

View on GitHub
tensorflow/python/eager/polymorphic_function/polymorphic_function.py

Summary

Maintainability
F
6 days
Test Coverage

File polymorphic_function.py has 1317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2018 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/eager/polymorphic_function/polymorphic_function.py - About 3 days to fix

    Function has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Function(core.PolymorphicFunction, trackable.Trackable):
      """A `tf.types.experimental.PolymorphicFunction` created by `tf.function`.
    
      Currently, individual methods/attributes under this class are not guaranteed
      by the TF API contract, and are subject to future changes.
    Severity: Minor
    Found in tensorflow/python/eager/polymorphic_function/polymorphic_function.py - About 4 hrs to fix

      Function experimental_get_compiler_ir has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def experimental_get_compiler_ir(self, *args, **kwargs):
          # Implements PolymorphicFunction.experimental_get_compiler_ir
          context.ensure_initialized()
          if not self._jit_compile:
            raise ValueError("Compiler IR can only be returned for functions marked "
      Severity: Minor
      Found in tensorflow/python/eager/polymorphic_function/polymorphic_function.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 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def __init__(
            self,
            initial_value=None,
            trainable=None,
            caching_device=None,

      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 _initialize_uninitialized_variables has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def _initialize_uninitialized_variables(self, initializers):
          """Make and call a `ConcreteFunction` which initializes variables."""
      
          if not initializers:
            return

      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 function has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def function(

        Function _call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def _call(self, *args, **kwds):
            """Calls the graph function."""
            self._lock.acquire()
            bound_args = function_type_utils.canonicalize_function_inputs(
                args,

        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 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def __call__(self, *args, **kwds):
            # Implements PolymorphicFunction.__call__.
            if self._run_functions_eagerly:
              with trace.Trace(self._name, tf_function_call="eager"):
                return self._python_function(*args, **kwds)

        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 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def __init__(

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

            def _list_all_concrete_functions_for_serialization(self):
              """Returns all concrete functions for serialization.
          
              Returns:
                A list of instances of `ConcreteFunction`.

          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 _evaluate_var_is_initialized has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def _evaluate_var_is_initialized(variables):
            """Compute booleans indicating whether each variable is initialized."""
            with ops.init_scope():
              var_is_initialized = []
              for v in variables:

          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__(self,

            Avoid deeply nested control flow statements.
            Open

                        with ops.name_scope("Assign") as n, ops.colocate_with(self._handle):
                          self._initializer_op = resource_variable_ops.assign_variable_op(
                              self._handle, lifted_initializer, name=n)
                  elif context.executing_eagerly():
            Severity: Major
            Found in tensorflow/python/eager/polymorphic_function/polymorphic_function.py - About 45 mins to fix

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

                def called_with_tracing(self, function_name, omit_warning):
                  """Updates the list of most recent calls' tracing information.
              
                  Warns the user when recent calls caused retracing too often.
              
              
              Severity: Minor
              Found in tensorflow/python/eager/polymorphic_function/polymorphic_function.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

              Avoid too many return statements within this function.
              Open

                  return tracing_compilation.call_function(
              Severity: Major
              Found in tensorflow/python/eager/polymorphic_function/polymorphic_function.py - About 30 mins to fix

                Function function has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def function(
                    func=None,
                    input_signature=None,
                    autograph=True,
                    jit_compile=None,
                Severity: Minor
                Found in tensorflow/python/eager/polymorphic_function/polymorphic_function.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def __init__(self,
                               python_function,
                               name,
                               input_signature=None,
                               autograph=True,
                Severity: Minor
                Found in tensorflow/python/eager/polymorphic_function/polymorphic_function.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