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

Refine checkstyle #8688

Merged
merged 9 commits into from
Apr 19, 2022
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
with:
reporter: github-pr-check
checkstyle_config: 'config/checkstyle/checkstyle_reviewdog.xml'
checkstyle_version: '10.1'
- name: Run checkstyle gradle
run: ./gradlew checkstyleMain checkstyleTest checkstyleJmh
- name: Run markdown-lint
Expand Down
9 changes: 9 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
</module>
<module name="RequireEmptyLineBeforeBlockTagGroup"/>
<module name="JavadocMissingLeadingAsteriskCheck"/>

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

Expand Down Expand Up @@ -67,6 +69,7 @@
<property name="tokens" value="COMMA, SEMI, ELLIPSIS, ARRAY_DECLARATOR, RBRACK, METHOD_REF"/>
</module>
<module name="SingleSpaceSeparator"/>
<module name="NoWhitespaceBeforeCaseDefaultColon"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<!-- RCULRY causes issues if classes are nested within arrays, therefore not activated -->
Expand All @@ -83,6 +86,8 @@
<module name="ConstantName">
<property name="format" value="^log(ger)?|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
</module>
<module name="PatternVariableName" />
<module name="RecordComponentName"/>

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

Expand Down Expand Up @@ -137,5 +142,9 @@

<module name="MissingDeprecated"/>

<!-- Checks for illegal usage of reserved names as identifier names, such as "var", "record" - https://checkstyle.sourceforge.io/config_naming.html#IllegalIdentifierName -->
<module name="IllegalIdentifierName"/>

<module name="RecordTypeParameterNameCheck"/>
</module>
</module>
9 changes: 9 additions & 0 deletions config/checkstyle/checkstyle_reviewdog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
</module>
<module name="RequireEmptyLineBeforeBlockTagGroup"/>
<module name="JavadocMissingLeadingAsteriskCheck"/>

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

Expand Down Expand Up @@ -67,6 +69,7 @@
<property name="tokens" value="COMMA, SEMI, ELLIPSIS, ARRAY_DECLARATOR, RBRACK, METHOD_REF"/>
</module>
<module name="SingleSpaceSeparator"/>
<module name="NoWhitespaceBeforeCaseDefaultColon"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<!-- RCULRY causes issues if classes are nested within arrays, therefore not activated -->
Expand All @@ -83,6 +86,8 @@
<module name="ConstantName">
<property name="format" value="^log(ger)?|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
</module>
<module name="PatternVariableName" />
<module name="RecordComponentName"/>

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

Expand Down Expand Up @@ -137,5 +142,9 @@

<module name="MissingDeprecated"/>

<!-- Checks for illegal usage of reserved names as identifier names, such as "var", "record" - https://checkstyle.sourceforge.io/config_naming.html#IllegalIdentifierName -->
<module name="IllegalIdentifierName"/>

