rasa/utils/tensorflow/layers.py

Summary

Maintainability
F
5 days
Test Coverage
A
95%

File layers.py has 1226 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from typing import List, Optional, Text, Tuple, Callable, Union, Any
import tensorflow as tf

# TODO: The following is not (yet) available via tf.keras
Severity: Major
Found in rasa/utils/tensorflow/layers.py - About 3 days to fix

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

        def __init__(
    Severity: Major
    Found in rasa/utils/tensorflow/layers.py - About 1 hr to fix

      Function _loss_sigmoid has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _loss_sigmoid(
      Severity: Major
      Found in rasa/utils/tensorflow/layers.py - About 1 hr to fix

        Function _train_sim has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _train_sim(
        Severity: Major
        Found in rasa/utils/tensorflow/layers.py - About 1 hr to fix

          Function _accuracy has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _accuracy(
          Severity: Major
          Found in rasa/utils/tensorflow/layers.py - About 1 hr to fix

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

                def __init__(
            Severity: Major
            Found in rasa/utils/tensorflow/layers.py - About 1 hr to fix

              Function call has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def call(
              Severity: Major
              Found in rasa/utils/tensorflow/layers.py - About 50 mins to fix

                Function call has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def call(
                Severity: Major
                Found in rasa/utils/tensorflow/layers.py - About 50 mins to fix

                  Function _loss_cross_entropy has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def _loss_cross_entropy(
                  Severity: Major
                  Found in rasa/utils/tensorflow/layers.py - About 50 mins to fix

                    Function _loss_margin has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def _loss_margin(
                    Severity: Major
                    Found in rasa/utils/tensorflow/layers.py - About 50 mins to fix

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

                          def __init__(
                      Severity: Major
                      Found in rasa/utils/tensorflow/layers.py - About 50 mins to fix

                        Function _sample_candidates has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def _sample_candidates(
                        Severity: Minor
                        Found in rasa/utils/tensorflow/layers.py - About 45 mins to fix

                          Function _sample_negatives has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def _sample_negatives(
                          Severity: Minor
                          Found in rasa/utils/tensorflow/layers.py - About 45 mins to fix

                            Function _compute_softmax_loss has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def _compute_softmax_loss(
                            Severity: Minor
                            Found in rasa/utils/tensorflow/layers.py - About 45 mins to fix

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

                                  def _train_sim(
                              Severity: Minor
                              Found in rasa/utils/tensorflow/layers.py - About 35 mins to fix

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

                                    def __init__(
                                Severity: Minor
                                Found in rasa/utils/tensorflow/layers.py - About 35 mins to fix

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

                                      def _compute_sigmoid_loss(
                                  Severity: Minor
                                  Found in rasa/utils/tensorflow/layers.py - About 35 mins to fix

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

                                        def apply_mask_and_scaling(
                                            self, loss: tf.Tensor, mask: Optional[tf.Tensor]
                                        ) -> tf.Tensor:
                                            """Scales the loss and applies the mask if necessary.
                                    
                                    
                                    Severity: Minor
                                    Found in rasa/utils/tensorflow/layers.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