tensorflow/tensorflow

View on GitHub
tensorflow/python/tpu/client/client_test.py

Summary

Maintainability
F
2 wks
Test Coverage

File client_test.py has 766 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2019 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/tpu/client/client_test.py - About 1 day to fix

    CloudTpuClientTest has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CloudTpuClientTest(test.TestCase):
    
      def setUp(self):
        super().setUp()
        if 'TPU_API_DISCOVERY_URL' in os.environ:
    Severity: Minor
    Found in tensorflow/python/tpu/client/client_test.py - About 5 hrs to fix

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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        @mock.patch.object(client, '_utcnow', mock_utcnow)
        def testRecoverableHBMOOM(self):
          test_cases = [
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 2 days to fix
      tensorflow/python/tpu/client/client_test.py on lines 321..450

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

      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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        @mock.patch.object(client, '_utcnow', mock_utcnow)
        def testRecoverableOOM(self):
          test_cases = [
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 2 days to fix
      tensorflow/python/tpu/client/client_test.py on lines 504..633

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

      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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        @mock.patch.object(client, '_utcnow', mock_utcnow)
        def testRecoverableHBMOOMDisabled(self):
          test_cases = [
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 1 day to fix
      tensorflow/python/tpu/client/client_test.py on lines 452..477

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 122.

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

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

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

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

      Refactorings

      Further Reading

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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        @mock.patch.object(client, '_utcnow', mock_utcnow)
        def testRecoverableOOMDisabled(self):
          test_cases = [
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 1 day to fix
      tensorflow/python/tpu/client/client_test.py on lines 635..660

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 122.

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

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

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

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

      Refactorings

      Further Reading

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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        @mock.patch.object(client, '_utcnow', mock_utcnow)
        def testRecoverableOOMNoAPI(self):
          test_cases = [
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 6 hrs to fix
      tensorflow/python/tpu/client/client_test.py on lines 662..685

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

      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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        @mock.patch.object(client, '_utcnow', mock_utcnow)
        def testRecoverableHBMOOMNoAPI(self):
          test_cases = [
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 6 hrs to fix
      tensorflow/python/tpu/client/client_test.py on lines 479..502

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

      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 mock_service_client(self, tpu_map=None):
          if tpu_map is None:
            tpu_map = {}
      
          mock_locations = mock.MagicMock()
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 4 hrs to fix
      tensorflow/python/distribute/cluster_resolver/tpu/tpu_cluster_resolver_test.py on lines 123..137

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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        def testRuntimeVersionApi(self):
          tpu_map = {
              'projects/test-project/locations/us-central1-c/nodes/tpu_name': {
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 2 other locations - About 4 hrs to fix
      tensorflow/python/tpu/client/client_test.py on lines 687..702
      tensorflow/python/tpu/client/client_test.py on lines 721..736

      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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        def testHealthApi(self):
          tpu_map = {
              'projects/test-project/locations/us-central1-c/nodes/tpu_name': {
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 2 other locations - About 4 hrs to fix
      tensorflow/python/tpu/client/client_test.py on lines 704..719
      tensorflow/python/tpu/client/client_test.py on lines 721..736

      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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        def testAcceleratorTypeApi(self):
          tpu_map = {
              'projects/test-project/locations/us-central1-c/nodes/tpu_name': {
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 2 other locations - About 4 hrs to fix
      tensorflow/python/tpu/client/client_test.py on lines 687..702
      tensorflow/python/tpu/client/client_test.py on lines 704..719

      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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        def testRecoverablePreempted(self):
          tpu_map = {
              'projects/test-project/locations/us-central1-c/nodes/tpu_name': {
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 3 hrs to fix
      tensorflow/python/tpu/client/client_test.py on lines 293..305

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

      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

        @mock.patch.object(client, '_request_compute_metadata',
                           mock_request_compute_metadata)
        def testRecoverableReady(self):
          tpu_map = {
              'projects/test-project/locations/us-central1-c/nodes/tpu_name': {
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 3 hrs to fix
      tensorflow/python/tpu/client/client_test.py on lines 307..319

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

      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 testEnvironmentVarToNetworkEndpointsMultipleIps(self):
          self.assertEqual(
              [{'ipAddress': '1.2.3.4', 'port': '2000'},
               {'ipAddress': '5.6.7.8', 'port': '1234'}],
              list(
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 2 other locations - About 1 hr to fix
      tensorflow/python/tpu/client/client_test.py on lines 147..151
      tensorflow/python/tpu/client/client_test.py on lines 154..158

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

        def testEnvironmentVarToNetworkEndpointsMissingPortAndMixed(self):
          self.assertEqual(
              [{'ipAddress': '1.2.3.4', 'port': '2000'},
               {'ipAddress': '5.6.7.8', 'port': '8470'}],
              list(client._environment_var_to_network_endpoints(
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 2 other locations - About 1 hr to fix
      tensorflow/python/tpu/client/client_test.py on lines 139..144
      tensorflow/python/tpu/client/client_test.py on lines 147..151

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

        def testEnvironmentVarToNetworkEndpointsMultipleGrpcAddresses(self):
          self.assertEqual(
              [{'ipAddress': '1.2.3.4', 'port': '2000'},
               {'ipAddress': '5.6.7.8', 'port': '1234'}],
              list(client._environment_var_to_network_endpoints(
      Severity: Major
      Found in tensorflow/python/tpu/client/client_test.py and 2 other locations - About 1 hr to fix
      tensorflow/python/tpu/client/client_test.py on lines 139..144
      tensorflow/python/tpu/client/client_test.py on lines 154..158

      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

        @mock.patch.dict(os.environ, {'GCE_METADATA_IP': '1.2.3.4'})
        def testEnvironmentGCEIPOverride(self):
          self.assertEqual('http://1.2.3.4', client._gce_metadata_endpoint())
      Severity: Minor
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 55 mins to fix
      tensorflow/python/tpu/client/client_test.py on lines 122..124

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

      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

        @mock.patch.dict(os.environ, {'GCE_METADATA_HOST': 'foo.bar'})
        def testEnvironmentGCEHostOverride(self):
          self.assertEqual('http://foo.bar', client._gce_metadata_endpoint())
      Severity: Minor
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 55 mins to fix
      tensorflow/python/tpu/client/client_test.py on lines 118..120

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

      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 testEnvironmentVarToNetworkEndpointsSingleIp(self):
          self.assertEqual(
              [{'ipAddress': '1.2.3.4', 'port': '1234'}],
              list(client._environment_var_to_network_endpoints(
      Severity: Minor
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 40 mins to fix
      tensorflow/python/tpu/client/client_test.py on lines 132..136

      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

        def testEnvironmentVarToNetworkEndpointsSingleGrpcAddress(self):
          self.assertEqual(
              [{'ipAddress': '1.2.3.4', 'port': '2000'}],
              list(
                  client._environment_var_to_network_endpoints(
      Severity: Minor
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 40 mins to fix
      tensorflow/python/tpu/client/client_test.py on lines 126..129

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

      class MockNodeClass:
      
        def __init__(self, tpu_map):
          self._tpu_map = tpu_map
      
      
      Severity: Minor
      Found in tensorflow/python/tpu/client/client_test.py and 1 other location - About 30 mins to fix
      tensorflow/python/distribute/cluster_resolver/tpu/tpu_cluster_resolver_test.py on lines 58..64

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 32.

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

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

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

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

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status