deeplearning4j/deeplearning4j

View on GitHub
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/workspace/BaseWorkspaceMgr.java

Summary

Maintainability
C
1 day
Test Coverage

BaseWorkspaceMgr has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

@Slf4j
public abstract class BaseWorkspaceMgr<T extends Enum<T>> implements WorkspaceMgr<T> {
    private static final boolean DISABLE_LEVERAGE = false;  //Mainly for debugging/optimization purposes

    protected final Set<T> scopeOutOfWs;

    File BaseWorkspaceMgr.java has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     *  ******************************************************************************
     *  *
     *  *
     *  * This program and the accompanying materials are made available under the

      Method validateArrayLocation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public INDArray validateArrayLocation(@NonNull T arrayType, @NonNull INDArray array, boolean migrateIfInvalid, boolean exceptionIfDetached) {
              validateConfig(arrayType);
      
              if(scopeOutOfWs.contains(arrayType)){

      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

      Method leverageTo has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public INDArray leverageTo(@NonNull T arrayType, @NonNull INDArray array) {
              if(array == null || !array.isAttached()){
                  return array;
              }

      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

      Method validateArrayLocation has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public INDArray validateArrayLocation(@NonNull T arrayType, @NonNull INDArray array, boolean migrateIfInvalid, boolean exceptionIfDetached) {
              validateConfig(arrayType);
      
              if(scopeOutOfWs.contains(arrayType)){

        Method castTo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public INDArray castTo(@NonNull T arrayType, @NonNull DataType dataType, @NonNull INDArray toCast, boolean dupIfCorrectType) {
                if(toCast.dataType() == dataType) {
                    if(!dupIfCorrectType) {
                        //Check if we can avoid duping... if not in workspace, or already in correct workspace

        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

        Avoid too many return statements within this method.
        Open

                return array;

          There are no issues that match your filters.

          Category
          Status