<module name="RecordTypeParameterNameCheck"/>
</module>
</module>
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/actions/ActionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static BooleanExpression isFilePresentForSelectedEntry(StateManager state
* Check if at least one of the selected entries has linked files
* <br>
* Used in {@link org.jabref.gui.maintable.OpenExternalFileAction} when multiple entries selected
*
* @param stateManager manager for the state of the GUI
* @return a boolean binding
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
* Represents a binding between a text input control and a auto-completion popup
* This class is a slightly modified version of {@link impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding}
* that works with general text input controls instead of just text fields.
* @param <T>
*
*/
public class AutoCompletionTextInputBinding<T> extends AutoCompletionBinding<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ private void setupValidation() {

/**
* Gets the absolute path relative to the LatexFileDirectory, if given a relative path
*
* @param input the user input path
* @return an absolute path if LatexFileDirectory exists; otherwise, returns input
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
/**
* Metadata extraction from PDFs and plaintext works very well using Grobid, but we do not want to enable it by default
* due to data privacy concerns.
* To make users aware of the feature, we ask each time before querrying Grobid, giving the option to opt-out.
* To make users aware of the feature, we ask each time before querying Grobid, giving the option to opt-out.
*/
public class GrobidOptInDialogHelper {

/**
* If Grobid is not enabled but the user has not expicitly opted-out of Grobid, we ask for permission to send data
* If Grobid is not enabled but the user has not explicitly opted-out of Grobid, we ask for permission to send data
* to Grobid using a dialog and giving an opt-out option.
*
* @param dialogService the DialogService to use
* @return if the user enabled Grobid, either in the past or after being asked by the dialog.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface GUIPostOpenAction {
/**
* This method is queried in order to find out whether the action needs to be
* performed or not.
*
* @param pr The result of the BIB parse operation.
* @return true if the action should be called, false otherwise.
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public FileHistoryMenu(PreferencesService preferences, DialogService dialogServi

/**
* This method is to use typed letters to access recent libraries in menu.
*
* @param keyEvent a KeyEvent.
* @return false if typed char is invalid or not a number.
*/
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/org/jabref/gui/openoffice/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@
import com.sun.star.uno.XComponentContext;

/** Bootstrap offers functionality to obtain a context or simply
a service manager.
The service manager can create a few basic services, whose implementations are:
<ul>
<li>com.sun.star.comp.loader.JavaLoader</li>
<li>com.sun.star.comp.urlresolver.UrlResolver</li>
<li>com.sun.star.comp.bridgefactory.BridgeFactory</li>
<li>com.sun.star.comp.connections.Connector</li>
<li>com.sun.star.comp.connections.Acceptor</li>
<li>com.sun.star.comp.servicemanager.ServiceManager</li>
</ul>

Other services can be inserted into the service manager by
using its XSet interface:
<pre>
XSet xSet = UnoRuntime.queryInterface( XSet.class, aMultiComponentFactory );
// insert the service manager
xSet.insert( aSingleComponentFactory );
</pre>
* a service manager.
* The service manager can create a few basic services, whose implementations are:
* <ul>
* <li>com.sun.star.comp.loader.JavaLoader</li>
* <li>com.sun.star.comp.urlresolver.UrlResolver</li>
* <li>com.sun.star.comp.bridgefactory.BridgeFactory</li>
* <li>com.sun.star.comp.connections.Connector</li>
* <li>com.sun.star.comp.connections.Acceptor</li>
* <li>com.sun.star.comp.servicemanager.ServiceManager</li>
* </ul>
*
* Other services can be inserted into the service manager by
* using its XSet interface:
* <pre>
* XSet xSet = UnoRuntime.queryInterface( XSet.class, aMultiComponentFactory );
* // insert the service manager
* xSet.insert( aSingleComponentFactory );
* </pre>
*/
public class Bootstrap {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* <p>
* {@link PreviewTab} is the controller of Entry Preview tab
* </p>
*
* @see PreviewTab
* */
public class PreviewTabViewModel implements PreferenceTabViewModel {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/logic/bibtex/FileFieldWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static String getStringRepresentation(LinkedFile field) {
/**
* Encodes a two-dimensional String array into a single string, using ':' and
* ';' as separators. The characters ':' and ';' are escaped with '\'.
*
* @param values The String array.
* @return The encoded String.
*/
Expand All @@ -41,6 +42,7 @@ public static String encodeStringArray(String[][] values) {
/**
* Encodes a String array into a single string, using ':' as separator.
* The characters ':' and ';' are escaped with '\'.
*
* @param entry The String array.
* @return The encoded String.
*/
Expand Down
25 changes: 12 additions & 13 deletions src/main/java/org/jabref/logic/bst/TextPrefixFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
import org.jabref.logic.bst.VM.BstFunction;

/**
The |built_in| function {\.{text.prefix\$}} pops the top two literals
(the integer literal |pop_lit1| and a string literal, in that order).
It pushes the substring of the (at most) |pop_lit1| consecutive text
characters starting from the beginning of the string. This function
is similar to {\.{substring\$}}, but this one considers an accented
character (or more precisely, a ``special character''$\!$, even if
it's missing its matching |right_brace|) to be a single text character
(rather than however many |ASCII_code| characters it actually
comprises), and this function doesn't consider braces to be text
characters; furthermore, this function appends any needed matching
|right_brace|s. If any of the types is incorrect, it complains and
pushes the null string.
*
* The |built_in| function {\.{text.prefix\$}} pops the top two literals
* (the integer literal |pop_lit1| and a string literal, in that order).
* It pushes the substring of the (at most) |pop_lit1| consecutive text
* characters starting from the beginning of the string. This function
* is similar to {\.{substring\$}}, but this one considers an accented
* character (or more precisely, a ``special character''$\!$, even if
* it's missing its matching |right_brace|) to be a single text character
* (rather than however many |ASCII_code| characters it actually
* comprises), and this function doesn't consider braces to be text
* characters; furthermore, this function appends any needed matching
* |right_brace|s. If any of the types is incorrect, it complains and
* pushes the null string.
*/
public class TextPrefixFunction implements BstFunction {

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/logic/bst/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,6 @@ public String run(Collection<BibEntry> bibEntries, BibDatabase bibDatabase) {
* field variable is marked as missing for the entry.
* <p>
* We use null for the missing entry designator.
* @param bibDatabase
*/
private void read(BibDatabase bibDatabase) {
FieldWriter fieldWriter = new FieldWriter(new FieldWriterPreferences(true, List.of(StandardField.MONTH), new FieldContentFormatterPreferences()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class CSLAdapter {
/**
* Creates the bibliography of the provided items. This method needs to run synchronized because the underlying
* CSL engine is not thread-safe.
*
* @param databaseContext {@link BibDatabaseContext} is used to be able to resolve fields and their aliases
*/
public synchronized List<String> makeBibliography(List<BibEntry> bibEntries, String style, CitationStyleOutputFormat outputFormat, BibDatabaseContext databaseContext, BibEntryTypesManager entryTypesManager) throws IOException, IllegalArgumentException {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/logic/exporter/Exporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public String toString() {

/**
* Exports to all files linked to a given entry
*
* @param databaseContext the database to export from
* @param filePreferences the filePreferences to use for resolving paths
* @param entryToWriteOn the entry for which we want to write on all linked pdfs
Expand Down Expand Up @@ -90,6 +91,7 @@ public boolean exportToAllFilesOfEntry(BibDatabaseContext databaseContext, FileP
* Behaviour in case the file is linked to different bib-entries depends on the implementation of {@link #export}.
* If it overwrites any existing information, only the last found bib-entry will be exported (as the previous exports are overwritten).
* If it extends existing information, all found bib-entries will be exported.
*
* @param databaseContext the database-context to export from
* @param dataBase the database to export from
* @param filePreferences the filePreferences to use for resolving paths
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/logic/git/GitHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Optional<Ref> getRefForBranch(String branchName) throws GitAPIException, IOExcep

/**
* Creates a commit on the currently checked out branch
*
* @param amend Whether to amend to the last commit (true), or not (false)
* @return Returns true if a new commit was created. This is the case if the repository was not clean on method invocation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ private List<BibEntry> getBibEntries(URL urlForQuery) throws FetcherException {

/**
* Constructs a URL based on the query, size and page number.
* @param luceneQuery the search query
* @param pageNumber the number of the page indexed from 0
*
* @param luceneQuery the search query
* @param pageNumber the number of the page indexed from 0
*/
URL getURLForQuery(QueryNode luceneQuery, int pageNumber) throws URISyntaxException, MalformedURLException, FetcherException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
* separated by " and ". This is the correct behaviour.
* One source lists the names separated by comma, with a comma at the end. We can detect
* this format and fix it.
*
* @param s The author string
* @return The fixed author string
*/
Expand Down
Loading