Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce LeftCurly rule #6452

Merged
merged 15 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
55 changes: 28 additions & 27 deletions config/IntelliJ Code Style.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<code_scheme name="JabRef">
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="javafx" withSubpackages="true" static="false" />
<emptyLine />
<package name="org.jabref" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
<option name="JD_P_AT_EMPTY_LINES" value="false" />
<option name="JD_KEEP_EMPTY_PARAMETER" value="false" />
<option name="JD_KEEP_EMPTY_EXCEPTION" value="false" />
<option name="JD_KEEP_EMPTY_RETURN" value="false" />
<option name="WRAP_COMMENTS" value="true" />
<code_scheme name="JabRef" version="173">
<option name="RIGHT_MARGIN" value="0" />
<option name="SOFT_MARGINS" value="120" />
<JavaCodeStyleSettings>
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
<option name="SPACE_INSIDE_ONE_LINE_ENUM_BRACES" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="javafx" withSubpackages="true" static="false" />
<emptyLine />
<package name="org.jabref" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
<option name="WRAP_COMMENTS" value="true" />
<arrangement>
<rules>
<section>
Expand Down Expand Up @@ -292,4 +293,4 @@
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</code_scheme>
21 changes: 19 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<module name="FileTabCharacter"/>
<module name="NewlineAtEndOfFile"/>

<!-- Checks for size violations: https://checkstyle.sourceforge.io/config_sizes.html -->

<!-- LineLength not in place as PreviewerViewer and RelatedArticlesTab have line length with more than 500 charachters -->

<module name="TreeWalker">
<!-- Checks for Javadoc comments: https://checkstyle.org/config_javadoc.html -->
<module name="InvalidJavadocPosition"/>
Expand All @@ -35,6 +39,7 @@
</module>

<!-- Checks for imports: https://checkstyle.org/config_import.html -->

<module name="UnusedImports"/>
<module name="RedundantImport"/>
<module name="AvoidStarImport"/>
Expand Down Expand Up @@ -85,6 +90,9 @@
</module>

<!-- Checks for blocks: https://checkstyle.org/config_blocks.html -->

<module name="AvoidNestedBlocks"/>

<module name="NeedBraces"/>

<module name="EmptyBlock">
Expand All @@ -99,16 +107,25 @@

public String getTabName() { return Localization.lang("XMP metadata"); }

Since it is too much effort to reformat all code, it is currently not enabled -->
<!-- <module name="LeftCurly"/> -->
-->
<module name="LeftCurly"/>

<module name="RightCurly"/>

<!-- coding - https://checkstyle.sourceforge.io/config_coding.html -->

<module name="AvoidDoubleBraceInitialization"/>

<module name="CovariantEquals"/>

<module name="MultipleVariableDeclarations"/>

<module name="OneStatementPerLine">
<property name="treatTryResourcesAsStatement" value="true"/>
</module>

<module name="UnnecessarySemicolonInTryWithResources"/>

<!-- Checks for common coding problems: https://checkstyle.org/config_coding.html -->

<module name="DeclarationOrder"/>
Expand Down
7 changes: 4 additions & 3 deletions docs/guidelines-for-setting-up-a-local-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ Contributions to JabRef's source code need to have a code formatting that is con
4. Check "Store relative to project location"
5. Click "Next" and "Finish"
6. Activate the CheckStyle configuration file by ticking it in the list
7. Ensure that CheckStyle version 8.31 (or higher) is selected
8. Save settings by clicking "OK"
9. Your configuration should now look like this:
7. Ensure that the latest CheckStyle version is selected (8.32 or higher)
8. Set the "Scan Scope" to "Only Java sources (including tests)
9. Save settings by clicking "OK"
10. Your configuration should now look like this:
![checkstyle settings](images/intellij-checkstyle-settings.png)

