SiLeBAT/FSK-Lab

View on GitHub
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/manualmodelconf/ManualModelEditorNodeDialog.java

Summary

Maintainability
F
1 wk
Test Coverage

Method loadSettingsFrom has a Cognitive Complexity of 164 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    protected void loadSettingsFrom(NodeSettingsRO settings,
            BufferedDataTable[] inData) throws NotConfigurableException {
        String mStr = null;
        String tsStr = null;

Cognitive Complexity

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

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

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

Further reading

Method getDiff has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
Open

    private HashMap<Integer, HashMap<String, Object[]>> getDiff(PmmXmlDoc inputDoc, PmmXmlDoc outputDoc) {
        HashMap<Integer, HashMap<String, Object[]>> result = new HashMap<>();
           Javers javers = JaversBuilder.javers().build();

           /*

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

    @Override
    protected void loadSettingsFrom(NodeSettingsRO settings,
            BufferedDataTable[] inData) throws NotConfigurableException {
        String mStr = null;
        String tsStr = null;

File ManualModelEditorNodeDialog.java has 355 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 setValue has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    private void setValue(Object o, String fieldName, Object oldValue, Object newValue) {
        // todo: checken, ob "oldValue = oldValue"?
        try {
            if (fieldName.indexOf("#") >= 0) { // z.B. '#parameter#elementSet/2'
                String fn = fieldName.substring(0, fieldName.indexOf("#"));// "parameter"

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

    private void checkSec(HashMap<ParametricModel, HashMap<String, ParametricModel>> m_secondaryModels, int id, HashMap<String, Object[]> hm) {
        boolean idFound = false;
        for (HashMap<String, ParametricModel> sm : m_secondaryModels.values()) {
            for (ParametricModel pm : sm.values()) {
                if (pm.estModelId == id) {

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

    private void setValue(Object o, String fieldName, Object oldValue, Object newValue) {
        // todo: checken, ob "oldValue = oldValue"?
        try {
            if (fieldName.indexOf("#") >= 0) { // z.B. '#parameter#elementSet/2'
                String fn = fieldName.substring(0, fieldName.indexOf("#"));// "parameter"

Method getDiff has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private HashMap<Integer, HashMap<String, Object[]>> getDiff(PmmXmlDoc inputDoc, PmmXmlDoc outputDoc) {
        HashMap<Integer, HashMap<String, Object[]>> result = new HashMap<>();
           Javers javers = JaversBuilder.javers().build();

           /*

Avoid deeply nested control flow statements.
Open

                            if (hasM2) {
                                ParametricModel pm2 = new ParametricModel(row, 2, null);
                                m2EstID = pm2.estModelId;
                                if (!m2s.containsKey(m2EstID)) {
                                    m2s.put(m2EstID, pm2);                                

Avoid deeply nested control flow statements.
Open

                                if (m1s.containsKey(id)) {
                                    for (String property : hm.keySet()) {
                                        Object[] o = hm.get(property);
                                        if (o != null) setValue(m1s.get(id), property, o[0], o[1]);
                                    }

Avoid deeply nested control flow statements.
Open

                            if (!m1s.containsKey(m1EstID)) {
                                m1s.put(m1EstID, pm1);                                
                            }

Avoid deeply nested control flow statements.
Open

                            if (!oneStepFitTs.containsKey(m1EstID)) oneStepFitTs.put(m1EstID, new HashSet<Integer>());

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

    private void checkSec(HashMap<ParametricModel, HashMap<String, ParametricModel>> m_secondaryModels, ParametricModel pm) {
        boolean idFound = false;
        for (HashMap<String, ParametricModel> sm : m_secondaryModels.values()) {
            for (String dep : sm.keySet()) {
                ParametricModel pms = sm.get(dep);

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 (mOut.estModelId == mIn.estModelId) {
                                Diff diff = javers.compare(mIn, mOut);
                                if (diff.getChanges().size() > 0) {
                                    System.out.println(mOut.estModelId + "\n" + diff);
                                    for (ValueChange c : diff.getChangesByType(ValueChange.class)) {

Avoid deeply nested control flow statements.
Open

                        if (o != null) setValue(pm, property, o[0], o[1]);

Avoid deeply nested control flow statements.
Open

                            if (diff.getChanges().size() == 0) {
                                doc.remove(pxecL);
                                break;
                            }

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

    private void checkSec(HashMap<ParametricModel, HashMap<String, ParametricModel>> m_secondaryModels, int id, HashMap<String, Object[]> hm) {

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

    private HashMap<Integer, HashMap<String, Object[]>> getDiff(PmmXmlDoc inputDoc, PmmXmlDoc outputDoc) {

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

    protected void loadSettingsFrom(NodeSettingsRO settings,

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

    private void setValue(Object o, String fieldName, Object oldValue, Object newValue) {

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

0 is a valid index, but is ignored by this check.
Open

                                        if (gid.indexOf("#") > 0) gid = gid.substring(gid.indexOf("#") + 1) + "#"; // estLit#elementSet/0#

Most checks against an indexOf value compare it with -1 because 0 is a valid index. Any checks which look for values >0 ignore the first element, which is likely a bug. If the intent is merely to check inclusion of a value in a String or a List, consider using the contains method instead.

This rule raises an issue when an indexOf value retrieved either from a String or a List is tested against >0.

Noncompliant Code Example

String color = "blue";
String name = "ishmael";

List<String> strings = new ArrayList<String> ();
strings.add(color);
strings.add(name);

if (strings.indexOf(color) > 0) {  // Noncompliant
  // ...
}
if (name.indexOf("ish") > 0) { // Noncompliant
  // ...
}
if (name.indexOf("ae") > 0) { // Noncompliant
  // ...
}

Compliant Solution

String color = "blue";
String name = "ishmael";

List<String> strings = new ArrayList<String> ();
strings.add(color);
strings.add(name);

if (strings.indexOf(color) > -1) {
  // ...
}
if (name.indexOf("ish") >= 0) {
  // ...
}
if (name.contains("ae") {
  // ...
}

0 is a valid index, but is ignored by this check.
Open

                                        if (gid.indexOf("#") > 0) gid = gid.substring(gid.indexOf("#") + 1) + "#"; // estLit#elementSet/0#

Most checks against an indexOf value compare it with -1 because 0 is a valid index. Any checks which look for values >0 ignore the first element, which is likely a bug. If the intent is merely to check inclusion of a value in a String or a List, consider using the contains method instead.

This rule raises an issue when an indexOf value retrieved either from a String or a List is tested against >0.

Noncompliant Code Example

String color = "blue";
String name = "ishmael";

List<String> strings = new ArrayList<String> ();
strings.add(color);
strings.add(name);

if (strings.indexOf(color) > 0) {  // Noncompliant
  // ...
}
if (name.indexOf("ish") > 0) { // Noncompliant
  // ...
}
if (name.indexOf("ae") > 0) { // Noncompliant
  // ...
}

Compliant Solution

String color = "blue";
String name = "ishmael";

List<String> strings = new ArrayList<String> ();
strings.add(color);
strings.add(name);

if (strings.indexOf(color) > -1) {
  // ...
}
if (name.indexOf("ish") >= 0) {
  // ...
}
if (name.contains("ae") {
  // ...
}

0 is a valid index, but is ignored by this check.
Open

                                        if (gid.indexOf("#") > 0) gid = gid.substring(gid.indexOf("#") + 1) + "#"; // parameter#elementSet/2#

Most checks against an indexOf value compare it with -1 because 0 is a valid index. Any checks which look for values >0 ignore the first element, which is likely a bug. If the intent is merely to check inclusion of a value in a String or a List, consider using the contains method instead.

This rule raises an issue when an indexOf value retrieved either from a String or a List is tested against >0.

Noncompliant Code Example

String color = "blue";
String name = "ishmael";

List<String> strings = new ArrayList<String> ();
strings.add(color);
strings.add(name);

if (strings.indexOf(color) > 0) {  // Noncompliant
  // ...
}
if (name.indexOf("ish") > 0) { // Noncompliant
  // ...
}
if (name.indexOf("ae") > 0) { // Noncompliant
  // ...
}

Compliant Solution

String color = "blue";
String name = "ishmael";

List<String> strings = new ArrayList<String> ();
strings.add(color);
strings.add(name);

if (strings.indexOf(color) > -1) {
  // ...
}
if (name.indexOf("ish") >= 0) {
  // ...
}
if (name.contains("ae") {
  // ...
}

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

                                        if (gid.indexOf("#") > 0) gid = gid.substring(gid.indexOf("#") + 1) + "#"; // estLit#elementSet/0#
                                        else {
                                            System.err.println(gid);
                                            //gid = "";
                                        }
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/manualmodelconf/ManualModelEditorNodeDialog.java on lines 345..349

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

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 (gid.indexOf("#") > 0) gid = gid.substring(gid.indexOf("#") + 1) + "#"; // estLit#elementSet/0#
                                        else {
                                            System.err.println(gid);
                                            //gid = "";
                                        }
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/manualmodelconf/ManualModelEditorNodeDialog.java on lines 356..360

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

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 (hasM1 && hasM2) finalSchema = KnimeSchema.merge(inSchema1, inSchema2);
                else if (hasM1) finalSchema = inSchema1;
                else if (hasM2) finalSchema = inSchema2;
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/manualmodelconf/ManualModelConfNodeModel.java on lines 356..358

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

        try {
            if (settings.containsKey(ManualModelConfNodeModel.PARAM_XMLSTRING)) {
                mStr = settings.getString(ManualModelConfNodeModel.PARAM_XMLSTRING);
            }
        }
de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/manualmodelconf/ManualModelConfNodeDialog.java on lines 82..89

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