Skip to content

Commit

Permalink
Merge branch 'main' into removeAppinsightWiring
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor authored Oct 21, 2023
2 parents 729ca48 + d6fd106 commit 3b8d443
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 15 deletions.
59 changes: 57 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ concurrency:

jobs:
checkstyle:
name: Code style check
name: Checkstyle
runs-on: ubuntu-latest
steps:
- name: Checkout source
Expand Down Expand Up @@ -52,22 +52,77 @@ jobs:
with:
message: >
Your code currently does not meet JabRef's code guidelines.
We use [Checkstyle](https://checkstyle.sourceforge.io/) to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow [the setup guide for the codestyle](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html).
Afterwards, please run checkstyle locally and fix the issues.
More information on code quality in JabRef is available at <https://devdocs.jabref.org/getting-into-the-code/development-strategy.html>.
comment_tag: checkstyle
reactions: eyes
openrewrite:
name: OpenRewrite
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Run OpenRewrite
run: |
./gradlew rewriteDryRun
- name: Add comment on pull request
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@v2
with:
message: >
Your code currently does not meet JabRef's code guidelines.
We use [OpenRewrite](https://docs.openrewrite.org/) to ensure "modern" Java coding practices.
The issues found can be **automatically fixed**.
Please execute the gradle task *`rewriteRun`*, check the results, commit, and push.
You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".
comment_tag: openrewrite
modernizer:
name: Modernizer
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Run modernizer
run: |
# enable failing of this task if modernizer complains
sed -i "s/failOnViolations = false/failOnViolations = true/" build.gradle
./gradlew modernizer
- name: Add comment on pull request
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@v2
with:
message: >
Your code currently does not meet JabRef's code guidelines.
We use [Gradle Modernizer Plugin](https://github.com/andygoossens/gradle-modernizer-plugin#gradle-modernizer-plugin) to ensure "modern" Java coding practices.
Please fix the detected errors, commit, and push.
You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "Modernizer".
comment_tag: modernizer
markdown-checks:
name: Markdown style check
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .vscode/ltex.dictionary.en-US.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Checkstyle
CouchDB
JabDrive
JabRef
CouchDB
OpenRewrite
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- When in `biblatex` mode, the [integrity check](https://docs.jabref.org/finding-sorting-and-cleaning-entries/checkintegrity) for journal titles now also checks the field `journal`.
- We added support for exporting to Hayagriva YAML format. [#10382](https://github.com/JabRef/jabref/issues/10382)
- We added support for pushing citations to [TeXShop](https://pages.uoregon.edu/koch/texshop/) on macOS [forum#2699](https://discourse.jabref.org/t/push-to-texshop-mac/2699).
- We added the 'Bachelor's thesis' type for Biblatex's 'Thesis' EntryType [#10029](https://github.com/JabRef/jabref/issues/10029).

### Changed

Expand Down
14 changes: 14 additions & 0 deletions docs/code-howtos/code-quality.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@ parent: Code Howtos
---
# Code Quality

## Code style checkers

JabRef has three code style checkers in place:

* [Checkstyle](https://checkstyle.sourceforge.io/) for basic checks, such as wrong import order.
* [Gradle Modernizer Plugin](https://github.com/andygoossens/gradle-modernizer-plugin#gradle-modernizer-plugin) for Java library usage checks. It ensures that "modern" Java concepts are used (e.g., [one should use `Deque` instead of `Stack`](https://stackoverflow.com/a/73021741/873282)).
* [OpenRewrite](https://docs.openrewrite.org/) for advanced rules. OpenRewrite can also automatically fix issues. JabRef's CI toolchain does NOT automatically rewrite the source code, but checks whether OpenRewrite would rewrite something. As developer, one can execute `./gradlew rewriteRun` to fix the issues.

In case a check fails, [the CI](https://github.com/JabRef/jabref/blob/main/.github/workflows/tests.yml#L24C6-L24C6) automatically adds a comment on the pull request.

## Monitoring

We monitor the general source code quality at three places:

* [codacy](https://www.codacy.com) is a hosted service to monitor code quality. It thereby combines the results of available open source code quality checkers such as [Checkstyle](https://checkstyle.sourceforge.io) or [PMD](https://pmd.github.io). The code quality analysis for JabRef is available at [https://app.codacy.com/gh/JabRef/jabref/dashboard](https://app.codacy.com/gh/JabRef/jabref/dashboard), especially the [list of open issues](https://app.codacy.com/gh/JabRef/jabref/issues/index). In case a rule feels wrong, it is most likely a PMD rule. The JabRef team can change the configuration at [https://app.codacy.com/p/306789/patterns/list?engine=9ed24812-b6ee-4a58-9004-0ed183c45b8f](https://app.codacy.com/p/306789/patterns/list?engine=9ed24812-b6ee-4a58-9004-0ed183c45b8f).
* [codecov](https://codecov.io) is a solution to check code coverage of test cases. The code coverage metrics for JabRef are available at [https://codecov.io/github/JabRef/jabref](https://codecov.io/github/JabRef/jabref).
* [Teamscale](https://www.cqse.eu/en/teamscale/overview/) is a popular German product analyzing code quality. The analysis results are available at <https://demo.teamscale.com/findings.html#/jabref/?>.

## Background literature

We strongly recommend reading following two books on code quality:

* [Java by Comparison](http://java.by-comparison.com) is a book by three JabRef developers which focuses on code improvements close to single statements. It is fast to read and one gains much information from each recommendation discussed in the book.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public TypeEditorViewModel(Field field, SuggestionProvider<?> suggestionProvider
itemMap.put("mathesis", Localization.lang("Master's thesis"));
itemMap.put("phdthesis", Localization.lang("PhD thesis"));
itemMap.put("candthesis", Localization.lang("Candidate thesis"));
itemMap.put("bathesis", Localization.lang("Bachelor's thesis"));
itemMap.put("techreport", Localization.lang("Technical report"));
itemMap.put("resreport", Localization.lang("Research report"));
itemMap.put("software", Localization.lang("Software"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<fx:root spacing="10.0" type="VBox" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.preferences.network.NetworkTab">
<Label styleClass="titleHeader" text="%Network" />
<CheckBox fx:id="versionCheck" text="%Check for latest version online"/>
<Label text="%Please use the latest version of JabRef if you run into a bug. If you encounter an issue or a bug, check the latest version, if the issue is still present." wrapText="true"/>
<Label text="%If you encounter an issue or a bug, please check the latest version, whether the issue is still present." wrapText="true"/>
<Label styleClass="sectionHeader" text="%Remote operation" />
<Label fx:id="remoteLabel" text="%This feature lets new files be opened or imported into an already running instance of JabRef instead of opening a new instance. For instance, this is useful when you open a file in JabRef from your web browser. Note that this will prevent you from running more than one instance of JabRef at a time." textOverrun="CLIP" wrapText="true" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ Incorrect\ ISSN\ format=Incorrect ISSN format
Error\ accessing\ catalog=Error accessing catalog

Check\ for\ latest\ version\ online=Check for latest version online
Please\ use\ the\ latest\ version\ of\ JabRef\ if\ you\ run\ into\ a\ bug.\ If\ you\ encounter\ an\ issue\ or\ a\ bug,\ check\ the\ latest\ version,\ if\ the\ issue\ is\ still\ present.=Please use the latest version of JabRef if you run into a bug. If you encounter an issue or a bug, check the latest version, if the issue is still present.
If\ you\ encounter\ an\ issue\ or\ a\ bug,\ please\ check\ the\ latest\ version,\ whether\ the\ issue\ is\ still\ present.=If you encounter an issue or a bug, please check the latest version, whether the issue is still present.

Keep\ both=Keep both

Expand Down Expand Up @@ -1557,6 +1557,7 @@ Looking\ up\ %0...\ -\ entry\ %1\ out\ of\ %2\ -\ found\ %3=Looking up %0... - e
Audio\ CD=Audio CD
British\ patent=British patent
British\ patent\ request=British patent request
Bachelor's\ thesis=Bachelor's thesis
Candidate\ thesis=Candidate thesis
Collaborator=Collaborator
Column=Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serial;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
Expand Down Expand Up @@ -99,7 +100,7 @@ void languageKeysShouldNotContainUnderscoresForSpaces() throws IOException {
quotedEntries
.stream()
.map(key -> String.format("\n%s (%s)\n", key.getKey(), key.getPath()))
.collect(Collectors.toList()));
.toList());
}

@Test
Expand All @@ -115,23 +116,25 @@ void languageKeysShouldNotContainHtmlBrAndHtmlP() throws IOException {
entriesWithHtml
.stream()
.map(key -> String.format("\n%s (%s)\n", key.getKey(), key.getPath()))
.collect(Collectors.toList()));
.toList());
}

@Test
void findMissingLocalizationKeys() throws IOException {
List<LocalizationEntry> missingKeys = LocalizationParser.findMissingKeys(LocalizationBundleForTest.LANG)
.stream()
.collect(Collectors.toList());
List<LocalizationEntry> missingKeys = new ArrayList<>(LocalizationParser.findMissingKeys(LocalizationBundleForTest.LANG));
assertEquals(Collections.emptyList(), missingKeys,
missingKeys.stream()
.map(key -> LocalizationKey.fromKey(key.getKey()))
.map(key -> String.format("%s=%s",
key.getEscapedPropertiesKey(),
key.getValueForEnglishPropertiesFile()))
.collect(Collectors.joining("\n",
"\n\nDETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH LANGUAGE FILE\n" +
"PASTE THESE INTO THE ENGLISH LANGUAGE FILE\n\n",
"""
DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH LANGUAGE FILE
PASTE THESE INTO THE ENGLISH LANGUAGE FILE
""",
"\n\n")));
}

Expand All @@ -141,8 +144,12 @@ void findObsoleteLocalizationKeys() throws IOException {
assertEquals(Collections.emptySet(), obsoleteKeys,
obsoleteKeys.stream().collect(Collectors.joining("\n",
"Obsolete keys found in language properties file: \n\n",
"\n\n1. CHECK IF THE KEY IS REALLY NOT USED ANYMORE\n" +
"2. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE\n"))
"""
1. CHECK IF THE KEY IS REALLY NOT USED ANYMORE
2. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE
"""))
);
}

Expand Down Expand Up @@ -190,7 +197,7 @@ void languageCanBeLoaded(Language language) {

private static class DuplicationDetectionProperties extends Properties {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private final List<String> duplicates = new ArrayList<>();

Expand Down

0 comments on commit 3b8d443

Please sign in to comment.