de.bund.bfr.knime.pmm.nodes/src/de/bund/bfr/knime/pmm/sbmlwriter/Test.java
Method actionPerformed
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
Open
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == computeButton) {
UnitDefinition unit = new UnitDefinition(idField.getText().trim(),
LEVEL, VERSION);
- Read upRead up
- Create a ticketCreate a ticket
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 actionPerformed
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == computeButton) {
UnitDefinition unit = new UnitDefinition(idField.getText().trim(),
LEVEL, VERSION);
- Create a ticketCreate a ticket
Refactor this method to reduce its Cognitive Complexity from 29 to the 15 allowed. Open
Open
public void actionPerformed(ActionEvent e) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Use static access with "javax.swing.WindowConstants" for "EXIT_ON_CLOSE". Open
Open
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
In the interest of code clarity, static
members of a base
class should never be accessed using a derived type's name.
Doing so is confusing and could create the illusion that two different static members exist.
Noncompliant Code Example
class Parent { public static int counter; } class Child extends Parent { public Child() { Child.counter++; // Noncompliant } }
Compliant Solution
class Parent { public static int counter; } class Child extends Parent { public Child() { Parent.counter++; } }