tensorflow/models

View on GitHub
official/nlp/modeling/networks/encoder_scaffold_test.py

Summary

Maintainability
F
3 days
Test Coverage

File encoder_scaffold_test.py has 603 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in official/nlp/modeling/networks/encoder_scaffold_test.py - About 1 day to fix

    Function test_hidden_cls_list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def test_hidden_cls_list(self):
        hidden_size = 32
        sequence_length = 10
        vocab_size = 57
    
    
    Severity: Minor
    Found in official/nlp/modeling/networks/encoder_scaffold_test.py - About 1 hr to fix

      Function test_serialize_deserialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def test_serialize_deserialize(self, use_hidden_cls_instance):
          hidden_size = 32
          sequence_length = 21
          vocab_size = 57
          num_types = 7
      Severity: Minor
      Found in official/nlp/modeling/networks/encoder_scaffold_test.py - About 1 hr to fix

        Function test_serialize_deserialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def test_serialize_deserialize(self):
            hidden_size = 32
            sequence_length = 21
            vocab_size = 57
        
        
        Severity: Minor
        Found in official/nlp/modeling/networks/encoder_scaffold_test.py - About 1 hr to fix

          Function test_network_creation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def test_network_creation(self, return_all_layer_outputs):
              hidden_size = 32
              sequence_length = 21
              num_hidden_instances = 3
              embedding_cfg = {
          Severity: Minor
          Found in official/nlp/modeling/networks/encoder_scaffold_test.py - About 1 hr to fix

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

              def get_config(self):
                config = super(ValidatedTransformerLayer, self).get_config()
                config["call_list"] = self.list
                config["call_class"] = tf_keras.utils.get_registered_name(self.call_class)
                return config
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 1 other location - About 2 hrs to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 66..70

            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 57.

            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 get_config(self):
                config = super(ValidatedMaskLayer, self).get_config()
                config["call_list"] = self.list
                config["call_class"] = tf_keras.utils.get_registered_name(self.call_class)
                return config
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 1 other location - About 2 hrs to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 42..46

            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 57.

            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 3 locations. Consider refactoring.
            Open

                test_network = encoder_scaffold.EncoderScaffold(
                    num_hidden_instances=3,
                    pooled_output_dim=hidden_size,
                    pooler_layer_initializer=tf_keras.initializers.TruncatedNormal(
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 2 other locations - About 1 hr to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 569..572
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 635..638

            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 38.

            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 3 locations. Consider refactoring.
            Open

                test_network = encoder_scaffold.EncoderScaffold(
                    num_hidden_instances=3,
                    pooled_output_dim=hidden_size,
                    pooler_layer_initializer=tf_keras.initializers.TruncatedNormal(
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 2 other locations - About 1 hr to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 248..251
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 635..638

            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 38.

            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 3 locations. Consider refactoring.
            Open

                test_network_a = encoder_scaffold.EncoderScaffold(
                    num_hidden_instances=3,
                    pooled_output_dim=hidden_size,
                    pooler_layer_initializer=tf_keras.initializers.TruncatedNormal(
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 2 other locations - About 1 hr to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 248..251
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 569..572

            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 38.

            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, call_list, call_class=None, **kwargs):
                super(ValidatedMaskLayer, self).__init__(**kwargs)
                self.list = call_list
                self.call_class = call_class
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 1 other location - About 1 hr to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 33..36

            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 38.

            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, call_list, call_class=None, **kwargs):
                super(ValidatedTransformerLayer, self).__init__(**kwargs)
                self.list = call_list
                self.call_class = call_class
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 1 other location - About 1 hr to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 57..60

            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 38.

            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

                network = encoder_scaffold.EncoderScaffold(
                    num_hidden_instances=3,
                    pooled_output_dim=hidden_size,
                    pooler_layer_initializer=tf_keras.initializers.TruncatedNormal(
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 3 other locations - About 45 mins to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 196..199
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 303..306
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 411..414

            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 35.

            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

                test_network = encoder_scaffold.EncoderScaffold(
                    num_hidden_instances=3,
                    pooled_output_dim=hidden_size,
                    pooler_layer_initializer=tf_keras.initializers.TruncatedNormal(
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 3 other locations - About 45 mins to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 196..199
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 303..306
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 342..345

            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 35.

            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

                test_network = encoder_scaffold.EncoderScaffold(
                    num_hidden_instances=3,
                    pooled_output_dim=hidden_size,
                    pooler_layer_initializer=tf_keras.initializers.TruncatedNormal(
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 3 other locations - About 45 mins to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 303..306
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 342..345
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 411..414

            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 35.

            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

                test_network = encoder_scaffold.EncoderScaffold(
                    num_hidden_instances=3,
                    pooled_output_dim=hidden_size,
                    pooler_layer_initializer=tf_keras.initializers.TruncatedNormal(
            Severity: Major
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 3 other locations - About 45 mins to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 196..199
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 342..345
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 411..414

            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 35.

            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

                hidden_cfg = {
                    "num_attention_heads":
                        2,
                    "intermediate_size":
                        3072,
            Severity: Minor
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 2 other locations - About 35 mins to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 543..557
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 610..624

            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 33.

            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

                hidden_cfg = {
                    "num_attention_heads":
                        2,
                    "intermediate_size":
                        3072,
            Severity: Minor
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 2 other locations - About 35 mins to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 102..116
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 610..624

            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 33.

            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

                hidden_cfg = {
                    "num_attention_heads":
                        2,
                    "intermediate_size":
                        3072,
            Severity: Minor
            Found in official/nlp/modeling/networks/encoder_scaffold_test.py and 2 other locations - About 35 mins to fix
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 102..116
            official/nlp/modeling/networks/encoder_scaffold_test.py on lines 543..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 33.

            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