deeplearning4j/deeplearning4j

View on GitHub
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/profiler/OpProfiler.java

Summary

Maintainability
F
5 days
Test Coverage

File OpProfiler.java has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    OpProfiler has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @Slf4j
    @Data
    public class OpProfiler {
    
        public enum PenaltyCause {

      Method reset has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public void reset() {
              invocationsCount.set(0);
      
              classAggergator.reset();
              longAggergator.reset();

      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 processOperands has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public PenaltyCause[] processOperands(INDArray x, INDArray y, INDArray z) {
              if (y == null)
                  return processOperands(x, z);
      
              if (x == z || y == z) {

      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 processOpCall has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public void processOpCall(Op op) {
              // total number of invocations
              invocationsCount.incrementAndGet();
      
              // number of invocations for this specific op

      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 statsAsString has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public String statsAsString() {
              StringBuffer stringBuffer = new StringBuffer();
              stringBuffer.append("---Total Op Calls: +  invocationsCount.get()\n");
              stringBuffer.append("--- OpClass calls statistics: ---\n");
              stringBuffer.append(classCounter.asString() + "\n");

        Method processOpCall has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void processOpCall(Op op) {
                // total number of invocations
                invocationsCount.incrementAndGet();
        
                // number of invocations for this specific op

          Method processOperands has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public PenaltyCause[] processOperands(INDArray... operands) {
                  if (operands == null)
                      return new PenaltyCause[] {NONE};
          
                  List<PenaltyCause> causes = new ArrayList<>();

          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 processBlasCall has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void processBlasCall(boolean isGemm, INDArray... operands) {
          
                  if (isGemm) {
                      /**
                       * but for gemm we also care about equal orders case: FF, CC

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

                public void processBlasCall(boolean isGemm, INDArray... operands) {
            
                    if (isGemm) {
                        /**
                         * but for gemm we also care about equal orders case: FF, CC

            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 processTADOperands has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public PenaltyCause[] processTADOperands(DataBuffer... tadBuffers) {
            
                    List<PenaltyCause> causes = new ArrayList<>();
                    for (DataBuffer tadBuffer : tadBuffers) {
                        if (tadBuffer == null)

            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 getOpClass has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                protected String getOpClass(Op op) {
                    if (op instanceof ScalarOp) {
                        return "ScalarOp";
                    } else if (op instanceof MetaOp) {
                        return "MetaOp";

            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 processOperands has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public PenaltyCause[] processOperands(INDArray x, INDArray y) {
                    List<PenaltyCause> penalties = new ArrayList<>();
            
                    if (x != null && x.ordering() != y.ordering()) {
                        penalties.add(PenaltyCause.MIXED_ORDER);

            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 joinDistinct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                protected PenaltyCause[] joinDistinct(PenaltyCause[] a, PenaltyCause[] b) {
                    List<PenaltyCause> causes = new ArrayList<>();
            
                    for (PenaltyCause cause : a) {
                        if (cause != null && !causes.contains(cause))

            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

            Consider simplifying this complex logical expression.
            Open

                        if ((ews < 1 || rank > 2 || (rank == 2 && tadBuffer.getInt(1) > 1 && tadBuffer.getInt(2) > 1))
                                && !causes.contains(PenaltyCause.TAD_NON_EWS_ACCESS))
                            causes.add(PenaltyCause.TAD_NON_EWS_ACCESS);
                        else if (ews > 1 && !causes.contains(PenaltyCause.TAD_STRIDED_ACCESS))
                            causes.add(PenaltyCause.TAD_STRIDED_ACCESS);

              Avoid too many return statements within this method.
              Open

                          return processOperands(x, y);

                Avoid too many return statements within this method.
                Open

                            return "GridOp";

                  Avoid too many return statements within this method.
                  Open

                              return "AccumulationOp";

                    Avoid too many return statements within this method.
                    Open

                                return "BroadcastOp";

                      Avoid too many return statements within this method.
                      Open

                                  return "RandomOp";

                        Avoid too many return statements within this method.
                        Open

                                        return causeXY;

                          Avoid too many return statements within this method.
                          Open

                                      return "MetaOp";

                            Avoid too many return statements within this method.
                            Open

                                        return "ScalarOp";

                              Avoid too many return statements within this method.
                              Open

                                              return "TransformOp";

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

                                    public void timeOpCall(Op op, long startTime) {
                                        long currentTime = System.nanoTime() - startTime;
                                        classAggergator.putTime(getOpClass(op), op, currentTime);
                                
                                        if (currentTime > THRESHOLD) {
                                nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/profiler/OpProfiler.java on lines 370..378

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

                                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

                                    public void timeOpCall(CustomOp op, long startTime) {
                                        long currentTime = System.nanoTime() - startTime;
                                        classAggergator.putTime(getOpClass(op), op, currentTime);
                                
                                        if (currentTime > THRESHOLD) {
                                nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/profiler/OpProfiler.java on lines 360..368

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

                                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

                                        if (x != null && x.elementWiseStride() > 1) {
                                            penalties.add(PenaltyCause.STRIDED_ACCESS);
                                        } else if (y != null && y.elementWiseStride() > 1) {
                                            penalties.add(PenaltyCause.STRIDED_ACCESS);
                                        }
                                nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/profiler/OpProfiler.java on lines 580..584

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

                                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

                                        if (x != null && x.elementWiseStride() < 1) {
                                            penalties.add(PenaltyCause.NON_EWS_ACCESS);
                                        } else if (y != null && y.elementWiseStride() < 1) {
                                            penalties.add(PenaltyCause.NON_EWS_ACCESS);
                                        }
                                nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/profiler/OpProfiler.java on lines 586..590

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

                                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

                                            for (PenaltyCause cause : causes) {
                                                switch (cause) {
                                                    case NON_EWS_ACCESS:
                                                        nonEwsAggregator.incrementCount();
                                                        break;
                                nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/profiler/OpProfiler.java on lines 261..276

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

                                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

                                            for (PenaltyCause cause : causes) {
                                                switch (cause) {
                                                    case NON_EWS_ACCESS:
                                                        nonEwsAggregator.incrementCount();
                                                        break;
                                nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/profiler/OpProfiler.java on lines 553..568

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

                                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