tensorflow/models

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

Summary

Maintainability
D
2 days
Test Coverage

Function validate has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  def validate(self):
    """Validate the parameters consistency based on the restrictions.

    This method validates the internal consistency using the pre-defined list of
    restrictions. A restriction is defined as a string which specifies a binary
Severity: Minor
Found in official/modeling/hyperparams/params_dict.py - About 5 hrs 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

File params_dict.py has 395 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.py - About 5 hrs to fix

    Function nested_csv_str_to_json_str has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def nested_csv_str_to_json_str(csv_str):
      """Converts a nested (using '.') comma-separated k=v string to a JSON string.
    
      Converts a comma-separated string of key/value pairs that supports
      nesting of keys to a JSON string. Nesting is implemented using
    Severity: Minor
    Found in official/modeling/hyperparams/params_dict.py - About 4 hrs 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 _override has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def _override(self, override_dict, is_strict=True):
        """The implementation of `override`."""
        for k, v in six.iteritems(override_dict):
          if k in ParamsDict.RESERVED_ATTR:
            raise KeyError('The key `%{}` is internally reserved. '
    Severity: Minor
    Found in official/modeling/hyperparams/params_dict.py - About 1 hr 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 override_params_dict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def override_params_dict(params, dict_or_string_or_yaml_file, is_strict):
      """Override a given ParamsDict using a dict, JSON/YAML/CSV string or YAML file.
    
      The logic of the function is outlined below:
      1. Test that the input is a dict. If not, proceed to 2.
    Severity: Minor
    Found in official/modeling/hyperparams/params_dict.py - About 55 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 as_dict has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def as_dict(self):
        """Returns a dict representation of ParamsDict.
    
        For the nested ParamsDict, a nested dict will be returned.
        """
    Severity: Minor
    Found in official/modeling/hyperparams/params_dict.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

    There are no issues that match your filters.

    Category
    Status