File MyDBPanel.java
has 766 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
- Create a ticketCreate a ticket
MyDBPanel
has 65 methods (exceeds 20 allowed). Consider refactoring. Open
public class MyDBPanel extends JPanel {
/**
*
*/
- Create a ticketCreate a ticket
Method initComponents
has 209 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
ResourceBundle bundle = ResourceBundle.getBundle("org.hsh.bfr.db.gui.PanelProps_" + DBKernel.getLanguage());
button12 = new JButton();
panel1 = new JPanel();
- Create a ticketCreate a ticket
Method handleSuchfeldChange
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
void handleSuchfeldChange(final KeyEvent e, final boolean doFilter) {
if (!filterChangeAllowed) return;
if (isFormVisible()) {
return;
}
- 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 button11ActionPerformed
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
void button11ActionPerformed(ActionEvent e) {
if (isFormVisible()) {
return;
}
if (parentDialog != null) {
- 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 button8ActionPerformed
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private void button8ActionPerformed(ActionEvent e) {
//myDBTable1.myPrint();
String tt = "";
tt += "ID\t" + GuiMessages.getString("Benutzer") + "\t" + GuiMessages.getString("Letzte Aenderung") + "\n";
tt += "-----------------------------\n\n";
- 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 paintComponent
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void paintComponent( Graphics g ) {
MyTable myT = myDBTable1.getActualTable();
if (myDBTable1 != null && myT != null) {
button1.setEnabled(!myT.isReadOnly());
- 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 button3ActionPerformed
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private void button3ActionPerformed(ActionEvent e) {
if (isFormVisible()) {
return;
}
int id = myDBTable1.getSelectedID();
- 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 button11ActionPerformed
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
void button11ActionPerformed(ActionEvent e) {
if (isFormVisible()) {
return;
}
if (parentDialog != null) {
- Create a ticketCreate a ticket
Method handleSuchfeldChange
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
void handleSuchfeldChange(final KeyEvent e, final boolean doFilter) {
if (!filterChangeAllowed) return;
if (isFormVisible()) {
return;
}
- Create a ticketCreate a ticket
Method button8ActionPerformed
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void button8ActionPerformed(ActionEvent e) {
//myDBTable1.myPrint();
String tt = "";
tt += "ID\t" + GuiMessages.getString("Benutzer") + "\t" + GuiMessages.getString("Letzte Aenderung") + "\n";
tt += "-----------------------------\n\n";
- Create a ticketCreate a ticket
Method setListVisible
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public MyDBTable setListVisible(boolean visible, MyTable myT2, Object[][] t1Conditions, Object[][] t2Conditions, Integer row) {
gmRow = row;
this.t1Conditions = t1Conditions;
this.t2Conditions = t2Conditions;
splitPane2.getRightComponent().setVisible(visible);
- Create a ticketCreate a ticket
Method paintComponent
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void paintComponent( Graphics g ) {
MyTable myT = myDBTable1.getActualTable();
if (myDBTable1 != null && myT != null) {
button1.setEnabled(!myT.isReadOnly());
- Create a ticketCreate a ticket
Method gotoFind
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private void gotoFind(int increment) {
if (isFormVisible()) {
return;
}
- 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 setListVisible
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public MyDBTable setListVisible(boolean visible, MyTable myT2, Object[][] t1Conditions, Object[][] t2Conditions, Integer row) {
- Create a ticketCreate a ticket
Method button12ActionPerformed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private void button12ActionPerformed(ActionEvent e) {
if (myDBTable1.getActualTable().isHasForm()) {
if (isFormVisible()) {
myDBForm1.save();
try {
- 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 setLeftComponent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public void setLeftComponent(MyTable myNewT) {
if (myNewT.isHasForm()) {
//MyDBForm form = new MyDBForm();
myDBForm1.setTable(myNewT);
splitPane2.setLeftComponent(myDBForm1);
- 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 setListVisible
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public MyDBTable setListVisible(boolean visible, MyTable myT2, Object[][] t1Conditions, Object[][] t2Conditions, Integer row) {
gmRow = row;
this.t1Conditions = t1Conditions;
this.t2Conditions = t2Conditions;
splitPane2.getRightComponent().setVisible(visible);
- 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
Refactor this method to reduce its Cognitive Complexity from 36 to the 15 allowed. Open
void handleSuchfeldChange(final KeyEvent e, final boolean doFilter) {
- 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
Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed. Open
private void button8ActionPerformed(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
Refactor this method to reduce its Cognitive Complexity from 29 to the 15 allowed. Open
void button11ActionPerformed(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
Make "t2Conditions" transient or serializable. Open
private Object[][] t2Conditions = null;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Fields in a Serializable
class must themselves be either Serializable
or transient
even if the class is
never explicitly serialized or deserialized. For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly
Serializable
object with non-transient, non-serializable data members could cause program crashes, and open the door to attackers. In
general a Serializable
class is expected to fulfil its contract and not have an unexpected behaviour when an instance is serialized.
This rule raises an issue on non-Serializable
fields, and on collection fields when they are not private
(because they
could be assigned non-Serializable
values externally), and when they are assigned non-Serializable
types within the
class.
Noncompliant Code Example
public class Address { //... } public class Person implements Serializable { private static final long serialVersionUID = 1905122041950251207L; private String name; private Address address; // Noncompliant; Address isn't serializable }
Compliant Solution
public class Address implements Serializable { private static final long serialVersionUID = 2405172041950251807L; } public class Person implements Serializable { private static final long serialVersionUID = 1905122041950251207L; private String name; private Address address; }
Exceptions
The alternative to making all members serializable
or transient
is to implement special methods which take on the
responsibility of properly serializing and de-serializing the object. This rule ignores classes which implement the following methods:
private void writeObject(java.io.ObjectOutputStream out) throws IOException private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
See
- MITRE, CWE-594 - Saving Unserializable Objects to Disk
- Oracle Java 6, Serializable
- Oracle Java 7, Serializable
Make "t1Conditions" transient or serializable. Open
private Object[][] t1Conditions = null;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Fields in a Serializable
class must themselves be either Serializable
or transient
even if the class is
never explicitly serialized or deserialized. For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly
Serializable
object with non-transient, non-serializable data members could cause program crashes, and open the door to attackers. In
general a Serializable
class is expected to fulfil its contract and not have an unexpected behaviour when an instance is serialized.
This rule raises an issue on non-Serializable
fields, and on collection fields when they are not private
(because they
could be assigned non-Serializable
values externally), and when they are assigned non-Serializable
types within the
class.
Noncompliant Code Example
public class Address { //... } public class Person implements Serializable { private static final long serialVersionUID = 1905122041950251207L; private String name; private Address address; // Noncompliant; Address isn't serializable }
Compliant Solution
public class Address implements Serializable { private static final long serialVersionUID = 2405172041950251807L; } public class Person implements Serializable { private static final long serialVersionUID = 1905122041950251207L; private String name; private Address address; }
Exceptions
The alternative to making all members serializable
or transient
is to implement special methods which take on the
responsibility of properly serializing and de-serializing the object. This rule ignores classes which implement the following methods:
private void writeObject(java.io.ObjectOutputStream out) throws IOException private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
See
- MITRE, CWE-594 - Saving Unserializable Objects to Disk
- Oracle Java 6, Serializable
- Oracle Java 7, Serializable