Skip to content

Commit

Permalink
Merge pull request #2765 from snisnisniksonah/checkstyle
Browse files Browse the repository at this point in the history
Clean up checkstyle warnings
  • Loading branch information
koppor authored Apr 21, 2017
2 parents 72703f3 + f652548 commit ae6d01b
Show file tree
Hide file tree
Showing 312 changed files with 810 additions and 1,043 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ task media(type: com.install4j.gradle.Install4jTask, dependsOn: "releaseJar") {
checkstyle {
// do not use other packages for checkstyle, excluding gen(erated) sources
checkstyleMain.source = "src/main/java"
toolVersion = '6.17'
toolVersion = '7.6.1'
}

task release(dependsOn: ["media", "releaseJar"]) {
Expand Down
38 changes: 14 additions & 24 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,7 @@
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->

<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->

<module name="Header">
<property name="header" value=""/>
</module>
Expand All @@ -49,6 +26,19 @@
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>

</module>
<module name="EmptyLineSeparator">
<property name="tokens" value="IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, STATIC_INIT, INSTANCE_INIT, METHOD_DEF"/>
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
</module>
<module name="WhitespaceAround">
<property name="tokens"
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"/>
</module>
<module name="DeclarationOrder"/>

</module>
<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppressions.xml"/>
</module>
</module>
10 changes: 10 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress checks="[a-zA-Z0-9]*" files="[\\/]gen[\\/]" />
<suppress checks="[a-zA-Z0-9]*" files="[\\/]test[\\/]" />
</suppressions>
1 change: 0 additions & 1 deletion src/main/java/oracle/jdbc/OracleConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class OracleConnection implements Connection {
public static String DCN_NOTIFY_ROWIDS;
public static String DCN_QUERY_CHANGE_NOTIFICATION;


@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
// Auto-generated method stub
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/JabRefExecutorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class JabRefExecutorService implements Executor {
private final Timer timer = new Timer("timer", true);
private Thread remoteThread;

private JabRefExecutorService() {}
private JabRefExecutorService() { }

@Override
public void execute(Runnable command) {
Expand Down Expand Up @@ -73,7 +73,7 @@ public void executeInterruptableTask(final Runnable runnable, String taskName) {
}

public void executeInterruptableTaskAndWait(Runnable runnable) {
if(runnable == null) {
if (runnable == null) {
LOGGER.debug("Received null as command for execution");
return;
}
Expand All @@ -92,7 +92,7 @@ public void executeInterruptableTaskAndWait(Runnable runnable) {
}

public void manageRemoteThread(Thread thread) {
if (this.remoteThread != null){
if (this.remoteThread != null) {
throw new IllegalStateException("Remote thread is already attached");
} else {
this.remoteThread = thread;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/cli/ImportInspectionCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class ImportInspectionCommandLine implements ImportInspector {

private final OutputPrinter status = new SystemOutputPrinter();


@Override
public void addEntry(BibEntry entry) {
entries.add(entry);
Expand All @@ -29,7 +28,6 @@ public void setProgress(int current, int max) {
.valueOf(max)));
}


public Collection<BibEntry> query(String query, EntryFetcher fetcher) {
entries.clear();
if (fetcher.processQuery(query, ImportInspectionCommandLine.this, status)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public String getExportMatches() {

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

public boolean isAutomaticallySetFileLinks() { return cl.hasOption("automaticallySetFileLinks");}
public boolean isAutomaticallySetFileLinks() { return cl.hasOption("automaticallySetFileLinks"); }

private Options getOptions() {
Options options = new Options();
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/collab/ChangeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ public class ChangeScanner implements Runnable {

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

private static final double MATCH_THRESHOLD = 0.4;
private final File file;
private final BibDatabase databaseInMemory;
private final MetaData metadataInMemory;
private final BasePanel panel;

private final BasePanel panel;
private final JabRefFrame frame;
private BibDatabase databaseInTemp;
private MetaData metadataInTemp;

private static final double MATCH_THRESHOLD = 0.4;
private MetaData metadataInTemp;

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


@FunctionalInterface
public interface DisplayResultCallback {
void scanResultsResolved(boolean resolved);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/collab/EntryChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public JComponent description() {
return new JLabel(name);
}


static class FieldChange extends Change {

private final BibEntry entry;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/collab/EntryDeleteChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

class EntryDeleteChange extends Change {

private static final Log LOGGER = LogFactory.getLog(EntryDeleteChange.class);
private final BibEntry memEntry;
private final BibEntry tmpEntry;
private final JScrollPane sp;

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


public EntryDeleteChange(BibEntry memEntry, BibEntry tmpEntry) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/collab/FileUpdateMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class FileUpdateMonitor implements Runnable {
public void run() {
// The running variable is used to make the thread stop when needed.
while (true) {
for(Entry e : entries.values()) {
for (Entry e : entries.values()) {
try {
if (e.hasBeenUpdated()) {
e.notifyListener();
Expand Down Expand Up @@ -210,7 +210,6 @@ public void decreaseTimeStamp() {
}
}


private static synchronized Path getTempFile() {
Path temporaryFile = null;
try {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/collab/StringAddChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

class StringAddChange extends Change {

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

private final BibtexString string;
private final InfoPane tp = new InfoPane();
private final JScrollPane sp = new JScrollPane(tp);

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


public StringAddChange(BibtexString string) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/collab/StringChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

class StringChange extends Change {

private static final Log LOGGER = LogFactory.getLog(StringChange.class);
private final BibtexString string;
private final String mem;
private final String disk;
private final String label;

private final String label;
private final InfoPane tp = new InfoPane();
private final JScrollPane sp = new JScrollPane(tp);
private final BibtexString tmpString;

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


public StringChange(BibtexString string, BibtexString tmpString, String label, String mem, String disk) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/collab/StringNameChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

class StringNameChange extends Change {

private static final Log LOGGER = LogFactory.getLog(StringNameChange.class);
private final BibtexString string;
private final String mem;
private final String disk;
private final String content;
private final BibtexString tmpString;

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


public StringNameChange(BibtexString string, BibtexString tmpString,
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/collab/StringRemoveChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import org.apache.commons.logging.LogFactory;

class StringRemoveChange extends Change {
private static final Log LOGGER = LogFactory.getLog(StringRemoveChange.class);
private final BibtexString string;
private final BibtexString inMem;

private final BibtexString inMem;
private final InfoPane tp = new InfoPane();
private final JScrollPane sp = new JScrollPane(tp);
private final BibtexString tmpString;

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


public StringRemoveChange(BibtexString string, BibtexString tmpString, BibtexString inMem) {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ private void setupActions() {
int numSelected;
boolean canceled;


// Run first, in EDT:
@Override
public void init() {
Expand Down Expand Up @@ -757,7 +756,7 @@ private void delete(boolean cut) {
}

// select the next entry to stay at the same place as before (or the previous if we're already at the end)
if (mainTable.getSelectedRow() != (mainTable.getRowCount() -1)){
if (mainTable.getSelectedRow() != (mainTable.getRowCount() - 1)) {
selectNextEntry();
} else {
selectPreviousEntry();
Expand Down Expand Up @@ -2160,7 +2159,6 @@ public void run() {
}
};


@Subscribe
public void listen(EntryAddedEvent addedEntryEvent) {
// if the added entry is an undo don't add it to the current group
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/gui/ClipBoardManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void lostOwnership(Clipboard aClipboard, Transferable aContents) {
/**
* Places the string into the clipboard using a {@link Transferable}.
*/
public void setTransferableClipboardContents(Transferable transferable){
public void setTransferableClipboardContents(Transferable transferable) {
CLIPBOARD.setContents(transferable, this);
}

Expand Down Expand Up @@ -73,13 +73,12 @@ public void setClipboardContents(String aString) {
StringSelection stringSelection = new StringSelection(aString);
CLIPBOARD.setContents(stringSelection, this);
}

public List<BibEntry> extractBibEntriesFromClipboard() {
// Get clipboard contents, and see if TransferableBibtexEntry is among the content flavors offered
Transferable content = CLIPBOARD.getContents(null);
List<BibEntry> result = new ArrayList<>();


if (content.isDataFlavorSupported(TransferableBibtexEntry.entryFlavor)) {
// We have determined that the clipboard data is a set of entries.
try {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/gui/DuplicateResolverDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public enum DuplicateResolverResult {
BREAK
}

JButton helpButton = new HelpAction(Localization.lang("Help"), HelpFile.FIND_DUPLICATES).getHelpButton();
private final JButton cancel = new JButton(Localization.lang("Cancel"));
private final JButton merge = new JButton(Localization.lang("Keep merged entry only"));
JButton helpButton = new HelpAction(Localization.lang("Help"), HelpFile.FIND_DUPLICATES).getHelpButton();
private final JabRefFrame frame;
private final JPanel options = new JPanel();
private DuplicateResolverResult status = DuplicateResolverResult.NOT_CHOSEN;
Expand Down Expand Up @@ -131,7 +131,6 @@ public void windowClosing(WindowEvent e) {
both.requestFocus();
}


private void buttonPressed(DuplicateResolverResult result) {
status = result;
dispose();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/DuplicateSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public void run() {

}


class SearcherRunnable implements Runnable {

private volatile boolean finished;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
* GUI Dialog for the feature "Find unlinked files".
*/
public class FindUnlinkedFilesDialog extends JabRefDialog {
private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class);

/**
* Keys to be used for referencing this Action.
*/
Expand All @@ -98,6 +96,8 @@ public class FindUnlinkedFilesDialog extends JabRefDialog {

public static final String ACTION_SHORT_DESCRIPTION = Localization
.lang("Searches for unlinked PDF files on the file system");

private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class);
private static final String GLOBAL_PREFS_WORKING_DIRECTORY_KEY = "findUnlinkedFilesWD";

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

int counter;


@Override
public void stateChanged(ChangeEvent e) {
counter++;
Expand Down Expand Up @@ -1083,7 +1082,6 @@ private static class CheckboxTreeCellRenderer extends DefaultTreeCellRenderer {

private final FileSystemView fsv = FileSystemView.getFileSystemView();


@Override
public Component getTreeCellRendererComponent(final JTree tree, Object value, boolean sel, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
Expand Down
Loading

0 comments on commit ae6d01b

Please sign in to comment.