SiLeBAT/FSK-Lab

View on GitHub
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/ParameterOptimizer.java

Summary

Maintainability
F
5 days
Test Coverage

Method optimize has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
Open

    public void optimize(AtomicInteger progress, int nParameterSpace,
            int nLevenberg, boolean stopWhenSuccessful) {
        List<Double> paramMin = new ArrayList<>();
        List<Integer> paramStepCount = new ArrayList<>();
        List<Double> paramStepSize = new ArrayList<>();

Cognitive Complexity

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

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

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

Further reading

File ParameterOptimizer.java has 497 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*******************************************************************************
 * Copyright (c) 2015 Federal Institute for Risk Assessment (BfR), Germany
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by

Method optimize has 137 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void optimize(AtomicInteger progress, int nParameterSpace,
            int nLevenberg, boolean stopWhenSuccessful) {
        List<Double> paramMin = new ArrayList<>();
        List<Integer> paramStepCount = new ArrayList<>();
        List<Double> paramStepSize = new ArrayList<>();

Method useCurrentResults has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private void useCurrentResults(List<Double> startValues) {
        double cost = optimizerValues.getCost();

        parameterValues = new ArrayList<>(parameters.size());
        sse = cost * cost;

Method createChangeLists has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private List<List<Integer>> createChangeLists() {
            int n = arguments.length;
            boolean done = false;
            List<List<Integer>> changeLists = new ArrayList<>();
            List<Integer> list = new ArrayList<>(Collections.nCopies(n, -1));

Method evalWithSingularityCheck has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        private double evalWithSingularityCheck(int index, double[] argValues,
                double[] paramValues) throws ParseException {
            for (int i = 0; i < parameters.length; i++) {
                parser.setVarValue(parameters[i], paramValues[i]);
            }

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

        private double evalWithSingularityCheck(int index, double[] argValues,
                double[] paramValues) throws ParseException {
            for (int i = 0; i < parameters.length; i++) {
                parser.setVarValue(parameters[i], paramValues[i]);
            }

Method createChangeLists has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        private List<List<Integer>> createChangeLists() {
            int n = arguments.length;
            boolean done = false;
            List<List<Integer>> changeLists = new ArrayList<>();
            List<Integer> list = new ArrayList<>(Collections.nCopies(n, -1));

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

    private void useCurrentResults(List<Double> startValues) {
        double cost = optimizerValues.getCost();

        parameterValues = new ArrayList<>(parameters.size());
        sse = cost * cost;

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

        @Override
        public double[] value(double[] point) throws IllegalArgumentException {
            double[] retValue = new double[targetValues.length];

            for (int i = 0; i < parameters.length; i++) {

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

Refactor this method to reduce its Cognitive Complexity from 75 to the 15 allowed.
Open

    public void optimize(AtomicInteger progress, int nParameterSpace,

Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

See

Refactor this method to reduce its Cognitive Complexity from 24 to the 15 allowed.
Open

        private List<List<Integer>> createChangeLists() {

Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

See

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

            for (int i = 0; i < targetValues.size(); i++) {
                this.targetValues[i] = targetValues.get(i);

                for (int j = 0; j < arguments.size(); j++) {
                    this.argumentValues[i][j] = argumentValues.get(j).get(i);
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/ParameterOptimizer.java on lines 605..611

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

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 < targetValues.size(); i++) {
                this.targetValues[i] = targetValues.get(i);

                for (int j = 0; j < arguments.size(); j++) {
                    this.argumentValues[i][j] = argumentValues.get(j).get(i);
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/ParameterOptimizer.java on lines 540..546

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

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 < arguments.length; i++) {
                    double d = list.get(i) * MathUtilities.EPSILON;

                    parser.setVarValue(arguments[i], argValues[i] + d);
                }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/ParameterOptimizer.java on lines 641..645

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 < arguments.length; i++) {
                    double d = list.get(i) * MathUtilities.EPSILON;

                    parser.setVarValue(arguments[i], argValues[i] + d);
                }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/ParameterOptimizer.java on lines 655..659

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

            for (int i = 0; i < parameters.size(); i++) {
                List<Double> nullList = Collections.nCopies(parameters.size(),
                        null);

                covariances.add(nullList);
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/modelestimation/OneStepEstimationThread.java on lines 287..292
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/modelestimation/PrimaryEstimationThread.java on lines 141..146
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/modelestimation/SecondaryEstimationThread.java on lines 261..266

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

                for (int j = 0; j < arguments.size(); j++) {
                    parser.setVarValue(arguments.get(j), argumentValues.get(j)
                            .get(i));
                }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/MathUtilities.java on lines 227..229

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

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

            for (int i = 0; i < parameters.length; i++) {
                parser.setVarValue(parameters[i], paramValues[i]);
            }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/ParameterOptimizer.java on lines 553..555
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/js/common/Param.java on lines 194..196
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/js/modelplotter/ModelPlotterViewValue.java on lines 355..357

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

            for (int i = 0; i < parameters.length; i++) {
                parser.setVarValue(parameters[i], point[i]);
            }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/math/ParameterOptimizer.java on lines 636..638
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/js/common/Param.java on lines 194..196
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/js/modelplotter/ModelPlotterViewValue.java on lines 355..357

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