guimc233/lgz-bot

View on GitHub
src/main/java/huzpsb/ll4j/model/Model.java

Summary

Maintainability
D
2 days
Test Coverage

File Model.java has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package huzpsb.ll4j.model;

import huzpsb.ll4j.layer.*;
import huzpsb.ll4j.utils.data.DataEntry;
import huzpsb.ll4j.utils.data.DataSet;
Severity: Minor
Found in src/main/java/huzpsb/ll4j/model/Model.java - About 4 hrs to fix

    Method trainOn has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        public Pair<Integer, Integer> trainOn(DataSet dataSet, double learningRate) {
            int t = 0, f = 0;
            if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
                throw new RuntimeException("Last layer is not output layer");
            }
    Severity: Minor
    Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method trainAndGetWA has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public List<DataEntry> trainAndGetWA(DataSet dataSet, double learningRate) {
            LinkedList<DataEntry> entries = new LinkedList<>();
            if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
                throw new RuntimeException("Last layer is not output layer");
            }
    Severity: Minor
    Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method trainOn has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public Pair<Integer, Integer> trainOn(DataSet dataSet, double learningRate) {
            int t = 0, f = 0;
            if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
                throw new RuntimeException("Last layer is not output layer");
            }
    Severity: Minor
    Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

      Method trainAndGetWA has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public List<DataEntry> trainAndGetWA(DataSet dataSet, double learningRate) {
              LinkedList<DataEntry> entries = new LinkedList<>();
              if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
                  throw new RuntimeException("Last layer is not output layer");
              }
      Severity: Minor
      Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

        Method parseLine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static AbstractLayer parseLine(String line) {
                String[] tokens = line.split(" ");
                switch (tokens[0]) {
                    case "D":
                        int inputSize = Integer.parseInt(tokens[1]);
        Severity: Minor
        Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

          Method testOn has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public Pair<Integer, Integer> testOn(DataSet dataSet) {
                  int t = 0, f = 0;
                  for (DataEntry dataEntry : dataSet.split) {
                      layers[0].input = dataEntry.values;
                      for (int i = 0; i < layers.length; i++) {
          Severity: Minor
          Found in src/main/java/huzpsb/ll4j/model/Model.java - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

              public List<DataEntry> testAndGetWA(DataSet dataSet) {
                  LinkedList<DataEntry> entries = new LinkedList<>();
                  for (DataEntry dataEntry : dataSet.split) {
                      layers[0].input = dataEntry.values;
                      for (int i = 0; i < layers.length; i++) {
          Severity: Minor
          Found in src/main/java/huzpsb/ll4j/model/Model.java - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

              public static AbstractLayer parseLine(String line) {
                  String[] tokens = line.split(" ");
                  switch (tokens[0]) {
                      case "D":
                          int inputSize = Integer.parseInt(tokens[1]);
          Severity: Minor
          Found in src/main/java/huzpsb/ll4j/model/Model.java - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

                      for (int i = 0; i < layers.length; i++) {
                          layers[i].training = true;
                          layers[i].forward();
                          if (i < layers.length - 1) {
                              layers[i + 1].input = layers[i].output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 40..46
          src/main/java/huzpsb/ll4j/model/Model.java on lines 104..110
          src/main/java/huzpsb/ll4j/model/Model.java on lines 127..133

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

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

                      for (int i = 0; i < layers.length; i++) {
                          layers[i].training = false;
                          layers[i].forward();
                          if (i < layers.length - 1) {
                              layers[i + 1].input = layers[i].output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 40..46
          src/main/java/huzpsb/ll4j/model/Model.java on lines 76..82
          src/main/java/huzpsb/ll4j/model/Model.java on lines 104..110

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

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

                      for (int i = 0; i < layers.length; i++) {
                          layers[i].training = false;
                          layers[i].forward();
                          if (i < layers.length - 1) {
                              layers[i + 1].input = layers[i].output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 40..46
          src/main/java/huzpsb/ll4j/model/Model.java on lines 76..82
          src/main/java/huzpsb/ll4j/model/Model.java on lines 127..133

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

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

                      for (int i = 0; i < layers.length; i++) {
                          layers[i].training = true;
                          layers[i].forward();
                          if (i < layers.length - 1) {
                              layers[i + 1].input = layers[i].output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 76..82
          src/main/java/huzpsb/ll4j/model/Model.java on lines 104..110
          src/main/java/huzpsb/ll4j/model/Model.java on lines 127..133

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

          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 = layers.length - 1; i >= 0; i--) {
                          layers[i].backward();
                          layers[i].update(learningRate);
                          if (i > 0) {
                              layers[i - 1].output_error = layers[i].input_error;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 1 other location - About 1 hr to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 55..61

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

          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 = layers.length - 1; i >= 0; i--) {
                          layers[i].backward();
                          layers[i].update(learningRate);
                          if (i > 0) {
                              layers[i - 1].output_error = layers[i].input_error;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 1 other location - About 1 hr to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 89..95

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

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

                  for (AbstractLayer layer : layers) {
                      layer.training = false;
                      layer.input = input;
                      layer.forward();
                      input = layer.output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 35 mins to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 148..153
          src/main/java/huzpsb/ll4j/model/Model.java on lines 176..181
          src/main/java/huzpsb/ll4j/model/Model.java on lines 187..192

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

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

                  for (AbstractLayer layer : layers) {
                      layer.training = false;
                      layer.input = input;
                      layer.forward();
                      input = layer.output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 35 mins to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 148..153
          src/main/java/huzpsb/ll4j/model/Model.java on lines 161..166
          src/main/java/huzpsb/ll4j/model/Model.java on lines 187..192

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

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

                  for (AbstractLayer layer : layers) {
                      layer.training = false;
                      layer.input = input;
                      layer.forward();
                      input = layer.output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 35 mins to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 148..153
          src/main/java/huzpsb/ll4j/model/Model.java on lines 161..166
          src/main/java/huzpsb/ll4j/model/Model.java on lines 176..181

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

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

                  for (AbstractLayer layer : layers) {
                      layer.training = false;
                      layer.input = input;
                      layer.forward();
                      input = layer.output;
          Severity: Major
          Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 35 mins to fix
          src/main/java/huzpsb/ll4j/model/Model.java on lines 161..166
          src/main/java/huzpsb/ll4j/model/Model.java on lines 176..181
          src/main/java/huzpsb/ll4j/model/Model.java on lines 187..192

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

          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