deeplearning4j/deeplearning4j

View on GitHub
codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java

Summary

Maintainability
F
1 wk
Test Coverage

File Nd4jNamespaceGenerator.java has 808 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Method buildParameters has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        private static List<String> buildParameters(MethodSpec.Builder c, Op op, Signature s, boolean isSameDiff, boolean withName) {
            List<String> inNames = new ArrayList<>();
    
            List<Parameter> params = s.getParameters();
    
    

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

        private static void generateDocs(NamespaceOps namespace, File outputDirectory, String basePackage) throws IOException {
            StringBuilder sb = new StringBuilder();
            sb.append("#  Namespace " + namespace.getName() + System.lineSeparator());
            List<Op> ops = namespace.getOps();
            for (Op op : ops) {

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

        private static void buildJavaDoc(Op op, Signature s, MethodSpec.Builder c, boolean withName) {
            //Method javadoc:
            List<DocSection> doc = op.getDoc();
            if(!doc.isEmpty()){
                for(DocSection ds : doc){

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

        private static void buildExecution(MethodSpec.Builder c, Op op, List<String> inNames, boolean isSameDiff,
                                           boolean withName, boolean isLoss) {
            boolean singleOut = op.getOutputs().size() == 1 && !op.getOutputs().get(0).getMultiOutput();
            if(singleOut){
                if (isSameDiff)

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

        private static void generateConfig(File outputDirectory, String targetPackage, Config config) throws IOException {
            if(config.getJavaClassOverride() != null && !config.getJavaClassOverride().isEmpty()){
                //Java class override means "don't generate, use the existing one instead"
                String c = config.getJavaClassOverride();
                int idx = c.lastIndexOf('.');

      Method buildExecution has 94 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static void buildExecution(MethodSpec.Builder c, Op op, List<String> inNames, boolean isSameDiff,
                                             boolean withName, boolean isLoss) {
              boolean singleOut = op.getOutputs().size() == 1 && !op.getOutputs().get(0).getMultiOutput();
              if(singleOut){
                  if (isSameDiff)

        Method generateConfig has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            private static void generateConfig(File outputDirectory, String targetPackage, Config config) throws IOException {
                if(config.getJavaClassOverride() != null && !config.getJavaClassOverride().isEmpty()){
                    //Java class override means "don't generate, use the existing one instead"
                    String c = config.getJavaClassOverride();
                    int idx = c.lastIndexOf('.');

        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

        Nd4jNamespaceGenerator has 29 methods (exceeds 20 allowed). Consider refactoring.
        Open

        @Slf4j
        public class Nd4jNamespaceGenerator {
            private static Map<DataType, Class<?>> typeMapping = new HashMap<>();
            private static Map<DataType, String> validationMapping = new HashMap<>();
            private static Map<Arg, TypeName> enumMapping = new HashMap<>();

          Method generateDocs has 74 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static void generateDocs(NamespaceOps namespace, File outputDirectory, String basePackage) throws IOException {
                  StringBuilder sb = new StringBuilder();
                  sb.append("#  Namespace " + namespace.getName() + System.lineSeparator());
                  List<Op> ops = namespace.getOps();
                  for (Op op : ops) {

            Method buildParameters has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static List<String> buildParameters(MethodSpec.Builder c, Op op, Signature s, boolean isSameDiff, boolean withName) {
                    List<String> inNames = new ArrayList<>();
            
                    List<Parameter> params = s.getParameters();
            
            

              Method buildJavaDoc has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static void buildJavaDoc(Op op, Signature s, MethodSpec.Builder c, boolean withName) {
                      //Method javadoc:
                      List<DocSection> doc = op.getDoc();
                      if(!doc.isEmpty()){
                          for(DocSection ds : doc){

                Method generateMethodText has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static String generateMethodText(Op op, Signature s, boolean isSameDiff, boolean isLoss, boolean withName) {
                        StringBuilder sb = new StringBuilder();
                        MethodSpec.Builder c = MethodSpec.methodBuilder(GenUtil.ensureFirstIsNotCap(op.getOpName()));
                        List<Parameter> params = s.getParameters();
                        List<Output> outs = op.getOutputs();

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

                    private static void generateOpFactory(NamespaceOps namespace, File outputDirectory, String className, String basePackage,
                                                          String parentClass) throws IOException, ClassNotFoundException {
                        boolean isBaseSameDiff = StringUtils.equals("SDBaseOps", className);
                        boolean isSameDiff = StringUtils.isNotEmpty(parentClass);
                        boolean isLoss = StringUtils.equals("SDLoss", className);

                  Method generateMethodText has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static String generateMethodText(Op op, Signature s, boolean isSameDiff, boolean isLoss, boolean withName) {
                          StringBuilder sb = new StringBuilder();
                          MethodSpec.Builder c = MethodSpec.methodBuilder(GenUtil.ensureFirstIsNotCap(op.getOpName()));
                          List<Parameter> params = s.getParameters();
                          List<Output> outs = op.getOutputs();

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

                        private static String anyToCode(Parameter parameter, Object v){
                            if(v == null){ return "null"; }
                            else if(v instanceof int[]){ return "new int[]"+Arrays.toString((int[]) v).replace("[", "{").replace("]", "}"); }
                            else if(v instanceof long[]){ return "new long[]"+Arrays.toString((long[]) v).replace("[", "{").replace("]", "}"); }
                            else if(v instanceof float[]){ return "new float[]"+Arrays.toString((float[]) v).replace("[", "{").replace("]", "}"); }

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

                        private static void addConfigBuilderParam(String configClassName, TypeSpec.Builder builder, String paramName, DataType inputType, TypeName paramType, String paramDescription, Count count) {
                            final String builderName = builder.build().name;
                            // Add param fields
                            builder.addField(paramType.box(), paramName, Modifier.PRIVATE);
                    
                    

                      Method addConfigBuilderParam has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          private static void addConfigBuilderParam(String configClassName, TypeSpec.Builder builder, String paramName, DataType inputType, TypeName paramType, String paramDescription, Count count) {

                        Method generate has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public static void generate(NamespaceOps namespace, GeneratorConfig config, File outputDirectory, String className,
                                                        String basePackage, String parentClass, String docsDirectory) throws IOException {

                          Method addConfigParam has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              private static void addConfigParam(TypeSpec.Builder builder, MethodSpec.Builder constructorBuilder, String paramName, TypeName paramType, String paramDescription, boolean addField) {

                            Method getArgType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public static TypeName getArgType(Arg arg) {
                                    DataType argType = arg.getType();
                                    Count count = arg.getCount();
                                    TypeName type;
                                    if(argType == DataType.ENUM){

                            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 buildExecution has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                private static void buildExecution(MethodSpec.Builder c, Op op, List<String> inNames, boolean isSameDiff,
                                                                   boolean withName, boolean isLoss) {

                              Avoid deeply nested control flow statements.
                              Open

                                                      if(!lines[i].endsWith("<br>")){
                                                          lines[i] = lines[i] + "<br>";
                                                      }

                                Method generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public static void generate(NamespaceOps namespace, GeneratorConfig config, File outputDirectory, String className,
                                                                String basePackage, String docsDirectory) throws IOException {

                                  Method addConfigBuilderParam has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private static void addConfigBuilderParam(String configClassName, TypeSpec.Builder builder, String paramName, DataType inputType, TypeName paramType, String paramDescription, Count count) {
                                          final String builderName = builder.build().name;
                                          // Add param fields
                                          builder.addField(paramType.box(), paramName, Modifier.PRIVATE);
                                  
                                  

                                  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 deeply nested control flow statements.
                                  Open

                                                          if(!lines[i].endsWith("<br>")){
                                                              lines[i] = lines[i] + "<br>";
                                                          }

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if(p instanceof Input){
                                                                Input i = (Input)p;
                                                                sb.append("* " + i.getName() + " " + (i.getDescription() == null ? "" : DocTokens.processDocText(i.getDescription(),
                                                                        op, DocTokens.GenerationType.ND4J)) + " (" + i.getType() + " type)" + System.lineSeparator());
                                                            } else if(p instanceof Arg) {

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if (isSameDiff)
                                                                  c.addParameter(SDVariable.class, inputName);
                                                              else
                                                                  c.addParameter(INDArray.class, inputName);

                                        Method buildParameters has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            private static List<String> buildParameters(MethodSpec.Builder c, Op op, Signature s, boolean isSameDiff, boolean withName) {

                                          Method generateOpFactory has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              private static void generateOpFactory(NamespaceOps namespace, File outputDirectory, String className, String basePackage,
                                                                                    String parentClass) throws IOException, ClassNotFoundException {

                                            Method signatureCreatorMethod has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                private static MethodSpec signatureCreatorMethod(Op op, Signature s, boolean isSameDiff, boolean withName,
                                                                                                 boolean isLoss){

                                              Method generateMethodText has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                  private static String generateMethodText(Op op, Signature s, boolean isSameDiff, boolean isLoss, boolean withName) {

                                                Method enableVarargsOnLastArg has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                    private static void enableVarargsOnLastArg(MethodSpec.Builder c, Op op, Signature s) {
                                                        List<Parameter> p = s.getParameters();
                                                        if(!p.isEmpty()){
                                                            Parameter lastP = p.get(p.size() - 1);
                                                            if (lastP instanceof Arg) {

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

                                                    private static void checkParameterCount(MethodSpec.Builder c, Count count, String paramName) {
                                                        // Check for parameter counts
                                                        if(count != null && !count.equals(exactlyOne)){
                                                            final String errorMessage = paramName + " has incorrect size/length. Expected: " + countToJava(count, paramName) + ", got %s";
                                                            if(count instanceof Exactly){

                                                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

                                                        else if(v instanceof double[]){ return "new double[]"+Arrays.toString((double[]) v).replace("[", "{").replace("]", "}"); }

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          else if(v instanceof int[]){ return "new int[]"+Arrays.toString((int[]) v).replace("[", "{").replace("]", "}"); }

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return it.name();

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              else if(v instanceof float[]){ return "new float[]"+Arrays.toString((float[]) v).replace("[", "{").replace("]", "}"); }

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                else if(v instanceof Input){ return ((Input)v).getName(); }

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  else if(v instanceof long[]){ return "new long[]"+Arrays.toString((long[]) v).replace("[", "{").replace("]", "}"); }

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                    if(v == null){ return "null"; }

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                      else if(v instanceof boolean[]){ return "new boolean[]"+Arrays.toString((boolean[]) v).replace("[", "{").replace("]", "}"); }

                                                                Method buildDocSectionText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    private static StringBuilder buildDocSectionText(List<DocSection> docSections) {
                                                                        StringBuilder sb = new StringBuilder();
                                                                        for (DocSection ds : docSections) {
                                                                            //if(ds.applies(Language.JAVA, CodeComponent.OP_CREATOR)){
                                                                            String text = ds.getText();

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

                                                                    private static void generateOpFactory(NamespaceOps namespace, File outputDirectory, String className, String basePackage,
                                                                                                          String parentClass) throws IOException, ClassNotFoundException {
                                                                        boolean isBaseSameDiff = StringUtils.equals("SDBaseOps", className);
                                                                        boolean isSameDiff = StringUtils.isNotEmpty(parentClass);
                                                                        boolean isLoss = StringUtils.equals("SDLoss", className);

                                                                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

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

                                                                        if(!constraints.isEmpty()){
                                                                            holder.addJavadoc("Inputs must satisfy the following constraints: <br>\n");
                                                                            for (Constraint constraint : constraints) {
                                                                                holder.addJavadoc(constraint.getMessage() +": " + constraintCodeGenerator.generateExpression(constraint.getCheck()) + "<br>\n");
                                                                            }
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 267..274

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

                                                                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

                                                                        if(!constraints.isEmpty()){
                                                                            c.addJavadoc("Inputs must satisfy the following constraints: <br>\n");
                                                                            for (Constraint constraint : constraints) {
                                                                                c.addJavadoc(constraint.getMessage() +": " + constraintCodeGenerator.generateExpression(constraint.getCheck()) + "<br>\n");
                                                                            }
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 880..887

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

                                                                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 3 locations. Consider refactoring.
                                                                Open

                                                                                    c.addJavadoc("@param " + i.getName() + " " + (i.getDescription() == null ? "" : DocTokens.processDocText(i.getDescription(), op, DocTokens.GenerationType.ND4J)) + " (" + i.getType() + " type)\n");
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 293..293
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 311..311

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

                                                                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 3 locations. Consider refactoring.
                                                                Open

                                                                                        c.addJavadoc("@param " + arg.getName() + " " + (arg.getDescription() == null ? "" : DocTokens.processDocText(arg.getDescription(), op, DocTokens.GenerationType.ND4J)) + " (Size: " + count.toString() + ")\n");
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 286..286
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 311..311

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

                                                                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 3 locations. Consider refactoring.
                                                                Open

                                                                                c.addJavadoc("@return " + o.getName() + " " + (o.getDescription() == null ? "" : DocTokens.processDocText(o.getDescription(), op, DocTokens.GenerationType.ND4J)) + " (" + o.getType() + " type)\n");
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 293..293
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 286..286

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

                                                                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

                                                                                else {
                                                                                    sb.append("return new ")
                                                                                            .append(op.getJavaPackage())
                                                                                            .append(".")
                                                                                            .append(op.getJavaOpClass() == null ? GenUtil.ensureFirstIsCap(op.getOpName()) : op.getJavaOpClass())
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 497..505

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

                                                                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 (isLoss) {
                                                                                    sb.append("SDVariable out = new ")
                                                                                            .append(op.getJavaPackage())
                                                                                            .append(".")
                                                                                            .append(op.getJavaOpClass() == null ? GenUtil.ensureFirstIsCap(op.getOpName()) : op.getJavaOpClass())
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 506..514

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

                                                                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( int i = 0; i < lines.length; i++) {
                                                                                        if(!lines[i].endsWith("<br>")){
                                                                                            lines[i] = lines[i] + "<br>";
                                                                                        }
                                                                                    }
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 866..870

                                                                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( int i=0; i<lines.length; i++ ){
                                                                                        if(!lines[i].endsWith("<br>")){
                                                                                            lines[i] = lines[i] + "<br>";
                                                                                        }
                                                                                    }
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 252..256

                                                                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

                                                                        if (outs.size() == 1) {
                                                                            retType = isSameDiff ? "SDVariable" : "INDArray";
                                                                        }
                                                                        else if (outs.size() >= 1) {
                                                                            retType = isSameDiff ? "SDVariable[]" : "INDArray[]";
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/DocsGenerator.java on lines 74..79

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

                                                                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

                                                                        holder.addMethod(MethodSpec.methodBuilder("sdBuilder")
                                                                                .addModifiers(Modifier.STATIC, Modifier.PUBLIC)
                                                                                .addStatement("return new $N()", sdBuilder.name)
                                                                                .returns(ClassName.bestGuess(sdBuilder.name))
                                                                                .build());
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 850..854

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

                                                                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

                                                                        holder.addMethod(MethodSpec.methodBuilder("ndBuilder")
                                                                                .addModifiers(Modifier.STATIC, Modifier.PUBLIC)
                                                                                .addStatement("return new $N()", ndBuilder.name)
                                                                                .returns(ClassName.bestGuess(ndBuilder.name))
                                                                                .build());
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 844..848

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

                                                                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

                                                                    private static void addBaseSameDiffConstructor(TypeSpec.Builder builder) {
                                                                
                                                                        MethodSpec ctor = MethodSpec.constructorBuilder()
                                                                                .addModifiers(Modifier.PUBLIC)
                                                                                .addParameter(SameDiff.class, "sameDiff")
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 210..218

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

                                                                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

                                                                    private static void addSameDiffConstructor(TypeSpec.Builder builder) {
                                                                        MethodSpec ctor = MethodSpec.constructorBuilder()
                                                                                .addModifiers(Modifier.PUBLIC)
                                                                                .addParameter(SameDiff.class, "sameDiff")
                                                                                .addStatement("super(sameDiff)")
                                                                codegen/op-codegen/src/main/java/org/nd4j/codegen/impl/java/Nd4jNamespaceGenerator.java on lines 199..208

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

                                                                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