tensorflow/tensorflow

View on GitHub
tensorflow/python/distribute/mirrored_strategy_test.py

Summary

Maintainability
F
3 wks
Test Coverage

File mirrored_strategy_test.py has 1226 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/distribute/mirrored_strategy_test.py - About 3 days to fix

    MirroredTwoDeviceDistributionTest has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MirroredTwoDeviceDistributionTest(
        strategy_test_lib.DistributionTestBase,
        strategy_test_lib.TwoDeviceDistributionTestBase,
        parameterized.TestCase):
    
    
    Severity: Minor
    Found in tensorflow/python/distribute/mirrored_strategy_test.py - About 3 hrs to fix

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

        def testReduceAxisToCpuUnknownShape(self, distribution):
          if not distribution.extended._use_merge_call():
            self.skipTest("Collective all-reduce does not support int32 on GPU.")
          original_v2 = tensor_shape._TENSORSHAPE_V2_OVERRIDE  # pylint: disable=protected-access
          try:
      Severity: Minor
      Found in tensorflow/python/distribute/mirrored_strategy_test.py - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

        def testBackwardFunctionDevicePlacement(self, distribution):
          with distribution.scope():
            w = variable_v1.VariableV1([1.5], name="w")
            b = variable_v1.VariableV1([0.5], name="b")
      
      
      Severity: Minor
      Found in tensorflow/python/distribute/mirrored_strategy_test.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 testNameScopeWithGetVariable(self, distribution):
          def in_cross_replica(_):
            c = variable_scope.get_variable("c", [1])
            return c
      
      
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 2 days to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 833..861

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

      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 testVariableScopeWithGetVariable(self, distribution):
      
          def in_cross_replica(_):
            c = variable_scope.get_variable("c", [1])
            return c
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 2 days to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 804..831

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

      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

        def testAssignMirroredVarReplicaContext(self, distribution):
          def var_fn():
            return variable_v1.VariableV1(
                1.0, name="foo", aggregation=variable_scope.VariableAggregation.MEAN)
      
      
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1040..1059
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1103..1122

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

      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

        def testAssignSubMirroredVarReplicaContext(self, distribution):
          def var_fn():
            return variable_v1.VariableV1(
                5.0, name="foo", aggregation=variable_scope.VariableAggregation.MEAN)
      
      
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 959..978
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1040..1059

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

      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

        def testAssignAddMirroredVarReplicaContext(self, distribution):
          def var_fn():
            return variable_v1.VariableV1(
                1.0, name="foo", aggregation=variable_scope.VariableAggregation.MEAN)
      
      
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 959..978
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1103..1122

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

      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 testAssignReplicaLocalVarSumAggregation(self, distribution):
          def model_fn():
            v_sum = variable_v1.VariableV1(
                1.0,
                synchronization=variable_scope.VariableSynchronization.ON_READ,
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1222..1244

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

      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 testAssignReplicaLocalVarMeanAggregation(self, distribution):
          def model_fn():
            v_sum = variable_v1.VariableV1(
                1.0,
                synchronization=variable_scope.VariableSynchronization.ON_READ,
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1195..1220

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

      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

        def testAssignSubMirroredVarReplicaContextWithSingleValue(self, distribution):
          def var_fn():
            return variable_v1.VariableV1(
                5.0, name="foo", aggregation=variable_scope.VariableAggregation.MEAN)
      
      
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 980..996
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1061..1077

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

      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

        def testAssignAddMirroredVarReplicaContextWithSingleValue(self, distribution):
          def var_fn():
            return variable_v1.VariableV1(
                1.0, name="foo", aggregation=variable_scope.VariableAggregation.MEAN)
      
      
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 980..996
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1124..1140

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

      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

        def testAssignMirroredVarReplicaContextWithSingleValue(self, distribution):
          def var_fn():
            return variable_v1.VariableV1(
                1.0, name="foo", aggregation=variable_scope.VariableAggregation.MEAN)
      
      
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 1 day to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1061..1077
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1124..1140

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

      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

            with ops.name_scope("main"):
              result = distribution.extended.call_for_each_replica(model_fn)
              self.assertEqual(2, len(result))
              for v, name in zip(result, ["a", "b"]):
                self.assertIsInstance(v, values.DistributedValues)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 7 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 761..768

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

      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

          with context.graph_mode(), distribution.scope():
            result = distribution.extended.call_for_each_replica(model_fn)
            self.assertEqual(2, len(result))
            for v, name in zip(result, ["a", "b"]):
              self.assertIsInstance(v, values.DistributedValues)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 7 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 744..751

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

      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

            with distribution.scope():
              sync_on_read_var = distribution.extended.call_for_each_replica(
                  model_fn)
              self.assertTrue(distribute_utils.is_sync_on_read(sync_on_read_var))
              self.assertFalse(self.evaluate(sync_on_read_var.is_initialized()))
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 4 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1159..1164

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

      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

            with distribution.scope():
              mirrored_var = distribution.extended.call_for_each_replica(var_fn)
              self.assertTrue(distribute_utils.is_mirrored(mirrored_var))
              self.assertFalse(self.evaluate(mirrored_var.is_initialized()))
              self.evaluate(mirrored_var.initializer)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 4 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 1178..1184

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

      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

          with distribution.scope():
            result = distribution.extended.call_for_each_replica(_replica_id)
            reduced = distribution.reduce(reduce_util.ReduceOp.SUM, result, axis=None)
            expected = sum(range(distribution.num_replicas_in_sync))
            self.assertEqual(expected, self.evaluate(reduced))
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 3 hrs to fix
      tensorflow/python/distribute/collective_all_reduce_strategy_test.py on lines 549..553

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

      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

          with func_graph.FuncGraph("fg").as_default(), distribution.scope():
            in_scope = ops.executing_eagerly_outside_functions()
            in_model_fn = distribution.extended.call_for_each_replica(model_fn)
            unwrapped = distribution.experimental_local_results(in_model_fn)
            self.assertEqual(in_scope, unwrapped[0])
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 3 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 603..608

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

      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

          with distribution.scope():
            in_scope = ops.executing_eagerly_outside_functions()
            in_model_fn = distribution.extended.call_for_each_replica(model_fn)
            unwrapped = distribution.experimental_local_results(in_model_fn)
            self.assertEqual(in_scope, unwrapped[0])
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 3 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 611..616

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

      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

            if ops.executing_eagerly_outside_functions():
              self.assertIsInstance(
                  strategy.extended._collective_ops,
                  cross_device_ops_lib.CollectiveAllReduce)
              self.assertEqual(
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 3 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 320..329

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

      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

            if ops.executing_eagerly_outside_functions():
              self.assertIsInstance(
                  strategy.extended._collective_ops,
                  cross_device_ops_lib.CollectiveAllReduce)
              self.assertEqual(
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 3 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 365..374

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

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

          if context.executing_eagerly():
            item = next(iter(dataset))
          else:
            if isinstance(dataset, input_lib_v1.DistributedDatasetV1):
              item = dataset.make_initializable_iterator().get_next()
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 3 other locations - About 2 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 292..298
      tensorflow/python/distribute/one_device_strategy_test.py on lines 126..132
      tensorflow/python/distribute/one_device_strategy_test.py on lines 147..153

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

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

          if context.executing_eagerly():
            item = next(iter(dataset))
          else:
            if isinstance(dataset, input_lib_v1.DistributedDatasetV1):
              item = dataset.make_initializable_iterator().get_next()
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 3 other locations - About 2 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 270..276
      tensorflow/python/distribute/one_device_strategy_test.py on lines 126..132
      tensorflow/python/distribute/one_device_strategy_test.py on lines 147..153

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

      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

            with ops.name_scope("foo"):
              a = constant_op.constant(1.0, name="a")
              distribute_lib.get_replica_context().merge_call(lambda _: _)
              b = constant_op.constant(1.0, name="b")
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 2 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 755..758

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

      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

            with ops.name_scope(None, "foo"):
              a = constant_op.constant(1.0, name="a")
              distribute_lib.get_replica_context().merge_call(lambda _: _)
              b = constant_op.constant(2.0, name="b")
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 2 hrs to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 737..740

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

      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

            def model_fn():
              v_sum = variable_v1.VariableV1(
                  1.0,
                  synchronization=variable_scope.VariableSynchronization.ON_READ,
                  aggregation=variable_scope.VariableAggregation.SUM)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/distribute/mirrored_variable_test.py on lines 571..577

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

          with distribution.scope():
            result = distribution.extended.call_for_each_replica(model_fn)
            self.assertTrue(distribute_utils.is_mirrored(result))
            self.assertEqual("foo:0", result.name)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/distribute/mirrored_variable_test.py on lines 232..236

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

          def model_fn():
            v = variable_v1.VariableV1(1.0, name="foo")
            distribute_lib.get_replica_context().merge_call(lambda _: _)
            return v
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 1 hr to fix
      tensorflow/python/distribute/mirrored_variable_test.py on lines 108..111
      tensorflow/python/distribute/mirrored_variable_test.py on lines 166..172

      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

      def _replica_id_as_int():
        replica_id = distribute_lib.get_replica_context().replica_id_in_sync_group
        if isinstance(replica_id, tensor_lib.Tensor):
          replica_id = tensor_util.constant_value(replica_id)
        return replica_id
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/distribute/parameter_server_strategy_test.py on lines 61..65

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

      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

          context.context().set_logical_device_configuration(physical_gpus[1], [
              context.LogicalDeviceConfiguration(memory_limit=1024),
              context.LogicalDeviceConfiguration(memory_limit=1024)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 417..419

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

      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

          context.context().set_logical_device_configuration(physical_gpus[1], [
              context.LogicalDeviceConfiguration(memory_limit=1024),
              context.LogicalDeviceConfiguration(memory_limit=1024)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 358..360

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

      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

        def testMinimizeLoss(self, distribution):
          if context.executing_eagerly():
            self._test_minimize_loss_eager(distribution)
          else:
            self._test_minimize_loss_graph(distribution)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 40 mins to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 517..521
      tensorflow/python/distribute/one_device_strategy_test.py on lines 40..44

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

      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

        def testMinimizeLoss(self, distribution):
          if context.executing_eagerly():
            self._test_minimize_loss_eager(distribution)
          else:
            self._test_minimize_loss_graph(distribution)
      Severity: Major
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 2 other locations - About 40 mins to fix
      tensorflow/python/distribute/mirrored_strategy_test.py on lines 80..84
      tensorflow/python/distribute/one_device_strategy_test.py on lines 40..44

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

      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

            dataset = dataset_ops.Dataset.range(2).interleave(
                (lambda _: dataset_ops.Dataset.range(10)), cycle_length=2)
      Severity: Minor
      Found in tensorflow/python/distribute/mirrored_strategy_test.py and 1 other location - About 35 mins to fix
      tensorflow/python/data/kernel_tests/cardinality_test.py on lines 86..87

      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