SiLeBAT/FSK-Lab

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

Summary

Maintainability
F
4 days
Test Coverage

File ModelCombiner.java has 420 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 updateParamValues has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    private static void updateParamValues(List<KnimeTuple> tuples,
            Map<KnimeTuple, List<KnimeTuple>> tupleCombinations) {
        Map<Integer, Map<String, Double>> paramSums = new LinkedHashMap<>();
        Map<Integer, Map<String, Integer>> paramCounts = new LinkedHashMap<>();
        Map<Integer, Map<String, Double>> paramValues = new LinkedHashMap<>();

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

    private static void updateMetaData(List<KnimeTuple> tuples, Map<KnimeTuple, List<KnimeTuple>> tupleCombinations) {
        Map<Integer, Set<String>> organisms = new LinkedHashMap<>();
        Map<Integer, Set<String>> matrices = new LinkedHashMap<>();
        Map<Integer, Set<String>> organismDetails = new LinkedHashMap<>();
        Map<Integer, Set<String>> matrixDetails = new LinkedHashMap<>();

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

    private static void updatePrimaryIndepRanges(List<KnimeTuple> tuples,
            Map<KnimeTuple, List<KnimeTuple>> tupleCombinations) {
        Map<Integer, Map<String, Double>> indepMin = new LinkedHashMap<>();
        Map<Integer, Map<String, Double>> indepMax = new LinkedHashMap<>();

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

    private static void updateMetaData(List<KnimeTuple> tuples, Map<KnimeTuple, List<KnimeTuple>> tupleCombinations) {
        Map<Integer, Set<String>> organisms = new LinkedHashMap<>();
        Map<Integer, Set<String>> matrices = new LinkedHashMap<>();
        Map<Integer, Set<String>> organismDetails = new LinkedHashMap<>();
        Map<Integer, Set<String>> matrixDetails = new LinkedHashMap<>();

Method updateParamValues has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static void updateParamValues(List<KnimeTuple> tuples,
            Map<KnimeTuple, List<KnimeTuple>> tupleCombinations) {
        Map<Integer, Map<String, Double>> paramSums = new LinkedHashMap<>();
        Map<Integer, Map<String, Integer>> paramCounts = new LinkedHashMap<>();
        Map<Integer, Map<String, Double>> paramValues = new LinkedHashMap<>();

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

    private static Map<KnimeTuple, List<KnimeTuple>> getTuplesToCombine(List<KnimeTuple> tuples, boolean containsData) {
        KnimeSchema outSchema = null;

        if (containsData) {
            outSchema = SchemaFactory.createM1DataSchema();

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

    private static void updatePrimaryIndepRanges(List<KnimeTuple> tuples,
            Map<KnimeTuple, List<KnimeTuple>> tupleCombinations) {
        Map<Integer, Map<String, Double>> indepMin = new LinkedHashMap<>();
        Map<Integer, Map<String, Double>> indepMax = new LinkedHashMap<>();

Method getTuplesToCombine has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static Map<KnimeTuple, List<KnimeTuple>> getTuplesToCombine(List<KnimeTuple> tuples, boolean containsData) {
        KnimeSchema outSchema = null;

        if (containsData) {
            outSchema = SchemaFactory.createM1DataSchema();

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

    private static void updateMetaData(List<KnimeTuple> tuples, Map<KnimeTuple, List<KnimeTuple>> tupleCombinations) {

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 18 to the 15 allowed.
Open

    private static Map<KnimeTuple, List<KnimeTuple>> getTuplesToCombine(List<KnimeTuple> tuples, boolean containsData) {

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 38 to the 15 allowed.
Open

    private static void updateParamValues(List<KnimeTuple> tuples,

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 78 to the 15 allowed.
Open

    public ModelCombiner(List<KnimeTuple> tuples, boolean containsData, Map<String, String> initParams,

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 30 to the 15 allowed.
Open

    private static void updatePrimaryIndepRanges(List<KnimeTuple> tuples,

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

                for (PmmXmlElementConvertable el : tuple.getPmmXml(Model1Schema.ATT_INDEPENDENT).getElementSet()) {
                    IndepXml indep = (IndepXml) el;

                    min.put(indep.name, Double.POSITIVE_INFINITY);
                    max.put(indep.name, Double.NEGATIVE_INFINITY);
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/modelanddatajoiner/CombinedJoiner.java on lines 485..491
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/modelanddatajoiner/CombinedJoiner.java on lines 502..508
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/modelanddatajoiner/PrimaryJoiner.java on lines 367..373
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/modelanddatajoiner/SecondaryJoiner.java on lines 474..480

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

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

                if (!errors.containsKey(name)) {
                    errors.put(name, param.error);
                } else if (!Objects.equals(errors.get(name), param.error)) {
                    errors.put(name, null);
                }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 450..454
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 456..460

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

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

                if (!ps.containsKey(name)) {
                    ps.put(name, param.P);
                } else if (!Objects.equals(ps.get(name), param.P)) {
                    ps.put(name, null);
                }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 444..448
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 450..454

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

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

                if (!ts.containsKey(name)) {
                    ts.put(name, param.t);
                } else if (!Objects.equals(ts.get(name), param.t)) {
                    ts.put(name, null);
                }
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 444..448
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 456..460

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

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 (max != null) {
                            if (original.max != null) {
                                original.max = Math.max(original.max, max);
                            } else {
                                original.max = max;
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 141..147

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

                        if (min != null) {
                            if (original.min != null) {
                                original.min = Math.min(original.min, min);
                            } else {
                                original.min = min;
de.bund.bfr.knime.pmm.common/src/de/bund/bfr/knime/pmm/common/ModelCombiner.java on lines 149..155

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

There are no issues that match your filters.

Category
Status