deeplearning4j/deeplearning4j

View on GitHub

Showing 6,111 of 13,975 total issues

Method createFromNpzFile has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public Map<String, INDArray> createFromNpzFile(File file) throws Exception{

        // TODO error checks
        HashMap<String, INDArray> map = new HashMap<>();

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

    protected void initSubgraph(Set<String> variables) {
        // Step 1: determine subgraph structure we actually need to execute
        Queue<String> processingQueue = new LinkedList<>(variables);

        // Note subgraph initially should include placeholders and constants

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

    private static void configureBaseLayer(String layerName, BaseLayer bLayer, IDropout iDropout,
                                           List<Regularization> regularization, List<Regularization> regularizationBias) {
        if (regularization != null && !regularization.isEmpty()) {
            final List<Regularization> bLayerRegs = new ArrayList<>(bLayer.getRegularization());
            if (bLayerRegs == null || bLayerRegs.isEmpty()) {

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

    static public FwdPassReturn activateHelper(final BaseRecurrentLayer layer, final NeuralNetConfiguration conf,
                                               final IActivation gateActivationFn, //Activation function for the gates - sigmoid or hard sigmoid (must be found in range 0 to 1)
                                               INDArray input, final INDArray recurrentWeights, //Shape: [hiddenLayerSize,4*hiddenLayerSize+3]; order: [wI,wF,wO,wG,wFF,wOO,wGG]
                                               final INDArray originalInputWeights, //Shape: [n^(L-1),4*hiddenLayerSize]; order: [wi,wf,wo,wg]
                                               final INDArray biases, //Shape: [4,hiddenLayerSize]; order: [bi,bf,bo,bg]^T

    File LSTMHelpers.java has 590 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Method generateDocs has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
      Open

          public static void generateDocs(int namespaceNum, NamespaceOps namespace, String docsDirectory, String basePackage) throws IOException {
              File outputDirectory = new File(docsDirectory);
              StringBuilder sb = new StringBuilder();
              String headerName = namespace.getName();
              if(headerName.startsWith("SD"))

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

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

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

            public static class Builder {
        
                private List<DataAction> actionList = new ArrayList<>();
                private Schema initialSchema;
        
        

          Method initAttributes has 249 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              override fun <GRAPH_TYPE : GeneratedMessageV3, NODE_TYPE : GeneratedMessageV3, OP_DEF_TYPE : GeneratedMessageV3, TENSOR_TYPE : GeneratedMessageV3, ATTR_DEF_TYPE : GeneratedMessageV3, ATTR_VALUE_TYPE : GeneratedMessageV3, DATA_TYPE : ProtocolMessageEnum> initAttributes(
                  df: DifferentialFunction,
                  sd: SameDiff,
                  descriptorAndContext: Pair<MappingContext<GRAPH_TYPE, NODE_TYPE, OP_DEF_TYPE, TENSOR_TYPE, ATTR_DEF_TYPE, ATTR_VALUE_TYPE, DATA_TYPE>, OpNamespace.OpDescriptor>
              ) {

            File StringUtils.java has 580 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*
             *  ******************************************************************************
             *  *
             *  *
             *  * This program and the accompanying materials are made available under the
            Severity: Major
            Found in nd4j/nd4j-common/src/main/java/org/nd4j/common/io/StringUtils.java - About 1 day to fix

              Method calculateOutputShape has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public List<LongShapeDescriptor> calculateOutputShape(@NonNull CustomOp op, OpContext opContext) {
                      DifferentialFunction func = (DifferentialFunction) op;
                      String opName = func.getOwnName();
                      val lc = op.opName().toLowerCase();

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

                      @SneakyThrows
                      @Override
                      public void run() {
                          Nd4j.getAffinityManager().unsafeSetDevice(deviceId);
                          boolean canRun = true;

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

                  private void initHelperGraph() {
              
                      int[] backPropOrder = origGraph.topologicalSortOrder().clone();
                      ArrayUtils.reverse(backPropOrder);
              
              

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

              fun Random() = Namespace("Random") {
                  val random = Mixin("random"){
                      Arg(DATA_TYPE, "datatype"){ description = "Data type of the output variable"}
                      Arg(LONG, "shape") { count = AtLeast(0); description = "Shape of the new random %INPUT_TYPE%, as a 1D array" }
                      Output(NUMERIC, "output") { description = "Tensor with the given shape where values are randomly sampled according to a %OP_NAME% distribution" }
              Severity: Minor
              Found in codegen/op-codegen/src/main/ops/org/nd4j/codegen/ops/Random.kt - About 1 day 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 ROC.java has 578 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

                Preconditions has 67 methods (exceeds 20 allowed). Consider refactoring.
                Open

                public final class Preconditions {
                    private static final Map<String,PreconditionsFormat> FORMATTERS = new HashMap<>();
                    static {
                        ServiceLoader<PreconditionsFormat> sl = ND4JClassLoading.loadService(PreconditionsFormat.class);
                        for (PreconditionsFormat pf : sl) {

                  Configuration has 67 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  public class Configuration implements Iterable<Map.Entry<String, String>>, Writable, Serializable {
                      private static final Logger LOG = LoggerFactory.getLogger(Configuration.class);
                  
                      private boolean quietmode = true;
                  
                  

                    VariationalAutoencoder has 67 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    public class VariationalAutoencoder implements Layer {
                    
                        protected INDArray input;
                        protected INDArray paramsFlattened;
                        protected INDArray gradientsFlattened;

                      File TFTensorMappers.java has 576 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

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

                        Method outputOfLayersDetached has 244 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected INDArray[] outputOfLayersDetached(boolean train, @NonNull FwdPassType fwdPassType, @NonNull int[] layerIndexes, @NonNull INDArray[] features,
                                                                        INDArray[] fMask, INDArray[] lMasks, boolean clearLayerInputs, boolean detachedInputs, MemoryWorkspace outputWorkspace){
                                if(features.length != numInputArrays){
                                    throw new IllegalArgumentException("Invalid number of input arrays: network has " + numInputArrays
                                            + " inputs, got " + features.length + " input arrays");
                          Severity
                          Category
                          Status
                          Source
                          Language