#### Troubleshooting when using both IDEA and Eclipse
Expand Down
Binary file modified docs/images/intellij-checkstyle-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ public class Globals {

/**
* This field is initialized upon startup.
* <p>
* Only GUI code is allowed to access it, logic code should use dependency injection.
*/
public static JournalAbbreviationRepository journalAbbreviationRepository;

/**
* This field is initialized upon startup.
* <p>
* Only GUI code is allowed to access it, logic code should use dependency injection.
*/
public static ProtectedTermsLoader protectedTermsLoader;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/JabRefException.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ public String getLocalizedMessage() {
return localizedMessage;
}
}

}
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/JabRefExecutorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class JabRefExecutorService {
thread.setName("JabRef CachedThreadPool");
thread.setUncaughtExceptionHandler(new FallbackExceptionHandler());
return thread;

});
private final ExecutorService lowPriorityExecutorService = Executors.newCachedThreadPool(r -> {
Thread thread = new Thread(r);
Expand Down Expand Up @@ -165,5 +164,4 @@ public void run() {
}
}
}

}
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ private static void ensureCorrectJavaVersion() {

if (java9Fail || versionFail) {
StringBuilder versionError = new StringBuilder(
Localization.lang("Your current Java version (%0) is not supported. Please install version %1 or higher.",
checker.getJavaVersion(),
buildInfo.minRequiredJavaVersion));
Localization.lang("Your current Java version (%0) is not supported. Please install version %1 or higher.",
checker.getJavaVersion(),
buildInfo.minRequiredJavaVersion));

versionError.append("\n");
versionError.append(Localization.lang("Your Java Runtime Environment is located at %0.", checker.getJavaInstallationDirectory()));
Expand Down Expand Up @@ -165,7 +165,7 @@ private static void applyPreferences(JabRefPreferences preferences) {

// Build list of Import and Export formats
Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(),
Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
Globals.entryTypesManager.addCustomOrModifiedTypes(preferences.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadBibEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@

// The rationale
String value();

}
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private boolean exportMatches(List<ParserResult> loaded) {
break;
default:
System.err.println(Localization.lang("Output file missing").concat(". \n \t ")
.concat(Localization.lang("Usage")).concat(": ") + JabRefCLI.getExportMatchesSyntax());
.concat(Localization.lang("Usage")).concat(": ") + JabRefCLI.getExportMatchesSyntax());
noGUINeeded = true;
return false;
}
Expand Down Expand Up @@ -442,7 +442,7 @@ private void exportFile(List<ParserResult> loaded, String[] data) {
try {
exporter.get().export(pr.getDatabaseContext(), Path.of(data[0]),
pr.getDatabaseContext().getMetaData().getEncoding()
.orElse(Globals.prefs.getDefaultEncoding()),
.orElse(Globals.prefs.getDefaultEncoding()),
pr.getDatabaseContext().getDatabase().getEntries());
} catch (Exception ex) {
System.err.println(Localization.lang("Could not export file") + " '" + data[0] + "': "
Expand Down Expand Up @@ -516,8 +516,7 @@ private void regenerateBibtexKeys(List<ParserResult> loaded) {
/**
* Run an entry fetcher from the command line.
*
* @param fetchCommand A string containing both the name of the fetcher to use and
* the search query, separated by a :
* @param fetchCommand A string containing both the name of the fetcher to use and the search query, separated by a :
* @return A parser result containing the entries fetched or null if an error occurred.
*/
private Optional<ParserResult> fetch(String fetchCommand) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/cli/CrossrefFetcherEvaluator.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public void run() {
} catch (FetcherException e) {
e.printStackTrace();
}

} else {
try {
Optional<DOI> crossrefDOI = new CrossRef().findIdentifier(entry);
Expand All @@ -86,7 +85,6 @@ public void run() {
countDownLatch.countDown();
}
});

}
countDownLatch.await();

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/jabref/cli/GenerateCharacterTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ public static void main(String[] args) {
System.out
.println(
character.getKey() + " & "
+ ((character.getKey() > 128) ? String
.valueOf(Character.toChars(character.getKey())) : "")
+ ((character.getKey() > 128) ?
String.valueOf(Character.toChars(character.getKey())) : "")
+ " & \\symbol{" + Integer.toString(character.getKey()) + "} & "
+ character.getValue() + " & \\verb¤" + character.getValue() + "¤ \\\\");
}
System.out.println("\\end{supertabular}");
System.out.println("\\end{document}");

}

}
Loading