Method prepareColumns
has a Cognitive Complexity of 202 (exceeds 5 allowed). Consider refactoring. Open
private void prepareColumns() {
Column c = this.getColumn(0);
c.setReadOnly(true);
if (actualTable != 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
File MyDBTable.java
has 1511 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
Method insertNewRow
has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring. Open
void insertNewRow(final boolean copySelected, final Vector<Object> vecIn) {
MyTable myT = this.getActualTable();
if (!this.actualTable.isReadOnly()) {
//JScrollPane scroller = getScroller();
this.getActualTable().saveProperties(this);
- 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 copyDetails
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
private void copyDetails(final MyTable myT, final Integer oldID, final Integer id) {
try {
String tablename = myT.getTablename();
copyKennzahlen(myT, oldID, id);
- 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
MyDBTable
has 64 methods (exceeds 20 allowed). Consider refactoring. Open
public class MyDBTable extends DBTable implements RowSorterListener, KeyListener, ListSelectionListener, MouseListener {
/**
*
*/
- Create a ticketCreate a ticket
Method prepareColumns
has 198 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void prepareColumns() {
Column c = this.getColumn(0);
c.setReadOnly(true);
if (actualTable != null) {
- Create a ticketCreate a ticket
Method keyTyped
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void keyTyped(final KeyEvent keyEvent) {
char ch = keyEvent.getKeyChar();
//System.out.println(ch + "\t" + keyEvent.isConsumed());
if (ch == KeyEvent.VK_TAB || ch == KeyEvent.VK_ENTER && !keyEvent.isAltDown() && !keyEvent.isControlDown()) {
- 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 checkForeignWindow2Open
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
private void checkForeignWindow2Open(final int row, final int col) {
MyTable[] myTs = actualTable.getForeignFields();
//System.out.println(lastClickedRow + "\t" + lastClickedCol + "\t" + myTs.length);
if (col > 0 && col <= myTs.length && myTs[col-1] != null &&
!myTs[col-1].getTablename().equals("DoubleKennzahlen")) {
- 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 checkOtherEditor2Open
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
private void checkOtherEditor2Open(final int lastClickedRow, final int lastClickedCol, final int x, final int y, final char ch) {
if (lastClickedCol > 0) {
MyTable[] myTs = actualTable.getForeignFields();
if (lastClickedCol > 0 && lastClickedCol <= myTs.length && myTs[lastClickedCol-1] != null &&
myTs[lastClickedCol-1].getTablename().equals("DoubleKennzahlen")) {
- 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 copyKennzahlen
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
private void copyKennzahlen(final MyTable myT, final Integer oldID, final Integer newID, final Integer toRow) throws Exception {
MyTable[] foreignFields = myT.getForeignFields();
if (foreignFields != null) {
for (int i=0; i<foreignFields.length; i++) {
if (foreignFields[i] != null && foreignFields[i].getTablename().equals("DoubleKennzahlen")) {
- 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 setTable
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
public boolean setTable(final MyTable myT, final Object[][] conditions, String andOrDefault) {
boolean result = true;
if (DBKernel.mainFrame != null) {
DBKernel.mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- 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 keyPressed
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void keyPressed(final KeyEvent keyEvent) {
//System.out.println(keyEvent.getKeyCode() + "\t" + keyEvent.getKeyChar() + "\t" + KeyEvent.VK_F + "\t" + keyEvent.isControlDown());
if (keyEvent.isControlDown() && keyEvent.getKeyCode() == KeyEvent.VK_LEFT) { //Ctrl+<-, Aussredem geht auch F8
keyEvent.consume();
- 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 insertNewRow
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
void insertNewRow(final boolean copySelected, final Vector<Object> vecIn) {
MyTable myT = this.getActualTable();
if (!this.actualTable.isReadOnly()) {
//JScrollPane scroller = getScroller();
this.getActualTable().saveProperties(this);
- Create a ticketCreate a ticket
Method keyTyped
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void keyTyped(final KeyEvent keyEvent) {
char ch = keyEvent.getKeyChar();
//System.out.println(ch + "\t" + keyEvent.isConsumed());
if (ch == KeyEvent.VK_TAB || ch == KeyEvent.VK_ENTER && !keyEvent.isAltDown() && !keyEvent.isControlDown()) {
- Create a ticketCreate a ticket
Method setTable
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
public boolean setTable(final MyTable myT, final Object[][] conditions, String andOrDefault) {
boolean result = true;
if (DBKernel.mainFrame != null) {
DBKernel.mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- Create a ticketCreate a ticket
Method isFilledBlobField
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public boolean isFilledBlobField(final int row, final int col) {
boolean result = false;
if (row >= 0 && row < this.getRowCount()) {
if (actualTable != null) {
if (actualTable.getTablename().equals("DateiSpeicher")) {
- 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 deleteRow
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
void deleteRow() {
String tablename = this.getActualTable().getTablename();
int selRow = this.getSelectedRow();
if (!this.actualTable.isReadOnly() && this.getRowCount() > 0 && selRow >= 0 && selRow < this.getRowCount()) {
int id = this.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 initConn
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public boolean initConn(final Connection conn) {
boolean result = false;
if (DBKernel.mainFrame != null) DBKernel.mainFrame.setTopTable(this);
if (conn != null) {
this.setConnection(conn);
- 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 copyDetails
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void copyDetails(final MyTable myT, final Integer oldID, final Integer id) {
try {
String tablename = myT.getTablename();
copyKennzahlen(myT, oldID, id);
- Create a ticketCreate a ticket
Method setSelectedID
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private boolean setSelectedID(final int id, final boolean force) {
if (id > 0 && (force || id != getSelectedID())) {
for (int row=0;row<this.getRowCount();row++) {
// evtl. sollte hier ein Thread eingebaut werden - wegen Gefahr zu langsam...
Object o = this.getValueAt(row, 0);
- 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 insertNull
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
void insertNull(final int selRow, final int selCol) {
if (!this.actualTable.isReadOnly() && selCol > 0 && selRow >= 0 && this.getRowCount() > 0) {
String[] mnTable = actualTable.getMNTable();
MyTable[] myFs = actualTable.getForeignFields();
if (mnTable != null && mnTable.length > selCol - 1 && mnTable[selCol - 1] != 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 checkForeignWindow2Open
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void checkForeignWindow2Open(final int row, final int col) {
MyTable[] myTs = actualTable.getForeignFields();
//System.out.println(lastClickedRow + "\t" + lastClickedCol + "\t" + myTs.length);
if (col > 0 && col <= myTs.length && myTs[col-1] != null &&
!myTs[col-1].getTablename().equals("DoubleKennzahlen")) {
- Create a ticketCreate a ticket
Method myPasteFromClipboard
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private void myPasteFromClipboard() {
int row = this.getTable().getSelectedRow();
int column = this.getTable().getSelectedColumn();
if (row >= 0 && row < this.getRowCount() && column >= 0 && column < this.getColumnCount()) {
String pasteString = "";
- 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 merging
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private void merging() {
int oldID = this.getSelectedID();
String msg = "Bitte die ID des Datensatzes eingeben, der ID '" + oldID + "' ersetzen soll (" + oldID + " -> ?):";
String titel = "ID '" + oldID + "' ersetzen durch andere ID!";
if (DBKernel.getLanguage().equalsIgnoreCase("en")) {
- 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 merging
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void merging() {
int oldID = this.getSelectedID();
String msg = "Bitte die ID des Datensatzes eingeben, der ID '" + oldID + "' ersetzen soll (" + oldID + " -> ?):";
String titel = "ID '" + oldID + "' ersetzen durch andere ID!";
if (DBKernel.getLanguage().equalsIgnoreCase("en")) {
- Create a ticketCreate a ticket
Method setSelectedRowCol
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public void setSelectedRowCol(final int row, int col, final int verticalScrollerPosition, final int horizontalScrollerPosition, final boolean forceCol) {
if (row >= 0) {
JScrollPane scroller = this.getScroller();
if (scroller != null) {
scroller.getVerticalScrollBar().setValue(verticalScrollerPosition);
- 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 keyPressed
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void keyPressed(final KeyEvent keyEvent) {
//System.out.println(keyEvent.getKeyCode() + "\t" + keyEvent.getKeyChar() + "\t" + KeyEvent.VK_F + "\t" + keyEvent.isControlDown());
if (keyEvent.isControlDown() && keyEvent.getKeyCode() == KeyEvent.VK_LEFT) { //Ctrl+<-, Aussredem geht auch F8
keyEvent.consume();
- Create a ticketCreate a ticket
Method checkOtherEditor2Open
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void checkOtherEditor2Open(final int lastClickedRow, final int lastClickedCol, final int x, final int y, final char ch) {
if (lastClickedCol > 0) {
MyTable[] myTs = actualTable.getForeignFields();
if (lastClickedCol > 0 && lastClickedCol <= myTs.length && myTs[lastClickedCol-1] != null &&
myTs[lastClickedCol-1].getTablename().equals("DoubleKennzahlen")) {
- Create a ticketCreate a ticket
Method mouseClicked
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void mouseClicked(final MouseEvent e) {
int lastClickedRow;// = e.getY()/this.getTable().getRowHeight();
int val = 0;
for (lastClickedRow = 0; lastClickedRow < this.getTable().getRowCount(); lastClickedRow++) {
- 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 initConn
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public boolean initConn(final Connection conn) {
boolean result = false;
if (DBKernel.mainFrame != null) DBKernel.mainFrame.setTopTable(this);
if (conn != null) {
this.setConnection(conn);
- Create a ticketCreate a ticket
Method myRefresh
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private void myRefresh(final int row, final int col) {
JScrollPane scroller = getScroller();
int scrollVal = (scroller == null) ? -1 : scroller.getVerticalScrollBar().getValue();
int hscrollVal = (scroller == null) ? -1 : scroller.getHorizontalScrollBar().getValue();
// System.err.println(row+" - "+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 myRefresh
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void myRefresh(final int row, final int col) {
JScrollPane scroller = getScroller();
int scrollVal = (scroller == null) ? -1 : scroller.getVerticalScrollBar().getValue();
int hscrollVal = (scroller == null) ? -1 : scroller.getHorizontalScrollBar().getValue();
// System.err.println(row+" - "+getSelectedID());
- Create a ticketCreate a ticket
Method copyRow
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private Integer copyRow(final ResultSet rs, final String tablename, final String parentTable, final Integer parentID) {
Integer result = null;
try {
String columns = "";
String vals = "";
- 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 insertNull
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
void insertNull(final int selRow, final int selCol) {
if (!this.actualTable.isReadOnly() && selCol > 0 && selRow >= 0 && this.getRowCount() > 0) {
String[] mnTable = actualTable.getMNTable();
MyTable[] myFs = actualTable.getForeignFields();
if (mnTable != null && mnTable.length > selCol - 1 && mnTable[selCol - 1] != null) {
- Create a ticketCreate a ticket
Method copyKennzahlen
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void copyKennzahlen(final MyTable myT, final Integer oldID, final Integer newID, final Integer toRow) throws Exception {
MyTable[] foreignFields = myT.getForeignFields();
if (foreignFields != null) {
for (int i=0; i<foreignFields.length; i++) {
if (foreignFields[i] != null && foreignFields[i].getTablename().equals("DoubleKennzahlen")) {
- Create a ticketCreate a ticket
Method deleteRow
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
void deleteRow() {
String tablename = this.getActualTable().getTablename();
int selRow = this.getSelectedRow();
if (!this.actualTable.isReadOnly() && this.getRowCount() > 0 && selRow >= 0 && selRow < this.getRowCount()) {
int id = this.getSelectedID();
- Create a ticketCreate a ticket
Method myPasteFromClipboard
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void myPasteFromClipboard() {
int row = this.getTable().getSelectedRow();
int column = this.getTable().getSelectedColumn();
if (row >= 0 && row < this.getRowCount() && column >= 0 && column < this.getColumnCount()) {
String pasteString = "";
- Create a ticketCreate a ticket
Method checkUnsavedStuff
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
void checkUnsavedStuff(final boolean saveProps) {
//if (actualTable == null || actualTable.isReadOnly()) System.err.println(" readonly, but saved??? " + actualTable);
// eigentlich würde es genügen, wenn man nur this.save() ausführt. this.save() hat selbst eine Routine, die checkt, ob was geändert wurde oder nicht, d.h. es wird nicht in jedem Fall abgespeichert
if (theFilter != null) return;
if (this.getEditingColumn() >= 0 && this.getEditingRow() >= 0) {
- 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 copyRow
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Integer copyRow(final ResultSet rs, final String tablename, final String parentTable, final Integer parentID) {
Integer result = null;
try {
String columns = "";
String vals = "";
- Create a ticketCreate a ticket
Method setSelectedRowCol
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void setSelectedRowCol(final int row, int col, final int verticalScrollerPosition, final int horizontalScrollerPosition, final boolean forceCol) {
if (row >= 0) {
JScrollPane scroller = this.getScroller();
if (scroller != null) {
scroller.getVerticalScrollBar().setValue(verticalScrollerPosition);
- Create a ticketCreate a ticket
Method updateRowHeader
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void updateRowHeader(final boolean setVisible) {
JScrollPane scroller = getScroller();
if (scroller != null) {
if (setVisible) {
- Create a ticketCreate a ticket
Method mouseClicked
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void mouseClicked(final MouseEvent e) {
int lastClickedRow;// = e.getY()/this.getTable().getRowHeight();
int val = 0;
for (lastClickedRow = 0; lastClickedRow < this.getTable().getRowCount(); lastClickedRow++) {
- Create a ticketCreate a ticket
Method updateRowHeader
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private void updateRowHeader(final boolean setVisible) {
JScrollPane scroller = getScroller();
if (scroller != null) {
if (setVisible) {
- 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 refreshHashbox
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
void refreshHashbox() {
MyTable[] foreignFields = actualTable.getForeignFields();
String[] mnTable = actualTable.getMNTable();
if (foreignFields != null) {
DBKernel.refreshHashTables();
- 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 sorterChanged
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void sorterChanged(final RowSorterEvent e) {
if (e == null || e.getType() == RowSorterEvent.Type.SORT_ORDER_CHANGED) {
if (this.getTable().getCellEditor() != null) {
this.getTable().getCellEditor().stopCellEditing();
- 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
Avoid deeply nested control flow statements. Open
for (MyTable myFT : ffTs) {
if (myFT != null && myFT.getTablename().equals(tablename)) {
tname = myT.getForeignFields()[i].getFieldNames()[ii];
break;
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (sorter != null) {
sorter.setComparator(i+2, new MyOtherSorter());
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (foreignHashs[i] != null) {
c = this.getColumn(i+1);
c.setUserCellEditor(new MyComboBoxEditor(foreignHashs[i], false)); c.setUserCellRenderer(new MyComboBoxEditor(foreignHashs[i], true));
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (rs.getObject(1) != null) {
Integer oldfID = rs.getInt(1);
ResultSet rs2 = DBKernel.getResultSet("SELECT * FROM " + DBKernel.delimitL("DoubleKennzahlen") +
" WHERE " + DBKernel.delimitL("ID") + "=" + oldfID, false);
if (rs2 != null && rs2.first()) {
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (foreignFields[i] != null) {
c = this.getColumn(i+1);
c.setReadOnly(true);
String[] mnTable = actualTable.getMNTable();
if (mnTable != null && i < mnTable.length && mnTable[i] != null && mnTable[i].length() > 0) {
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (rs != null && rs.first()) {
do {
Integer oldfID = rs.getInt("ID");
MyTable myfT = DBKernel.myDBi.getTable(fTablename);
System.out.println(tablename + "-" + fTablename + " - oldfID: " + oldfID + "\toldID = " + oldID);
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
for (int j=0;j<this.getColumnCount();j++) {
if (this.getColumn(j).getColumnName().equals(filterConditions[i][0])) {
this.setValueAt(filterConditions[i][1], newSelRow, j);
break;
}
- Create a ticketCreate a ticket
Method checkOtherEditor2Open
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private void checkOtherEditor2Open(final int lastClickedRow, final int lastClickedCol, final int x, final int y, final char ch) {
- Create a ticketCreate a ticket
Method setSelectedRowCol
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public void setSelectedRowCol(final int row, int col, final int verticalScrollerPosition, final int horizontalScrollerPosition, final boolean forceCol) {
- Create a ticketCreate a ticket
Method syncTableRowHeights
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public void syncTableRowHeights() {
JScrollPane scroller = getScroller();
if (scroller != null && scroller.getRowHeader() != null && scroller.getRowHeader().getView() instanceof JTable) {
JTable jTable = (JTable) scroller.getRowHeader().getView();
JTable bigTable = this.getTable();
- 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 getSelectedID
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public int getSelectedID() {
int result = -1;
int row = this.getSelectedRow();
if (row >= 0 && this.getRowCount() > 0 && row < this.getRowCount()) {
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 getVisibleCellContent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public String getVisibleCellContent(final int row, final int col) {
String result = null;
MyTable[] foreignFields = actualTable.getForeignFields();
if (row >= this.getRowCount()) {
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
Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed. Open
public boolean initConn(final Connection conn) {
- 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 80 to the 15 allowed. Open
void insertNewRow(final boolean copySelected, final Vector<Object> vecIn) {
- 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 35 to the 15 allowed. Open
private void checkOtherEditor2Open(final int lastClickedRow, final int lastClickedCol, final int x, final int y, final char ch) {
- 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 33 to the 15 allowed. Open
private void copyKennzahlen(final MyTable myT, final Integer oldID, final Integer newID, final Integer toRow) throws Exception {
- 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 39 to the 15 allowed. Open
public void keyTyped(final KeyEvent keyEvent) {
- 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 20 to the 15 allowed. Open
void deleteRow() {
- 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 17 to the 15 allowed. Open
private boolean setSelectedID(final int id, final boolean force) {
- 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 30 to the 15 allowed. Open
public void keyPressed(final KeyEvent keyEvent) {
- 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 36 to the 15 allowed. Open
public boolean setTable(final MyTable myT, final Object[][] conditions, String andOrDefault) {
- 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 38 to the 15 allowed. Open
private void checkForeignWindow2Open(final int row, final int col) {
- 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 22 to the 15 allowed. Open
public boolean isFilledBlobField(final int row, final int col) {
- 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 17 to the 15 allowed. Open
void insertNull(final int selRow, final int selCol) {
- 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 71 to the 15 allowed. Open
private void copyDetails(final MyTable myT, final Integer oldID, final Integer id) {
- 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 214 to the 15 allowed. Open
private void prepareColumns() {
- 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
Define a constant instead of duplicating this literal "DoubleKennzahlen" 10 times. Open
else if (myFs != null && myFs.length > selCol - 1 && myFs[selCol - 1] != null && myFs[selCol - 1].getTablename().equals("DoubleKennzahlen")) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
public void run() { prepare("action1"); // Noncompliant - "action1" is duplicated 3 times execute("action1"); release("action1"); } @SuppressWarning("all") // Compliant - annotations are excluded private void method1() { /* ... */ } @SuppressWarning("all") private void method2() { /* ... */ } public String method3(String a) { System.out.println("'" + a + "'"); // Compliant - literal "'" has less than 5 characters and is excluded return ""; // Compliant - literal "" has less than 5 characters and is excluded }
Compliant Solution
private static final String ACTION_1 = "action1"; // Compliant public void run() { prepare(ACTION_1); // Compliant execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "DateiSpeicher" 3 times. Open
if (actualTable.getTablename().equals("DateiSpeicher")) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
public void run() { prepare("action1"); // Noncompliant - "action1" is duplicated 3 times execute("action1"); release("action1"); } @SuppressWarning("all") // Compliant - annotations are excluded private void method1() { /* ... */ } @SuppressWarning("all") private void method2() { /* ... */ } public String method3(String a) { System.out.println("'" + a + "'"); // Compliant - literal "'" has less than 5 characters and is excluded return ""; // Compliant - literal "" has less than 5 characters and is excluded }
Compliant Solution
private static final String ACTION_1 = "action1"; // Compliant public void run() { prepare(ACTION_1); // Compliant execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "SELECT * FROM " 3 times. Open
ResultSet rs2 = DBKernel.getResultSet("SELECT * FROM " + DBKernel.delimitL(fTablename) + " WHERE " + DBKernel.delimitL("ID") + "=" + oldfID, false);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
public void run() { prepare("action1"); // Noncompliant - "action1" is duplicated 3 times execute("action1"); release("action1"); } @SuppressWarning("all") // Compliant - annotations are excluded private void method1() { /* ... */ } @SuppressWarning("all") private void method2() { /* ... */ } public String method3(String a) { System.out.println("'" + a + "'"); // Compliant - literal "'" has less than 5 characters and is excluded return ""; // Compliant - literal "" has less than 5 characters and is excluded }
Compliant Solution
private static final String ACTION_1 = "action1"; // Compliant public void run() { prepare(ACTION_1); // Compliant execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal " WHERE " 9 times. Open
if (lastID != null) where = " WHERE " + DBKernel.delimitL("ID") + " > " + (lastID - 1000) + " "; // 230000
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
public void run() { prepare("action1"); // Noncompliant - "action1" is duplicated 3 times execute("action1"); release("action1"); } @SuppressWarning("all") // Compliant - annotations are excluded private void method1() { /* ... */ } @SuppressWarning("all") private void method2() { /* ... */ } public String method3(String a) { System.out.println("'" + a + "'"); // Compliant - literal "'" has less than 5 characters and is excluded return ""; // Compliant - literal "" has less than 5 characters and is excluded }
Compliant Solution
private static final String ACTION_1 = "action1"; // Compliant public void run() { prepare(ACTION_1); // Compliant execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. Open
public void mousePressed(final MouseEvent e) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
There are several reasons for a method not to have a method body:
- It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
- It is not yet, or never will be, supported. In this case an
UnsupportedOperationException
should be thrown. - The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.
Noncompliant Code Example
public void doSomething() { } public void doSomethingElse() { }
Compliant Solution
@Override public void doSomething() { // Do nothing because of X and Y. } @Override public void doSomethingElse() { throw new UnsupportedOperationException(); }
Exceptions
Default (no-argument) constructors are ignored when there are other constructors in the class, as are empty methods in abstract classes.
public abstract class Animal { void speak() { // default implementation ignored } }
Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. Open
public void mouseEntered(final MouseEvent e) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
There are several reasons for a method not to have a method body:
- It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
- It is not yet, or never will be, supported. In this case an
UnsupportedOperationException
should be thrown. - The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.
Noncompliant Code Example
public void doSomething() { } public void doSomethingElse() { }
Compliant Solution
@Override public void doSomething() { // Do nothing because of X and Y. } @Override public void doSomethingElse() { throw new UnsupportedOperationException(); }
Exceptions
Default (no-argument) constructors are ignored when there are other constructors in the class, as are empty methods in abstract classes.
public abstract class Animal { void speak() { // default implementation ignored } }
Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. Open
public void mouseReleased(final MouseEvent e) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
There are several reasons for a method not to have a method body:
- It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
- It is not yet, or never will be, supported. In this case an
UnsupportedOperationException
should be thrown. - The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.
Noncompliant Code Example
public void doSomething() { } public void doSomethingElse() { }
Compliant Solution
@Override public void doSomething() { // Do nothing because of X and Y. } @Override public void doSomethingElse() { throw new UnsupportedOperationException(); }
Exceptions
Default (no-argument) constructors are ignored when there are other constructors in the class, as are empty methods in abstract classes.
public abstract class Animal { void speak() { // default implementation ignored } }
Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. Open
public void mouseExited(final MouseEvent e) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
There are several reasons for a method not to have a method body:
- It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
- It is not yet, or never will be, supported. In this case an
UnsupportedOperationException
should be thrown. - The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.
Noncompliant Code Example
public void doSomething() { } public void doSomethingElse() { }
Compliant Solution
@Override public void doSomething() { // Do nothing because of X and Y. } @Override public void doSomethingElse() { throw new UnsupportedOperationException(); }
Exceptions
Default (no-argument) constructors are ignored when there are other constructors in the class, as are empty methods in abstract classes.
public abstract class Animal { void speak() { // default implementation ignored } }
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (foreignFields != null) {
DBKernel.refreshHashTables();
for (int i=0;i<foreignFields.length;i++) {
if (foreignFields[i] != null && (mnTable == null || mnTable[i] == null)) {
hashBox[i] = DBKernel.fillHashtable(foreignFields[i], "", "\n", "\n", !bigbigTable); //" | " " ; "
- Read upRead up
- Create a ticketCreate a ticket
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 136.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (foreignFields != null) {
DBKernel.refreshHashTables();
for (int i=0;i<foreignFields.length;i++) {
if (foreignFields[i] != null && (mnTable == null || mnTable[i] == null)) {
hashBox[i] = DBKernel.fillHashtable(foreignFields[i], "", "\n", "\n", !bigbigTable); //" | " " ; "
- Read upRead up
- Create a ticketCreate a ticket
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 136.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (fieldTypes[i].equals("OTHER")) {
c.setUserCellRenderer(new MyJavaTypeRenderer());
mthcr = new MyTableHeaderCellRenderer(this, defaultBgColor, fieldComments[i]);
tcm.getColumn(i+1).setHeaderRenderer(mthcr);
if (sorter != null) {
- Read upRead up
- Create a ticketCreate a ticket
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 68.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
else if (actualTable.getFieldNames()[i].equals("Dateigroesse")) { // Dateigroesse && actualTable.getTablename().equals("DateiSpeicher")
c.setUserCellRenderer(new MyBlobSizeRenderer());
mthcr = new MyTableHeaderCellRenderer(this, defaultBgColor, fieldComments[i]);
tcm.getColumn(i+1).setHeaderRenderer(mthcr);
if (sorter != null) {
- Read upRead up
- Create a ticketCreate a ticket
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 68.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i=0;i<this.getTable().getKeyListeners().length;i++) {
if (this.getTable().getKeyListeners()[i] instanceof MyDBTable) {
hasKeyListener = true;
break;
}
- Read upRead up
- Create a ticketCreate a ticket
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 52.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i=0;i<this.getTable().getMouseListeners().length;i++) {
if (this.getTable().getMouseListeners()[i] instanceof MyDBTable) {
hasMouseListener = true;
break;
}
- Read upRead up
- Create a ticketCreate a ticket
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 52.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 4 locations. Consider refactoring. Open
if (col > 0 && foreignFields != null && foreignFields.length > col-1 && foreignFields[col-1] != null && hashBox[col-1] != null) {
- Read upRead up
- Create a ticketCreate a ticket
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 44.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
ResultSet rs2 = DBKernel.getResultSet("SELECT * FROM " + DBKernel.delimitL("DoubleKennzahlen") +
" WHERE " + DBKernel.delimitL("ID") + "=" + oldfID, false);
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
if (mnTable != null && i < mnTable.length && mnTable[i] != null && mnTable[i].equals("INT")) {
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
hashBox[lastClickedCol-1] = DBKernel.fillHashtable(myTs[lastClickedCol-1], "", "\n", "\n", !bigbigTable, true); //" | " " ; "
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
hashBox[col-1] = DBKernel.fillHashtable(foreignFields[col-1], "", "\n", "\n", !bigbigTable, true); //" | " " ; "
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76