SiLeBAT/FSK-Lab

View on GitHub
org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java

Summary

Maintainability
F
1 wk
Test Coverage

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
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 day to fix

MyDBPanel has 65 methods (exceeds 20 allowed). Consider refactoring.
Open

public class MyDBPanel extends JPanel {
    
    /**
     * 
     */
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 day to fix

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();
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 day to fix

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;
        }
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 4 hrs to fix

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) {
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 4 hrs to fix

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"; 
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 2 hrs to fix

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());
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 2 hrs to fix

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();
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 hr to fix

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) {
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 hr to fix

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;
        }
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 hr to fix

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"; 
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 hr to fix

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);
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 hr to fix

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());
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 1 hr to fix

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

    private void gotoFind(int increment) {
        if (isFormVisible()) {
            return;
        }
        
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 45 mins to fix

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) {
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 35 mins to fix

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 {
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 35 mins to fix

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);
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 25 mins to fix

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);
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/gui/dbtable/MyDBPanel.java - About 25 mins to fix

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) {

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) {

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) {

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;

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

Make "t1Conditions" transient or serializable.
Open

    private Object[][] t1Conditions = null;

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

There are no issues that match your filters.

Category
Status