tensorflow/tensorflow

View on GitHub
tensorflow/python/autograph/operators/py_builtins_test.py

Summary

Maintainability
F
1 wk
Test Coverage

File py_builtins_test.py has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 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/autograph/operators/py_builtins_test.py - About 1 day to fix

    PyBuiltinsTest has 54 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PyBuiltinsTest(test.TestCase):
    
      def test_abs(self):
        self.assertEqual(py_builtins.abs_(-1), 1)
        with self.cached_session() as sess:
    Severity: Major
    Found in tensorflow/python/autograph/operators/py_builtins_test.py - About 7 hrs to fix

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

        def test_next_tf_iterator(self):
          # graph-mode iterators are only supported inside tf.function.
          @def_function.function(autograph=False)
          def test_fn(go_out_of_range, with_default):
            iterator = iter(dataset_ops.Dataset.range(3))
      Severity: Minor
      Found in tensorflow/python/autograph/operators/py_builtins_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 test_max_tensor(self):
          r = py_builtins.max_(constant_op.constant(2))
          self.assertAllEqual(self.evaluate(r), 2)
          with self.assertRaises(ValueError):
            py_builtins.max_(constant_op.constant([[2]]))
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 2 days to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 227..243

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

      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 test_min_tensor(self):
          r = py_builtins.min_(constant_op.constant(2))
          self.assertAllEqual(self.evaluate(r), 2)
          with self.assertRaises(ValueError):
            py_builtins.min_(constant_op.constant([[2]]))
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 2 days to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 205..221

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

      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 test_any_dataset(self):
          dataset_1 = dataset_ops.DatasetV2.from_tensor_slices([False, True, False])
          dataset_2 = dataset_ops.DatasetV2.from_tensor_slices([False, False, False])
          self.assertEqual(self.evaluate(py_builtins.any_(dataset_1)), True)
          self.assertEqual(self.evaluate(py_builtins.any_(dataset_2)), False)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 1 day to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 656..673

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

      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 test_all_dataset(self):
          dataset_1 = dataset_ops.DatasetV2.from_tensor_slices([False, True, False])
          dataset_2 = dataset_ops.DatasetV2.from_tensor_slices([True, True, True])
          self.assertEqual(self.evaluate(py_builtins.all_(dataset_1)), False)
          self.assertEqual(self.evaluate(py_builtins.all_(dataset_2)), True)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 1 day to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 633..650

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

      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 self.cached_session() as sess:
            self.assertAllEqual(self.evaluate(iterator.get_next()), (1, 1))
            self.assertAllEqual(self.evaluate(iterator.get_next()), (2, 2))
            self.assertAllEqual(self.evaluate(iterator.get_next()), (3, 3))
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 4 hrs to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 294..297

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

      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 self.cached_session() as sess:
            self.assertAllEqual(self.evaluate(iterator.get_next()), (-11, -21))
            self.assertAllEqual(self.evaluate(iterator.get_next()), (-12, -22))
            self.assertAllEqual(self.evaluate(iterator.get_next()), (4, 5))
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 4 hrs to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 69..72

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

      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

          with self.cached_session() as sess:
            self.assertAllEqual(self.evaluate(iterator.get_next()), 1)
            self.assertAllEqual(self.evaluate(iterator.get_next()), 2)
            self.assertAllEqual(self.evaluate(iterator.get_next()), 3)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 2 other locations - About 3 hrs to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 318..321
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 329..332

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

      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

          with self.cached_session() as sess:
            self.assertAllEqual(self.evaluate(iterator.get_next()), 5)
            self.assertAllEqual(self.evaluate(iterator.get_next()), 6)
            self.assertAllEqual(self.evaluate(iterator.get_next()), 7)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 2 other locations - About 3 hrs to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 58..61
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 329..332

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

      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

          with self.cached_session() as sess:
            self.assertAllEqual(self.evaluate(iterator.get_next()), -32)
            self.assertAllEqual(self.evaluate(iterator.get_next()), -34)
            self.assertAllEqual(self.evaluate(iterator.get_next()), 9)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 2 other locations - About 3 hrs to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 58..61
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 318..321

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

      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 test_any(self):
          self.assertEqual(py_builtins.any_([False, True, False]), True)
          self.assertEqual(py_builtins.any_([False, False, False]), False)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 652..654

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

      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 test_all(self):
          self.assertEqual(py_builtins.all_([False, True, False]), False)
          self.assertEqual(py_builtins.all_([True, True, True]), True)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 629..631

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

      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 test_min(self):
          self.assertEqual(py_builtins.min_([2, 1, 3]), 1)
          self.assertEqual(py_builtins.min_(2, 0, 1), 0)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 201..203

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

      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 test_max(self):
          self.assertEqual(py_builtins.max_([1, 3, 2]), 3)
          self.assertEqual(py_builtins.max_(0, 2, 1), 2)
      Severity: Major
      Found in tensorflow/python/autograph/operators/py_builtins_test.py and 1 other location - About 1 hr to fix
      tensorflow/python/autograph/operators/py_builtins_test.py on lines 223..225

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

      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