You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/tests.yml
+57-2Lines changed: 57 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ concurrency:
23
23
24
24
jobs:
25
25
checkstyle:
26
-
name: Code style check
26
+
name: Checkstyle
27
27
runs-on: ubuntu-latest
28
28
steps:
29
29
- name: Checkout source
@@ -52,22 +52,77 @@ jobs:
52
52
with:
53
53
message: >
54
54
Your code currently does not meet JabRef's code guidelines.
55
+
We use [Checkstyle](https://checkstyle.sourceforge.io/) to identify issues.
55
56
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
56
57
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).
57
58
Afterwards, please run checkstyle locally and fix the issues.
58
59
59
60
60
61
More information on code quality in JabRef is available at <https://devdocs.jabref.org/getting-into-the-code/development-strategy.html>.
61
62
comment_tag: checkstyle
62
-
reactions: eyes
63
+
openrewrite:
64
+
name: OpenRewrite
65
+
runs-on: ubuntu-latest
66
+
steps:
67
+
- name: Checkout source
68
+
uses: actions/checkout@v4
69
+
with:
70
+
submodules: 'true'
71
+
show-progress: 'false'
72
+
- name: Set up JDK
73
+
uses: actions/setup-java@v3
74
+
with:
75
+
java-version: 21.0.1
76
+
distribution: 'liberica'
77
+
cache: 'gradle'
63
78
- name: Run OpenRewrite
64
79
run: |
65
80
./gradlew rewriteDryRun
81
+
- name: Add comment on pull request
82
+
if: ${{ failure() }}
83
+
uses: thollander/actions-comment-pull-request@v2
84
+
with:
85
+
message: >
86
+
Your code currently does not meet JabRef's code guidelines.
87
+
We use [OpenRewrite](https://docs.openrewrite.org/) to ensure "modern" Java coding practices.
88
+
The issues found can be **automatically fixed**.
89
+
Please execute the gradle task *`rewriteRun`*, check the results, commit, and push.
90
+
91
+
92
+
You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".
93
+
comment_tag: openrewrite
94
+
modernizer:
95
+
name: Modernizer
96
+
runs-on: ubuntu-latest
97
+
steps:
98
+
- name: Checkout source
99
+
uses: actions/checkout@v4
100
+
with:
101
+
submodules: 'true'
102
+
show-progress: 'false'
103
+
- name: Set up JDK
104
+
uses: actions/setup-java@v3
105
+
with:
106
+
java-version: 21.0.1
107
+
distribution: 'liberica'
108
+
cache: 'gradle'
66
109
- name: Run modernizer
67
110
run: |
68
111
# enable failing of this task if modernizer complains
69
112
sed -i "s/failOnViolations = false/failOnViolations = true/" build.gradle
70
113
./gradlew modernizer
114
+
- name: Add comment on pull request
115
+
if: ${{ failure() }}
116
+
uses: thollander/actions-comment-pull-request@v2
117
+
with:
118
+
message: >
119
+
Your code currently does not meet JabRef's code guidelines.
120
+
We use [Gradle Modernizer Plugin](https://github.com/andygoossens/gradle-modernizer-plugin#gradle-modernizer-plugin) to ensure "modern" Java coding practices.
121
+
Please fix the detected errors, commit, and push.
122
+
123
+
124
+
You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "Modernizer".
Copy file name to clipboardExpand all lines: docs/code-howtos/code-quality.md
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,26 @@ parent: Code Howtos
3
3
---
4
4
# Code Quality
5
5
6
+
## Code style checkers
7
+
8
+
JabRef has three code style checkers in place:
9
+
10
+
*[Checkstyle](https://checkstyle.sourceforge.io/) for basic checks, such as wrong import order.
11
+
*[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)).
12
+
*[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.
13
+
14
+
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.
15
+
16
+
## Monitoring
17
+
6
18
We monitor the general source code quality at three places:
7
19
8
20
*[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).
9
21
*[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).
10
22
*[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/?>.
11
23
24
+
## Background literature
25
+
12
26
We strongly recommend reading following two books on code quality:
13
27
14
28
*[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.
0 commit comments