diff --git a/docs/code-howtos/faq.md b/docs/code-howtos/faq.md index da5b9343dcd..368ffc96103 100644 --- a/docs/code-howtos/faq.md +++ b/docs/code-howtos/faq.md @@ -7,14 +7,36 @@ parent: Code Howtos Following is a list of common errors encountered by developers which lead to failing tests, with their common solutions: -* `org.jabref.architecture.MainArchitectureTest` `restrictStandardStreams` FAILED - * Fix : Check if you've used ```System.out.println(...)``` (the standard output stream) to log anything into the console. This is an architectural violation, as you should use the Logger instead for logging. More details on how to log can be found [here](https://devdocs.jabref.org/code-howtos/logging.html). +* Failing Checkstyle tests: + * Fix: JabRef follows a pre-defined style of code for uniformity and maintainability that must be adhered to during development. To set up warnings and auto-fixes conforming to these style rules in your IDE, follow [Step 3](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html) of the process to set up a local workspace in the documentation. Ideally, follow all the [set up rules](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/) in the documentation end-to-end to avoid typical set-up errors.
Note: The steps provided in the documentation are for IntelliJ, which is the preferred IDE for Java development. The `checkstyle.xml` is also available for VSCode, in the same directory as mentioned in the steps. -* `org.jabref.architecture.MainArchitectureTest` `doNotUseLogicInModel` FAILED - * Fix : One common case when this test fails is when you put any class purely containing business logic at some level inside the ```model``` directory (```org/jabref/model/```). To fix this, shift the class to a subdirectory within the ```logic``` directory (```org/jabref/logic/```). +* Failing OpenRewrite tests: + * Fix: [OpenRewrite](https://docs.openrewrite.org/) is an automated refactoring ecosystem for source code. Execute the Gradle task `rewriteRun` from the `rewrite` group of the Gradle Tool window in IntelliJ to apply the automated refactoring and pass the test.
+ ![Executing Gradle task rewriteRun](../images/rewriteRun.png)
* `org.jabref.logic.l10n.LocalizationConsistencyTest` `findMissingLocalizationKeys` FAILED - * Fix : You have probably used Strings that are visible on the UI (to the user) but not wrapped them using ```Localization.lang(...)``` and added them to the [localization properties file](https://github.com/JabRef/jabref/blob/main/src/main/resources/l10n/JabRef_en.properties). + * Fix: You have probably used Strings that are visible on the UI (to the user) but not wrapped them using `Localization.lang(...)` and added them to the [localization properties file](https://github.com/JabRef/jabref/blob/main/src/main/resources/l10n/JabRef_en.properties). Read more about the background and format of localization in JabRef [here](https://devdocs.jabref.org/code-howtos/localization.html). +* `org.jabref.logic.l10n.LocalizationConsistencyTest` `findObsoleteLocalizationKeys` FAILED + * Fix: There are localization keys [localization properties file](https://github.com/JabRef/jabref/blob/main/src/main/resources/l10n/JabRef_en.properties) that are not used in the code, probably due to the removal of existing code. Navigate to the unused key-value pairs in the file and remove them. You can always click on the details of the failing test to pinpoint which keys are unused. + Read more about the background and format of localization in JabRef [here](https://devdocs.jabref.org/code-howtos/localization.html). + +* `org.jabref.logic.citationstyle.CitationStyle` `discoverCitationStyles` ERROR: Could not find any citation style. Tried with /ieee.csl. + * Fix: Check the directory `src/main/resources/csl-styles`. If it is missing or empty, run `git submodule update`. Now, check inside if `ieee.csl` exists. If it does not, run `git reset --hard` inside that directory. + +* `java.lang.IllegalArgumentException`: Unable to load locale en-US
ERROR: Could not generate BibEntry citation. The CSL engine could not create a preview for your item. + * Fix: Check the directory `src/main/resources/csl-locales`. If it is missing or empty, run `git submodule update`. If still not fixed, run `git reset --hard` inside that directory. + +* `org.jabref.architecture.MainArchitectureTest` `restrictStandardStreams` FAILED + * Fix: Check if you've used `System.out.println(...)` (the standard output stream) to log anything into the console. This is an architectural violation, as you should use the Logger instead for logging. More details on how to log can be found [here](https://devdocs.jabref.org/code-howtos/logging.html). + +* `org.jabref.architecture.MainArchitectureTest` `doNotUseLogicInModel` FAILED + * Fix: One common case when this test fails is when you put any class purely containing business logic inside the `model` package (i.e., inside the directory `org/jabref/model/`). To fix this, shift the class to a sub-package within the `logic` package (i.e., the directory`org/jabref/logic/`). An efficient way to do this is to use IntelliJ's built-in refactoring capabilities - right-click on the file, go to "Refactor" and use "Move Class". The import statement for all the classes using this class will be automatically adjusted according to the new location.
+ ![Moving a file using refactor](../images/refactor-moving.png)
+ +* `ANTLR Tool version 4.12.0 used for code generation does not match the current runtime version 4.13.1` + * Fix: Execute the Gradle task `clean` from the `build` group of the Gradle Tool Window in IntelliJ:
+ ![Executing Gradle task clean](../images/clean.png)
+ diff --git a/docs/images/clean.png b/docs/images/clean.png new file mode 100644 index 00000000000..c4c0df895aa Binary files /dev/null and b/docs/images/clean.png differ diff --git a/docs/images/refactor-moving.png b/docs/images/refactor-moving.png new file mode 100644 index 00000000000..fb7b5e7fe8f Binary files /dev/null and b/docs/images/refactor-moving.png differ diff --git a/docs/images/rewriteRun.png b/docs/images/rewriteRun.png new file mode 100644 index 00000000000..2bfde7b2755 Binary files /dev/null and b/docs/images/rewriteRun.png differ