deeplearning4j/deeplearning4j

View on GitHub

Showing 13,975 of 13,975 total issues

Method deserialize has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public ComputationGraphConfiguration deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
        long charOffsetStart = jp.getCurrentLocation().getCharOffset();
        ComputationGraphConfiguration conf = (ComputationGraphConfiguration) defaultDeserializer.deserialize(jp, ctxt);

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

    public String summary(InputType... inputTypes) {
        StringBuilder ret = new StringBuilder();
        ret.append("\n");

        int frozenParams = 0;

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

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

/*
 *  ******************************************************************************
 *  *
 *  *
 *  * This program and the accompanying materials are made available under the
nd4j/samediff-import/samediff-import-onnx/src/main/kotlin/org/nd4j/samediff/frameworkimport/onnx/definitions/implementations/GlobalAveragePooling.kt on lines 1..54

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

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

/*
 *  ******************************************************************************
 *  *
 *  *
 *  * This program and the accompanying materials are made available under the
nd4j/samediff-import/samediff-import-onnx/src/main/kotlin/org/nd4j/samediff/frameworkimport/onnx/definitions/implementations/GlobalMaxPooling.kt on lines 1..54

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

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

File ImportGraph.kt has 700 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    File ImportClassMapping.java has 699 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method replaceSubgraphsMatching has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
      Open

          public static SameDiff replaceSubgraphsMatching(@NonNull SameDiff sd, @NonNull SubGraphPredicate p, @NonNull SubGraphProcessor processor) {
              //Make a copy so that if the transform fails part way through, we don't leave user with broken graph
              sd = sd.dup();
      
              List<SubGraph> subgraphs = getSubgraphsMatching(sd, p);

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

            public Builder mergeFrom(org.nd4j.ir.MapperNamespace.MappingRule other) {
              if (other == org.nd4j.ir.MapperNamespace.MappingRule.getDefaultInstance()) return this;
              if (!other.getRuleName().isEmpty()) {
                ruleName_ = other.ruleName_;
                onChanged();

      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

      Builder has 84 methods (exceeds 20 allowed). Consider refactoring.
      Open

          public static final class Builder extends
              org.nd4j.shade.protobuf.GeneratedMessageV3.Builder<Builder> implements
              // @@protoc_insertion_point(builder_implements:org.nd4j.ir.ArgDescriptor)
              org.nd4j.ir.OpNamespace.ArgDescriptorOrBuilder {
            public static final org.nd4j.shade.protobuf.Descriptors.Descriptor

        Method getTraceEvents has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
        Open

            public static TraceEvent[] getTraceEvents(File file, ProfileFormat profileFormat, boolean aggregateTFSubOps) {
                ObjectMapper json = ProfilingListener.jsonMapper();
        
                String content = null;
                try(BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {

        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 convertAttributes has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring.
        Open

            override fun convertAttributes(mappingCtx: MappingContext<GRAPH_DEF, NODE_TYPE, OP_DEF_TYPE, TENSOR_TYPE, ATTR_DEF, ATTR_VALUE_TYPE, DATA_TYPE>): List<OpNamespace.ArgDescriptor> {
                val ret = ArrayList<OpNamespace.ArgDescriptor>()
        
                for((k, v) in mappingNamesToPerform()) {
                    val argDescriptorTypeList =  mappingCtx.argDescriptorTypeForName(k)

        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 doImport has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring.
        Open

            override fun doImport(
                sd: SameDiff,
                attributes: Map<String, Any>,
                outputNames: List<String>,
                op: SameDiffOp,

        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 BaseNDArrayFactory.java has 689 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

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

          TensorProto has 83 methods (exceeds 20 allowed). Consider refactoring.
          Open

            public static final class TensorProto extends
                org.nd4j.shade.protobuf.GeneratedMessageV3 implements
                // @@protoc_insertion_point(message_implements:org.nd4j.ir.TensorProto)
                TensorProtoOrBuilder {
            private static final long serialVersionUID = 0L;

            Method next has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                public List<Writable> next() {
                    if(numFeatures < 0 && numLabels < 0){
                        throw new IllegalStateException("Cannot get record: setConf(Configuration) has not been called. A setConf " +
                                "call is rquired to specify the number of features and/or labels in the source dataset");

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

                @Override
                public void decode(DirectBuffer buffer) {
                    //TODO we could do this more efficiently, with buffer re-use, etc.
                    MessageHeaderDecoder dec = new MessageHeaderDecoder();
                    UpdateDecoder ud = new UpdateDecoder();

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

                @Override
                public void iterationDone(Model model, int iteration, int epoch) {
            
                    ModelInfo modelInfo = getModelInfo(model);
                    boolean backpropParamsOnly = backpropParamsOnly(model);

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

                static public Pair<Gradient, INDArray> backpropGradientHelper(final BaseRecurrentLayer layer, final NeuralNetConfiguration conf,
                                final IActivation gateActivationFn, INDArray input, final INDArray recurrentWeights, //Shape: [hiddenLayerSize,4*hiddenLayerSize+3]; order: [wI,wF,wO,wG,wFF,wOO,wGG]
                                final INDArray inputWeights, //Shape: [n^(L-1),4*hiddenLayerSize]; order: [wi,wf,wo,wg]
                                final INDArray epsilon, final boolean truncatedBPTT, final int tbpttBackwardLength,
                                final FwdPassReturn fwdPass, final boolean forwards, final String inputWeightKey,

            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

            MathUtils has 82 methods (exceeds 20 allowed). Consider refactoring.
            Open

            public class MathUtils {
            
            
            
                /**
            Severity: Major
            Found in nd4j/nd4j-common/src/main/java/org/nd4j/common/util/MathUtils.java - About 1 day to fix

              File JcublasLapack.java has 680 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               *  ******************************************************************************
               *  *
               *  *
               *  * This program and the accompanying materials are made available under the
                Severity
                Category
                Status
                Source
                Language