deeplearning4j/deeplearning4j

View on GitHub

Showing 13,975 of 13,975 total issues

DynamicCustomOp has 71 methods (exceeds 20 allowed). Consider refactoring.
Open

@Slf4j
public class DynamicCustomOp extends DifferentialFunction implements CustomOp {

    private String opName;
    @Builder.Default

    UIVariable has 71 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @SuppressWarnings("unused")
    public final class UIVariable extends Table {
      public static void ValidateVersion() { Constants.FLATBUFFERS_1_12_0(); }
      public static UIVariable getRootAsUIVariable(ByteBuffer _bb) { return getRootAsUIVariable(_bb, new UIVariable()); }
      public static UIVariable getRootAsUIVariable(ByteBuffer _bb, UIVariable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }

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

          @Override
          public List<List<Writable>> next(int num) {
              Preconditions.checkArgument(num > 0, "Number of examples must be > 0: got %s", num);
      
              if (imageLoader == 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 appendTo has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
      Open

          public StringBuilder appendTo(final StringBuilder builder) {
              builder.append('{');
              boolean atLeastOne = false;
              if (score()) {
                  if (atLeastOne) {

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

          @Override
          public Pair<Gradient, INDArray> backpropGradient(INDArray epsilon, LayerWorkspaceMgr workspaceMgr) {
              assertInputSet(true);
              INDArray nextEpsilon;
              val shape = getShape(epsilon);

      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 66 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public void iterationDone(Model model, int iteration, int epoch) {
              // we update lastTime on every iteration
              // just to simplify things
              if (lastTime.get() == 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 doEvaluationHelper has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
      Open

          private <T extends IEvaluation> Map<Integer,T[]> doEvaluationHelper(MultiDataSetIterator iterator, Map<Integer, T[]> evaluations){
              if (layers == null || !(getOutputLayer(0) instanceof IOutputLayer)) {
                  throw new IllegalStateException("Cannot evaluate network with no output layer");
              }
      
      

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

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

        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;
              
              

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

                        scannedClasses.getClassesImplementing(PreImportHook::class.java.name).filter { input -> input.hasAnnotation(PreHookRule::class.java.name) }.forEach {
                            val instance = Class.forName(it.name).getDeclaredConstructor().newInstance() as PreImportHook
                            val rule = it.annotationInfo.first { input -> input.name == PreHookRule::class.java.name }
                            val nodeNames = rule.parameterValues["nodeNames"].value as Array<String>
                            val frameworkName = rule.parameterValues["frameworkName"].value as String
                nd4j/samediff-import/samediff-import-api/src/main/kotlin/org/nd4j/samediff/frameworkimport/reflect/ImportReflectionCache.kt on lines 80..104

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

                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

                        scannedClasses.getClassesImplementing(PostImportHook::class.java.name).filter { input -> input.hasAnnotation(PostHookRule::class.java.name) }.forEach {
                            val instance = Class.forName(it.name).getDeclaredConstructor().newInstance() as PostImportHook
                            val rule = it.annotationInfo.first { input -> input.name == PostHookRule::class.java.name }
                            val nodeNames = rule.parameterValues["nodeNames"].value as Array<String>
                            val frameworkName = rule.parameterValues["frameworkName"].value as String
                nd4j/samediff-import/samediff-import-api/src/main/kotlin/org/nd4j/samediff/frameworkimport/reflect/ImportReflectionCache.kt on lines 57..78

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

                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

                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
                    Severity
                    Category
                    Status
                    Source
                    Language