Skip to content

Commit ae6d01b

Browse files
authored
Merge pull request #2765 from snisnisniksonah/checkstyle
Clean up checkstyle warnings
2 parents 72703f3 + f652548 commit ae6d01b

File tree

312 files changed

+810
-1043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+810
-1043
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ task media(type: com.install4j.gradle.Install4jTask, dependsOn: "releaseJar") {
390390
checkstyle {
391391
// do not use other packages for checkstyle, excluding gen(erated) sources
392392
checkstyleMain.source = "src/main/java"
393-
toolVersion = '6.17'
393+
toolVersion = '7.6.1'
394394
}
395395

396396
task release(dependsOn: ["media", "releaseJar"]) {

config/checkstyle/checkstyle.xml

+14-24
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,7 @@
33
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
44
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
55

6-
<!--
7-
Checkstyle configuration that checks the sun coding conventions from:
8-
- the Java Language Specification at
9-
http://java.sun.com/docs/books/jls/second_edition/html/index.html
10-
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
11-
- the Javadoc guidelines at
12-
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
13-
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
14-
- some best practices
15-
Checkstyle is very configurable. Be sure to read the documentation at
16-
http://checkstyle.sf.net (or in your downloaded distribution).
17-
Most Checks are configurable, be sure to consult the documentation.
18-
To completely disable a check, just comment it out or delete it from the file.
19-
Finally, it is worth reading the documentation.
20-
-->
21-
226
<module name="Checker">
23-
<!--
24-
If you set the basedir property below, then all reported file
25-
names will be relative to the specified directory. See
26-
http://checkstyle.sourceforge.net/5.x/config.html#Checker
27-
<property name="basedir" value="${basedir}"/>
28-
-->
29-
307
<module name="Header">
318
<property name="header" value=""/>
329
</module>
@@ -49,6 +26,19 @@
4926
<property name="sortStaticImportsAlphabetically" value="true"/>
5027
</module>
5128

52-
</module>
29+
<module name="EmptyLineSeparator">
30+
<property name="tokens" value="IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, STATIC_INIT, INSTANCE_INIT, METHOD_DEF"/>
31+
<property name="allowMultipleEmptyLines" value="false"/>
32+
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
33+
</module>
34+
<module name="WhitespaceAround">
35+
<property name="tokens"
36+
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
37+
</module>
38+
<module name="DeclarationOrder"/>
5339

40+
</module>
41+
<module name="SuppressionFilter">
42+
<property name="file" value="config/checkstyle/suppressions.xml"/>
43+
</module>
5444
</module>

config/checkstyle/suppressions.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
5+
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
6+
7+
<suppressions>
8+
<suppress checks="[a-zA-Z0-9]*" files="[\\/]gen[\\/]" />
9+
<suppress checks="[a-zA-Z0-9]*" files="[\\/]test[\\/]" />
10+
</suppressions>

src/main/java/oracle/jdbc/OracleConnection.java

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class OracleConnection implements Connection {
2929
public static String DCN_NOTIFY_ROWIDS;
3030
public static String DCN_QUERY_CHANGE_NOTIFICATION;
3131

32-
3332
@Override
3433
public <T> T unwrap(Class<T> iface) throws SQLException {
3534
// Auto-generated method stub

src/main/java/org/jabref/JabRefExecutorService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class JabRefExecutorService implements Executor {
3333
private final Timer timer = new Timer("timer", true);
3434
private Thread remoteThread;
3535

36-
private JabRefExecutorService() {}
36+
private JabRefExecutorService() { }
3737

3838
@Override
3939
public void execute(Runnable command) {
@@ -73,7 +73,7 @@ public void executeInterruptableTask(final Runnable runnable, String taskName) {
7373
}
7474

7575
public void executeInterruptableTaskAndWait(Runnable runnable) {
76-
if(runnable == null) {
76+
if (runnable == null) {
7777
LOGGER.debug("Received null as command for execution");
7878
return;
7979
}
@@ -92,7 +92,7 @@ public void executeInterruptableTaskAndWait(Runnable runnable) {
9292
}
9393

9494
public void manageRemoteThread(Thread thread) {
95-
if (this.remoteThread != null){
95+
if (this.remoteThread != null) {
9696
throw new IllegalStateException("Remote thread is already attached");
9797
} else {
9898
this.remoteThread = thread;

src/main/java/org/jabref/cli/ImportInspectionCommandLine.java

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public class ImportInspectionCommandLine implements ImportInspector {
1717

1818
private final OutputPrinter status = new SystemOutputPrinter();
1919

20-
2120
@Override
2221
public void addEntry(BibEntry entry) {
2322
entries.add(entry);
@@ -29,7 +28,6 @@ public void setProgress(int current, int max) {
2928
.valueOf(max)));
3029
}
3130

32-
3331
public Collection<BibEntry> query(String query, EntryFetcher fetcher) {
3432
entries.clear();
3533
if (fetcher.processQuery(query, ImportInspectionCommandLine.this, status)) {

src/main/java/org/jabref/cli/JabRefCLI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public String getExportMatches() {
137137

138138
public boolean isGenerateBibtexKeys() { return cl.hasOption("generateBibtexKeys"); }
139139

140-
public boolean isAutomaticallySetFileLinks() { return cl.hasOption("automaticallySetFileLinks");}
140+
public boolean isAutomaticallySetFileLinks() { return cl.hasOption("automaticallySetFileLinks"); }
141141

142142
private Options getOptions() {
143143
Options options = new Options();

src/main/java/org/jabref/collab/ChangeScanner.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ public class ChangeScanner implements Runnable {
4747

4848
private static final String[] SORT_BY = new String[] {FieldName.YEAR, FieldName.AUTHOR, FieldName.TITLE};
4949

50+
private static final double MATCH_THRESHOLD = 0.4;
5051
private final File file;
5152
private final BibDatabase databaseInMemory;
5253
private final MetaData metadataInMemory;
53-
private final BasePanel panel;
5454

55+
private final BasePanel panel;
5556
private final JabRefFrame frame;
5657
private BibDatabase databaseInTemp;
57-
private MetaData metadataInTemp;
5858

59-
private static final double MATCH_THRESHOLD = 0.4;
59+
private MetaData metadataInTemp;
6060

6161
/**
6262
* We create an ArrayList to hold the changes we find. These will be added in the form
@@ -464,7 +464,6 @@ private void scanGroups(MetaData inTemp, MetaData onDisk) {
464464
}
465465
}
466466

467-
468467
@FunctionalInterface
469468
public interface DisplayResultCallback {
470469
void scanResultsResolved(boolean resolved);

src/main/java/org/jabref/collab/EntryChange.java

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ public JComponent description() {
9797
return new JLabel(name);
9898
}
9999

100-
101100
static class FieldChange extends Change {
102101

103102
private final BibEntry entry;

src/main/java/org/jabref/collab/EntryDeleteChange.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
class EntryDeleteChange extends Change {
1919

20+
private static final Log LOGGER = LogFactory.getLog(EntryDeleteChange.class);
2021
private final BibEntry memEntry;
2122
private final BibEntry tmpEntry;
22-
private final JScrollPane sp;
2323

24-
private static final Log LOGGER = LogFactory.getLog(EntryDeleteChange.class);
24+
private final JScrollPane sp;
2525

2626

2727
public EntryDeleteChange(BibEntry memEntry, BibEntry tmpEntry) {

src/main/java/org/jabref/collab/FileUpdateMonitor.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class FileUpdateMonitor implements Runnable {
2828
public void run() {
2929
// The running variable is used to make the thread stop when needed.
3030
while (true) {
31-
for(Entry e : entries.values()) {
31+
for (Entry e : entries.values()) {
3232
try {
3333
if (e.hasBeenUpdated()) {
3434
e.notifyListener();
@@ -210,7 +210,6 @@ public void decreaseTimeStamp() {
210210
}
211211
}
212212

213-
214213
private static synchronized Path getTempFile() {
215214
Path temporaryFile = null;
216215
try {

src/main/java/org/jabref/collab/StringAddChange.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
class StringAddChange extends Change {
1818

19-
private final BibtexString string;
19+
private static final Log LOGGER = LogFactory.getLog(StringAddChange.class);
2020

21+
private final BibtexString string;
2122
private final InfoPane tp = new InfoPane();
22-
private final JScrollPane sp = new JScrollPane(tp);
2323

24-
private static final Log LOGGER = LogFactory.getLog(StringAddChange.class);
24+
private final JScrollPane sp = new JScrollPane(tp);
2525

2626

2727
public StringAddChange(BibtexString string) {

src/main/java/org/jabref/collab/StringChange.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717

1818
class StringChange extends Change {
1919

20+
private static final Log LOGGER = LogFactory.getLog(StringChange.class);
2021
private final BibtexString string;
2122
private final String mem;
2223
private final String disk;
23-
private final String label;
2424

25+
private final String label;
2526
private final InfoPane tp = new InfoPane();
2627
private final JScrollPane sp = new JScrollPane(tp);
27-
private final BibtexString tmpString;
2828

29-
private static final Log LOGGER = LogFactory.getLog(StringChange.class);
29+
private final BibtexString tmpString;
3030

3131

3232
public StringChange(BibtexString string, BibtexString tmpString, String label, String mem, String disk) {

src/main/java/org/jabref/collab/StringNameChange.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
class StringNameChange extends Change {
1919

20+
private static final Log LOGGER = LogFactory.getLog(StringNameChange.class);
2021
private final BibtexString string;
2122
private final String mem;
2223
private final String disk;
2324
private final String content;
24-
private final BibtexString tmpString;
2525

26-
private static final Log LOGGER = LogFactory.getLog(StringNameChange.class);
26+
private final BibtexString tmpString;
2727

2828

2929
public StringNameChange(BibtexString string, BibtexString tmpString,

src/main/java/org/jabref/collab/StringRemoveChange.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
import org.apache.commons.logging.LogFactory;
1515

1616
class StringRemoveChange extends Change {
17+
private static final Log LOGGER = LogFactory.getLog(StringRemoveChange.class);
1718
private final BibtexString string;
18-
private final BibtexString inMem;
1919

20+
private final BibtexString inMem;
2021
private final InfoPane tp = new InfoPane();
2122
private final JScrollPane sp = new JScrollPane(tp);
22-
private final BibtexString tmpString;
2323

24-
private static final Log LOGGER = LogFactory.getLog(StringRemoveChange.class);
24+
private final BibtexString tmpString;
2525

2626

2727
public StringRemoveChange(BibtexString string, BibtexString tmpString, BibtexString inMem) {

src/main/java/org/jabref/gui/BasePanel.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ private void setupActions() {
397397
int numSelected;
398398
boolean canceled;
399399

400-
401400
// Run first, in EDT:
402401
@Override
403402
public void init() {
@@ -757,7 +756,7 @@ private void delete(boolean cut) {
757756
}
758757

759758
// select the next entry to stay at the same place as before (or the previous if we're already at the end)
760-
if (mainTable.getSelectedRow() != (mainTable.getRowCount() -1)){
759+
if (mainTable.getSelectedRow() != (mainTable.getRowCount() - 1)) {
761760
selectNextEntry();
762761
} else {
763762
selectPreviousEntry();
@@ -2160,7 +2159,6 @@ public void run() {
21602159
}
21612160
};
21622161

2163-
21642162
@Subscribe
21652163
public void listen(EntryAddedEvent addedEntryEvent) {
21662164
// if the added entry is an undo don't add it to the current group

src/main/java/org/jabref/gui/ClipBoardManager.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void lostOwnership(Clipboard aClipboard, Transferable aContents) {
4040
/**
4141
* Places the string into the clipboard using a {@link Transferable}.
4242
*/
43-
public void setTransferableClipboardContents(Transferable transferable){
43+
public void setTransferableClipboardContents(Transferable transferable) {
4444
CLIPBOARD.setContents(transferable, this);
4545
}
4646

@@ -73,13 +73,12 @@ public void setClipboardContents(String aString) {
7373
StringSelection stringSelection = new StringSelection(aString);
7474
CLIPBOARD.setContents(stringSelection, this);
7575
}
76-
76+
7777
public List<BibEntry> extractBibEntriesFromClipboard() {
7878
// Get clipboard contents, and see if TransferableBibtexEntry is among the content flavors offered
7979
Transferable content = CLIPBOARD.getContents(null);
8080
List<BibEntry> result = new ArrayList<>();
8181

82-
8382
if (content.isDataFlavorSupported(TransferableBibtexEntry.entryFlavor)) {
8483
// We have determined that the clipboard data is a set of entries.
8584
try {

src/main/java/org/jabref/gui/DuplicateResolverDialog.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public enum DuplicateResolverResult {
3636
BREAK
3737
}
3838

39+
JButton helpButton = new HelpAction(Localization.lang("Help"), HelpFile.FIND_DUPLICATES).getHelpButton();
3940
private final JButton cancel = new JButton(Localization.lang("Cancel"));
4041
private final JButton merge = new JButton(Localization.lang("Keep merged entry only"));
41-
JButton helpButton = new HelpAction(Localization.lang("Help"), HelpFile.FIND_DUPLICATES).getHelpButton();
4242
private final JabRefFrame frame;
4343
private final JPanel options = new JPanel();
4444
private DuplicateResolverResult status = DuplicateResolverResult.NOT_CHOSEN;
@@ -131,7 +131,6 @@ public void windowClosing(WindowEvent e) {
131131
both.requestFocus();
132132
}
133133

134-
135134
private void buttonPressed(DuplicateResolverResult result) {
136135
status = result;
137136
dispose();

src/main/java/org/jabref/gui/DuplicateSearch.java

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ public void run() {
143143

144144
}
145145

146-
147146
class SearcherRunnable implements Runnable {
148147

149148
private volatile boolean finished;

src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@
8888
* GUI Dialog for the feature "Find unlinked files".
8989
*/
9090
public class FindUnlinkedFilesDialog extends JabRefDialog {
91-
private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class);
92-
9391
/**
9492
* Keys to be used for referencing this Action.
9593
*/
@@ -98,6 +96,8 @@ public class FindUnlinkedFilesDialog extends JabRefDialog {
9896

9997
public static final String ACTION_SHORT_DESCRIPTION = Localization
10098
.lang("Searches for unlinked PDF files on the file system");
99+
100+
private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class);
101101
private static final String GLOBAL_PREFS_WORKING_DIRECTORY_KEY = "findUnlinkedFilesWD";
102102

103103
private static final String GLOBAL_PREFS_DIALOG_SIZE_KEY = "findUnlinkedFilesDialogSize";
@@ -446,7 +446,6 @@ private void startSearch() {
446446

447447
int counter;
448448

449-
450449
@Override
451450
public void stateChanged(ChangeEvent e) {
452451
counter++;
@@ -1083,7 +1082,6 @@ private static class CheckboxTreeCellRenderer extends DefaultTreeCellRenderer {
10831082

10841083
private final FileSystemView fsv = FileSystemView.getFileSystemView();
10851084

1086-
10871085
@Override
10881086
public Component getTreeCellRendererComponent(final JTree tree, Object value, boolean sel, boolean expanded,
10891087
boolean leaf, int row, boolean hasFocus) {

0 commit comments

Comments
 (0)