SiLeBAT/FSK-Lab

View on GitHub
de.bund.bfr.knime.foodprocess.view/src/de/bund/bfr/knime/foodprocess/view/MyChartCreator.java

Summary

Maintainability
F
5 days
Test Coverage

Method createChart has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
Open

    private JFreeChart createChart(DataTableSpec spec, List<DataRow> rowList, DataTable table,
            List<String> usedParameters, String xUnits, boolean equidistantProcesses, boolean plotLines, boolean plotPoints) {
        LinkedList<XYDataset> dataSets = new LinkedList<XYDataset>();
        LinkedList<XYDataset> equiDataSets = new LinkedList<XYDataset>();
        int timeIndex = spec.findColumnIndex(AttributeUtilities.TIME + " [s]");

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

    private JFreeChart createChart(DataTableSpec spec, List<DataRow> rowList, DataTable table,
            List<String> usedParameters, String xUnits, boolean equidistantProcesses, boolean plotLines, boolean plotPoints) {
        LinkedList<XYDataset> dataSets = new LinkedList<XYDataset>();
        LinkedList<XYDataset> equiDataSets = new LinkedList<XYDataset>();
        int timeIndex = spec.findColumnIndex(AttributeUtilities.TIME + " [s]");

Method createChart has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public JFreeChart createChart(PCMLDocument pcmlDoc, List<String> usedParameters, String xUnits,
            boolean equidistantProcesses, boolean plotLines, boolean plotPoints) {
        Map<NameAndDbId, Integer> columns = PCMLDataTable.createColumnMap(pcmlDoc);
        Map<String, ProcessNode> processNodes = PCMLDataTable.createProcessNodeMap(pcmlDoc);
        DataTableSpec spec = PCMLDataTable.createOutSpec(columns);

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 MyChartCreator.java has 335 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 getColor has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private Color getColor(String param, Color lastBG, String lastParam) {
        Color bg = Color.WHITE;
        @SuppressWarnings("unused")
        Color fg = Color.BLACK;
        if (JCheckboxWithObject.isTemperature(param)) {

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

    public JFreeChart createChart(PCMLDocument pcmlDoc, List<String> usedParameters, String xUnits,
            boolean equidistantProcesses, boolean plotLines, boolean plotPoints) {
        Map<NameAndDbId, Integer> columns = PCMLDataTable.createColumnMap(pcmlDoc);
        Map<String, ProcessNode> processNodes = PCMLDataTable.createProcessNodeMap(pcmlDoc);
        DataTableSpec spec = PCMLDataTable.createOutSpec(columns);

Method getColor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private Color getColor(String param, Color lastBG, String lastParam) {
        Color bg = Color.WHITE;
        @SuppressWarnings("unused")
        Color fg = Color.BLACK;
        if (JCheckboxWithObject.isTemperature(param)) {

Method setBounds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private void setBounds(List<NumberAxis> axes) {
        Double lb = null;
        Double ub = null;
        for (NumberAxis na : axes) {
            if (lb == null || na.getLowerBound() < lb)

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

    private JFreeChart createChart(DataTableSpec spec, List<DataRow> rowList, DataTable table,
            List<String> usedParameters, String xUnits, boolean equidistantProcesses, boolean plotLines, boolean plotPoints) {

Avoid deeply nested control flow statements.
Open

                        if (!p.equals(process)) {
                            newP = true;
                            if (process != null) {
                                if (!pFilled) {
                                    ranges.add(new Point2D.Double(processStart, time));

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

    public JFreeChart createChart(DataTable table, List<String> usedParameters, String xUnits,
            boolean equidistantProcesses, boolean plotLines, boolean plotPoints) {

Avoid deeply nested control flow statements.
Open

                        if (!paramCell.isMissing()) {
                            Double val = ((DoubleCell) paramCell).getDoubleValue();
                            if (param2Cumulate && !newP) {
                                if (timeSeries.containsKey(time))
                                    timeSeries.put(time, val + timeSeries.get(time));

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

    public JFreeChart createChart(PCMLDocument pcmlDoc, List<String> usedParameters, String xUnits,
            boolean equidistantProcesses, boolean plotLines, boolean plotPoints) {

Consider simplifying this complex logical expression.
Open

            if (paramIndex >= 0) {
                LinkedHashMap<Double, Double> timeSeries = new LinkedHashMap<Double, Double>();
                boolean paramDone = false;
                String process = null, lastP = null;

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

    private LinkedHashMap<Double, Double> getEquiSeries(LinkedHashMap<Double, Double> timeSeries,
            LinkedList<Point2D.Double> ranges) {
        LinkedHashMap<Double, Double> result = new LinkedHashMap<Double, Double>();
        for (Double time : timeSeries.keySet()) {
            Double value = timeSeries.get(time);

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

    private JFreeChart createChart(DataTableSpec spec, List<DataRow> rowList, DataTable table,

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

    private Color getColor(String param, Color lastBG, String lastParam) {

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

    public JFreeChart createChart(PCMLDocument pcmlDoc, List<String> usedParameters, String xUnits,

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

                    if (timeColumn == null || !timeColumn.equals(column))
                        rowData.put(column, cursor.getTextValue());
                    else
                        curTime = (cursor.getTextValue() != null && !cursor.getTextValue().equalsIgnoreCase("null"))
                                ? Double.valueOf(cursor.getTextValue()) : 0.0;
de.bund.bfr.knime.foodprocess.pcml/src/de/bund/bfr/knime/pcml/node/pcmltotable/PCMLDataTable.java on lines 105..109

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

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

        } else if (JCheckboxWithObject.isMatrix(param)) {
            if (lastParam != null && JCheckboxWithObject.isMatrix(lastParam))
                bg = lastBG.brighter();
            else
                bg = Color.DARK_GRAY;
de.bund.bfr.knime.foodprocess.view/src/de/bund/bfr/knime/foodprocess/view/MyChartCreator.java on lines 342..348
de.bund.bfr.knime.foodprocess.view/src/de/bund/bfr/knime/foodprocess/view/MyChartCreator.java on lines 330..336

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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        } else if (JCheckboxWithObject.isAgent(param)) {
            if (lastParam != null && JCheckboxWithObject.isAgent(lastParam))
                bg = lastBG.darker();
            else
                bg = Color.RED;
de.bund.bfr.knime.foodprocess.view/src/de/bund/bfr/knime/foodprocess/view/MyChartCreator.java on lines 342..348
de.bund.bfr.knime.foodprocess.view/src/de/bund/bfr/knime/foodprocess/view/MyChartCreator.java on lines 336..342

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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        } else if (JCheckboxWithObject.isWithUnit(param)) {
            if (lastParam != null && JCheckboxWithObject.isWithUnit(lastParam))
                bg = lastBG.brighter();
            else
                bg = Color.LIGHT_GRAY;
de.bund.bfr.knime.foodprocess.view/src/de/bund/bfr/knime/foodprocess/view/MyChartCreator.java on lines 336..342
de.bund.bfr.knime.foodprocess.view/src/de/bund/bfr/knime/foodprocess/view/MyChartCreator.java on lines 330..336

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 (timeColumn == null) {
                    // increment time by the time step of the process node
                    double stepWidth = processNode.getParameters().getDuration()
                            / processNode.getParameters().getNumberComputations();
                    time = time + stepWidth;
de.bund.bfr.knime.foodprocess.pcml/src/de/bund/bfr/knime/pcml/node/pcmltotable/PCMLDataTable.java on lines 118..123

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

There are no issues that match your filters.

Category
Status