tensorflow/models

View on GitHub
official/modeling/hyperparams/params_dict_test.py

Summary

Maintainability
D
1 day
Test Coverage

File params_dict_test.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

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

        with self.assertRaises(KeyError):
          params = params_dict.ParamsDict({'a': 1, 'c': {'a': 10}}, ['a == c.a'])
          params.validate()
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 1 other location - About 1 hr to fix
    official/modeling/hyperparams/params_dict_test.py on lines 156..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

        with self.assertRaises(KeyError):
          params = params_dict.ParamsDict({'a': 1, 'b': {'a': 11}}, ['a == c'])
          params.validate()
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 1 other location - About 1 hr to fix
    official/modeling/hyperparams/params_dict_test.py on lines 173..175

    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

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

        params = params_dict.ParamsDict({
            'a': 1,
            'b': {
                'b1': 2,
                'b2': [2, 3],
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 1 other location - About 1 hr to fix
    official/modeling/hyperparams/params_dict_test.py on lines 308..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 38.

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

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

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

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

    Refactorings

    Further Reading

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

        params = params_dict.ParamsDict({
            'a': 1,
            'b': {
                'b1': 2,
                'b2': [2, 3],
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 1 other location - About 1 hr to fix
    official/modeling/hyperparams/params_dict_test.py on lines 285..296

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 38.

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

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

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

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

    Refactorings

    Further Reading

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

      def test_basic_nested_csv_str_to_json_str(self):
        csv_str = 'a=1,b.b1=2'
        json_str = '{a : 1, b : {b1 : 2}}'
        converted_csv_str = params_dict.nested_csv_str_to_json_str(csv_str)
        self.assertEqual(converted_csv_str, json_str)
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 5 other locations - About 55 mins to fix
    official/modeling/hyperparams/params_dict_test.py on lines 362..366
    official/modeling/hyperparams/params_dict_test.py on lines 388..392
    official/modeling/hyperparams/params_dict_test.py on lines 401..405
    official/modeling/hyperparams/params_dict_test.py on lines 407..411
    official/modeling/hyperparams/params_dict_test.py on lines 443..447

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

      def test_float_array_param_nested_csv_str_to_json_str(self):
        csv_str = 'a.b[1]=3.45,a.b[2]=1.32,a.b[0]=2.232'
        json_str = '{a : {b : [2.232, 3.45, 1.32]}}'
        converted_csv_str = params_dict.nested_csv_str_to_json_str(csv_str)
        self.assertEqual(converted_csv_str, json_str)
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 5 other locations - About 55 mins to fix
    official/modeling/hyperparams/params_dict_test.py on lines 362..366
    official/modeling/hyperparams/params_dict_test.py on lines 375..379
    official/modeling/hyperparams/params_dict_test.py on lines 388..392
    official/modeling/hyperparams/params_dict_test.py on lines 401..405
    official/modeling/hyperparams/params_dict_test.py on lines 443..447

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

      def test_complex_nested_csv_str_to_json_str(self):
        csv_str = 'a.aa.aaa.aaaaa.a=1'
        json_str = '{a : {aa : {aaa : {aaaaa : {a : 1}}}}}'
        converted_csv_str = params_dict.nested_csv_str_to_json_str(csv_str)
        self.assertEqual(converted_csv_str, json_str)
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 5 other locations - About 55 mins to fix
    official/modeling/hyperparams/params_dict_test.py on lines 362..366
    official/modeling/hyperparams/params_dict_test.py on lines 375..379
    official/modeling/hyperparams/params_dict_test.py on lines 401..405
    official/modeling/hyperparams/params_dict_test.py on lines 407..411
    official/modeling/hyperparams/params_dict_test.py on lines 443..447

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

      def test_int_array_param_nested_csv_str_to_json_str(self):
        csv_str = 'a.b[2]=3,a.b[0]=1,a.b[1]=2'
        json_str = '{a : {b : [1, 2, 3]}}'
        converted_csv_str = params_dict.nested_csv_str_to_json_str(csv_str)
        self.assertEqual(converted_csv_str, json_str)
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 5 other locations - About 55 mins to fix
    official/modeling/hyperparams/params_dict_test.py on lines 362..366
    official/modeling/hyperparams/params_dict_test.py on lines 375..379
    official/modeling/hyperparams/params_dict_test.py on lines 388..392
    official/modeling/hyperparams/params_dict_test.py on lines 407..411
    official/modeling/hyperparams/params_dict_test.py on lines 443..447

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

      def test_gcs_added_quotes(self):
        csv_str = 'a=gs://abc, b=gs://def'
        expected_output = '{a : \'gs://abc\', b : \'gs://def\'}'
        converted_csv_str = params_dict.nested_csv_str_to_json_str(csv_str)
        self.assertEqual(converted_csv_str, expected_output)
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 5 other locations - About 55 mins to fix
    official/modeling/hyperparams/params_dict_test.py on lines 362..366
    official/modeling/hyperparams/params_dict_test.py on lines 375..379
    official/modeling/hyperparams/params_dict_test.py on lines 388..392
    official/modeling/hyperparams/params_dict_test.py on lines 401..405
    official/modeling/hyperparams/params_dict_test.py on lines 407..411

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

      def test_basic_csv_str_to_json_str(self):
        csv_str = 'a=1,b=2,c=3'
        json_str = '{a : 1, b : 2, c : 3}'
        converted_csv_str = params_dict.nested_csv_str_to_json_str(csv_str)
        self.assertEqual(converted_csv_str, json_str)
    Severity: Major
    Found in official/modeling/hyperparams/params_dict_test.py and 5 other locations - About 55 mins to fix
    official/modeling/hyperparams/params_dict_test.py on lines 375..379
    official/modeling/hyperparams/params_dict_test.py on lines 388..392
    official/modeling/hyperparams/params_dict_test.py on lines 401..405
    official/modeling/hyperparams/params_dict_test.py on lines 407..411
    official/modeling/hyperparams/params_dict_test.py on lines 443..447

    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

    There are no issues that match your filters.

    Category
    Status