tensorflow/models

View on GitHub
research/seq_flow_lite/layers/transformer_layers.py

Summary

Maintainability
F
1 wk
Test Coverage

File transformer_layers.py has 583 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2020 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 research/seq_flow_lite/layers/transformer_layers.py - About 1 day to fix

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

      def call(self,
               inputs,
               input_mask,
               input_inverse_normalizer,
               memory=None,
    Severity: Minor
    Found in research/seq_flow_lite/layers/transformer_layers.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 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(self, num_layers, max_time_step, vocabulary_size, embedding_size,
    Severity: Major
    Found in research/seq_flow_lite/layers/transformer_layers.py - About 1 hr to fix

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

        def __init__(self, num_layers, max_time_step, vocabulary_size, embedding_size,
      Severity: Major
      Found in research/seq_flow_lite/layers/transformer_layers.py - About 1 hr to fix

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

          def call(self, inputs, mask, inverse_normalizer, attn_mask=None):
            bsz = self.get_batch_dimension(inputs)
            self._assert_rank_and_type(inputs, 3)
            self._assert_rank_and_type(mask, 3)
            assert inputs.get_shape().as_list()[-1] == self.model_dimension
        Severity: Minor
        Found in research/seq_flow_lite/layers/transformer_layers.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 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def call(self,
        Severity: Major
        Found in research/seq_flow_lite/layers/transformer_layers.py - About 50 mins to fix

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

            def __init__(self,
          Severity: Major
          Found in research/seq_flow_lite/layers/transformer_layers.py - About 50 mins to fix

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

              def __init__(self,
            Severity: Major
            Found in research/seq_flow_lite/layers/transformer_layers.py - About 50 mins to fix

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

                def call(self, inputs, mask, inverse_normalizer, memory, memory_mask,
              Severity: Major
              Found in research/seq_flow_lite/layers/transformer_layers.py - About 50 mins to fix

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

                  def call(self, inputs, mask, inverse_normalizer, memory, memory_mask,
                Severity: Major
                Found in research/seq_flow_lite/layers/transformer_layers.py - About 50 mins to fix

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

                    def call(self,
                  Severity: Major
                  Found in research/seq_flow_lite/layers/transformer_layers.py - About 50 mins to fix

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

                      def call(self, inputs, mask, inverse_normalizer, attn_mask=None):
                        batch_size = self.get_batch_dimension(inputs)
                        self._assert_rank_and_type(inputs, 3)
                        self._assert_rank_and_type(mask, 3)
                        assert inputs.get_shape().as_list()[-1] == self.model_dimension
                    Severity: Minor
                    Found in research/seq_flow_lite/layers/transformer_layers.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 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def __init__(self,
                    Severity: Minor
                    Found in research/seq_flow_lite/layers/transformer_layers.py - About 35 mins to fix

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

                        def __init__(self,
                      Severity: Minor
                      Found in research/seq_flow_lite/layers/transformer_layers.py - About 35 mins to fix

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

                          def call(self, inputs, mask, inverse_normalizer, memory, memory_mask,
                                   memory_inverse_normalizer, attn_mask):
                            bsz = self.get_batch_dimension(inputs)
                            self._assert_rank_and_type(inputs, 3)
                            self._assert_rank_and_type(mask, 3)
                        Severity: Minor
                        Found in research/seq_flow_lite/layers/transformer_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

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def __init__(self,
                                       model_dimension,
                                       num_heads,
                                       intermediate_size,
                                       initializer_stddev=0.02,
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 1 other location - About 1 day to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 381..408

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 201.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def __init__(self,
                                       model_dimension,
                                       num_heads,
                                       intermediate_size,
                                       initializer_stddev=0.02,
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 1 other location - About 1 day to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 171..198

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 201.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.TFLITE, base_layers.PREDICT]:
                              q_tensor = tf.reshape(q_tensor, [bsz, -1, self.num_heads, self.filters])
                              kv_tensors = tf.reshape(kv_tensors,
                                                      [bsz, -1, 2, self.num_heads, self.filters])
                              kv_tensors = tf.unstack(kv_tensors, axis=2)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 1 other location - About 1 day to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 337..344

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 122.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.TFLITE, base_layers.PREDICT]:
                              q_tensor = tf.reshape(q_tensor, [bsz, -1, self.num_heads, self.filters])
                              kv_tensors = tf.reshape(kv_tensors,
                                                      [bsz, -1, 2, self.num_heads, self.filters])
                              kv_tensors = tf.unstack(kv_tensors, axis=2)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 1 other location - About 1 day to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 550..557

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 122.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                            if (self.parameters.mode == base_layers.TRAIN and
                                self.activation_dropout_rate > 0.0):
                              ffn_down = tf.nn.dropout(ffn_down, rate=self.activation_dropout_rate)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 3 other locations - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 211..213
                        research/seq_flow_lite/layers/transformer_layers.py on lines 218..220
                        research/seq_flow_lite/layers/transformer_layers.py on lines 423..425

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                            if (self.parameters.mode == base_layers.TRAIN and
                                self.activation_dropout_rate > 0.0):
                              ffn_down = tf.nn.dropout(ffn_down, rate=self.activation_dropout_rate)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 3 other locations - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 211..213
                        research/seq_flow_lite/layers/transformer_layers.py on lines 423..425
                        research/seq_flow_lite/layers/transformer_layers.py on lines 430..432

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                            if (self.parameters.mode == base_layers.TRAIN and
                                self.activation_dropout_rate > 0.0):
                              tensor = tf.nn.dropout(tensor, rate=self.activation_dropout_rate)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 3 other locations - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 211..213
                        research/seq_flow_lite/layers/transformer_layers.py on lines 218..220
                        research/seq_flow_lite/layers/transformer_layers.py on lines 430..432

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                            if (self.parameters.mode == base_layers.TRAIN and
                                self.activation_dropout_rate > 0.0):
                              tensor = tf.nn.dropout(tensor, rate=self.activation_dropout_rate)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 3 other locations - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 218..220
                        research/seq_flow_lite/layers/transformer_layers.py on lines 423..425
                        research/seq_flow_lite/layers/transformer_layers.py on lines 430..432

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 48.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                              if (self.attention_dropout_rate > 0.0 and
                                  self.parameters.mode == base_layers.TRAIN):
                                attn_mask *= self.random_drop_to_zero(attn_mask,
                                                                      self.attention_dropout_rate)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 2 other locations - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 69..72
                        research/seq_flow_lite/layers/transformer_layers.py on lines 132..135

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 45.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                            if (self.attention_dropout_rate > 0.0 and
                                self.parameters.mode == base_layers.TRAIN):
                              attn_mask *= self.random_drop_to_zero(attn_mask,
                                                                    self.attention_dropout_rate)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 2 other locations - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 69..72
                        research/seq_flow_lite/layers/transformer_layers.py on lines 561..564

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 45.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                            if (self.attention_dropout_rate > 0.0 and
                                self.parameters.mode == base_layers.TRAIN):
                              attn_mask *= self.random_drop_to_zero(attn_mask,
                                                                    self.attention_dropout_rate)
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 2 other locations - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 132..135
                        research/seq_flow_lite/layers/transformer_layers.py on lines 561..564

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 45.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            for _ in range(num_layers):
                              self.layers.append(
                                  FunnelTransformerEncoder(
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 1 other location - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 236..238

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 41.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            for _ in range(num_layers):
                              self.layers.append(
                                  TransformerEncoder(
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 1 other location - About 1 hr to fix
                        research/seq_flow_lite/layers/transformer_layers.py on lines 449..451

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 41.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 7 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.PREDICT, base_layers.TFLITE]:
                              inputs = inputs * mask_rank3
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 6 other locations - About 30 mins to fix
                        research/seq_flow_lite/layers/qrnn_layers.py on lines 433..434
                        research/seq_flow_lite/layers/transformer_layers.py on lines 270..271
                        research/seq_flow_lite/layers/transformer_layers.py on lines 275..276
                        research/seq_flow_lite/layers/transformer_layers.py on lines 294..295
                        research/seq_flow_lite/layers/transformer_layers.py on lines 464..465
                        research/seq_flow_lite/layers/transformer_layers.py on lines 491..492

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 7 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.PREDICT, base_layers.TFLITE]:
                              inputs = inputs * mask_rank3
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 6 other locations - About 30 mins to fix
                        research/seq_flow_lite/layers/qrnn_layers.py on lines 433..434
                        research/seq_flow_lite/layers/transformer_layers.py on lines 270..271
                        research/seq_flow_lite/layers/transformer_layers.py on lines 275..276
                        research/seq_flow_lite/layers/transformer_layers.py on lines 289..290
                        research/seq_flow_lite/layers/transformer_layers.py on lines 294..295
                        research/seq_flow_lite/layers/transformer_layers.py on lines 491..492

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 7 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.PREDICT, base_layers.TFLITE]:
                              inputs = inputs * mask_rank3
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 6 other locations - About 30 mins to fix
                        research/seq_flow_lite/layers/qrnn_layers.py on lines 433..434
                        research/seq_flow_lite/layers/transformer_layers.py on lines 275..276
                        research/seq_flow_lite/layers/transformer_layers.py on lines 289..290
                        research/seq_flow_lite/layers/transformer_layers.py on lines 294..295
                        research/seq_flow_lite/layers/transformer_layers.py on lines 464..465
                        research/seq_flow_lite/layers/transformer_layers.py on lines 491..492

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 7 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.PREDICT, base_layers.TFLITE]:
                              outputs = outputs * mask_rank3
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 6 other locations - About 30 mins to fix
                        research/seq_flow_lite/layers/qrnn_layers.py on lines 433..434
                        research/seq_flow_lite/layers/transformer_layers.py on lines 270..271
                        research/seq_flow_lite/layers/transformer_layers.py on lines 289..290
                        research/seq_flow_lite/layers/transformer_layers.py on lines 294..295
                        research/seq_flow_lite/layers/transformer_layers.py on lines 464..465
                        research/seq_flow_lite/layers/transformer_layers.py on lines 491..492

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 7 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.PREDICT, base_layers.TFLITE]:
                              outputs = outputs * mask_rank3
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 6 other locations - About 30 mins to fix
                        research/seq_flow_lite/layers/qrnn_layers.py on lines 433..434
                        research/seq_flow_lite/layers/transformer_layers.py on lines 270..271
                        research/seq_flow_lite/layers/transformer_layers.py on lines 275..276
                        research/seq_flow_lite/layers/transformer_layers.py on lines 289..290
                        research/seq_flow_lite/layers/transformer_layers.py on lines 464..465
                        research/seq_flow_lite/layers/transformer_layers.py on lines 491..492

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 7 locations. Consider refactoring.
                        Open

                            if self.parameters.mode not in [base_layers.PREDICT, base_layers.TFLITE]:
                              pooled_outputs = pooled_outputs * pooled_mask
                        Severity: Major
                        Found in research/seq_flow_lite/layers/transformer_layers.py and 6 other locations - About 30 mins to fix
                        research/seq_flow_lite/layers/qrnn_layers.py on lines 433..434
                        research/seq_flow_lite/layers/transformer_layers.py on lines 270..271
                        research/seq_flow_lite/layers/transformer_layers.py on lines 275..276
                        research/seq_flow_lite/layers/transformer_layers.py on lines 289..290
                        research/seq_flow_lite/layers/transformer_layers.py on lines 294..295
                        research/seq_flow_lite/layers/transformer_layers.py on lines 464..465

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 32.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        There are no issues that match your filters.

                        Category
                        Status