tensorflow/models

View on GitHub
official/projects/yolo/optimization/sgd_torch.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def __init__(self,
Severity: Major
Found in official/projects/yolo/optimization/sgd_torch.py - About 1 hr to fix

    Function _get_variable_group has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def _get_variable_group(self, var, coefficients):
        if self._variables_set:
          # check which groups hold which varaibles, preset.
          if _var_key(var) in self._wset:
            return True, False, False
    Severity: Minor
    Found in official/projects/yolo/optimization/sgd_torch.py - About 45 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 _apply has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def _apply(self, grad, var, weight_decay, momentum, lr):
    Severity: Minor
    Found in official/projects/yolo/optimization/sgd_torch.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

          return False, False, True
      Severity: Major
      Found in official/projects/yolo/optimization/sgd_torch.py - About 30 mins to fix

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

          def _search(self, var, keys):
            """Search all all keys for matches. Return True on match."""
            if keys is not None:
              # variable group is not ignored so search for the keys.
              for r in keys:
        Severity: Minor
        Found in official/projects/yolo/optimization/sgd_torch.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

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

          def _create_slots(self, var_list):
            """Create a momentum variable for each variable."""
            if self._momentum:
              for var in var_list:
                # check if trainable to support GPU EMA.
        Severity: Minor
        Found in official/projects/yolo/optimization/sgd_torch.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

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

          def _apply(self, grad, var, weight_decay, momentum, lr):
            """Uses Pytorch Optimizer with Weight decay SGDW."""
            dparams = grad
            groups = []
        
        
        Severity: Minor
        Found in official/projects/yolo/optimization/sgd_torch.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

        There are no issues that match your filters.

        Category
        Status