Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
034d03f
Switch to prettier-java
koppor Oct 26, 2023
504f9d4
Add prettier action
koppor Nov 17, 2023
d389a54
Fix parameters
koppor Nov 17, 2023
0bbd3fb
Fix build.gradle
koppor Nov 17, 2023
b2bef3a
Fix build.gradle
koppor Nov 17, 2023
a21f7b3
Try to fix plugin name
koppor Nov 17, 2023
5725873
Try to work-around https://github.com/creyD/prettier_action/issues/111
koppor Nov 17, 2023
531306a
Try to fix installation
koppor Nov 17, 2023
e197cfa
Workaround https://github.com/creyD/prettier_action/issues/128
koppor Nov 17, 2023
b85bc6b
Switch to "npm install"
koppor Nov 17, 2023
7d8339c
Try to work-around https://github.com/creyD/prettier_action/issues/19
koppor Nov 17, 2023
f6566fb
Really version package*.json
koppor Nov 17, 2023
57e11f8
Branches...
koppor Nov 17, 2023
5e3eb76
Branches...
koppor Nov 17, 2023
ac60a12
Branches...
koppor Nov 17, 2023
b905db4
Try other solution
koppor Nov 17, 2023
2f43d7b
Really try to checout
koppor Nov 17, 2023
8b554ff
Let's try with a token
koppor Nov 17, 2023
6c33d7b
Revert "Let's try with a token"
koppor Nov 17, 2023
8b4d2dd
No token
koppor Nov 17, 2023
0b1746d
Reformatted with prettier-java
koppor Nov 17, 2023
3582e1e
Only error, no push - on remote PRs
koppor Nov 17, 2023
0d5cd4e
Remove comments - don't work on forks
koppor Nov 17, 2023
f447423
Disable UnnecessaryParantheses due to https://github.com/openrewrite/…
koppor Nov 17, 2023
2c409bb
Switch to 100 line width
koppor Nov 18, 2023
6f151ec
Reformat code
koppor Nov 18, 2023
5b3c785
Reformat to 100 line length
koppor Nov 18, 2023
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
  •  
  •  
  •  
86 changes: 27 additions & 59 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,37 @@ jobs:
name: Checkstyle
runs-on: ubuntu-latest
steps:
- name: Checkout source
- name: Checkout source (PR)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: 'true'
show-progress: 'false'
- name: Checkout source (no-PR)
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Install prettier-plugin-java
run: npm install
- name: Check code style (using prettier-java)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
uses: creyD/prettier_action@v4.3
with:
prettier_options: --check **/*.java
prettier_plugins: "prettier-plugin-java"
clean_node_folder: false
dry: true
- name: Reformat code (using prettier-java)
if: "!(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)"
uses: creyD/prettier_action@v4.3
with:
prettier_options: --write **/*.java
prettier_plugins: "prettier-plugin-java"
clean_node_folder: false
- name: Set up JDK
uses: actions/setup-java@v3
with:
Expand All @@ -49,20 +75,6 @@ jobs:
checkstyle_version: '10.3'
- name: Run checkstyle using gradle
run: ./gradlew checkstyleMain checkstyleTest checkstyleJmh
- 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 [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
openrewrite:
name: OpenRewrite
runs-on: ubuntu-latest
Expand All @@ -81,19 +93,6 @@ jobs:
- 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
Expand All @@ -114,18 +113,6 @@ jobs:
# 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:
name: Markdown
runs-on: ubuntu-latest
Expand All @@ -141,17 +128,6 @@ jobs:
globs: |
*.md
docs/**/*.md
- name: Add comment on pull request
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@v2
with:
message: >
You modified Markdown (*.md) files.
To ensure consistent styling, we have [markdown-lint](https://github.com/DavidAnson/markdownlint) in place.
[Markdown lint's rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#rules) help to keep our Markdown files consistent within this repository and consistent with the Markdown files outside here.

You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "Markdown".
comment_tag: markdown
changelog:
name: CHANGELOG.md
runs-on: ubuntu-latest
Expand Down Expand Up @@ -198,14 +174,6 @@ jobs:
diff \
<(git show origin/main:CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)') \
<(git show HEAD:CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)')
- name: Add comment on pull request
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@v2
with:
message: >
While the PR was in progress, JabRef released a new version.
You have to merge `upstream/main` and move your entry in `CHANGELOG.md` to section `## [Unreleased]`.
comment_tag: changelog-unreleased-only
tests:
name: Unit tests
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tabWidth: 4
printWidth: 100
plugins:
- prettier-plugin-java
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"java.configuration.updateBuildConfiguration": "interactive",
"java.format.settings.url": "/config/VSCode Code Style.xml",
"java.checkstyle.configuration": "${workspaceFolder}/config/checkstyle/checkstyle_reviewdog.xml",
"java.checkstyle.version": "10.3.4"
"java.checkstyle.version": "10.3.4",
"java.completion.importOrder": ["#"]
}
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ plugins {
id 'jacoco'

id 'checkstyle'
id 'org.openrewrite.rewrite' version '6.4.0'

id 'project-report'

id 'idea'

id 'org.openrewrite.rewrite' version '6.4.0'
}

// Enable following for debugging
Expand Down
12 changes: 2 additions & 10 deletions config/IntelliJ Code Style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,20 @@
</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" />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="255" />
<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
67 changes: 56 additions & 11 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.checkstyle.org/dtds/configuration_1_3.dtd">

<!-- Extended version of https://github.com/jhipster/prettier-java/blob/main/docs/checkstyle/checkstyle.xml -->

<module name="Checker">
<property name="charset" value="UTF-8"/>

Expand Down Expand Up @@ -38,6 +40,8 @@
<!-- LineLength not in place as PreviewerViewer and RelatedArticlesTab have line length with more than 500 charachters -->

<module name="TreeWalker">
<module name="OuterTypeFilename"/>

<!-- Checks for Javadoc comments: https://checkstyle.org/config_javadoc.html -->
<module name="InvalidJavadocPosition"/>
<module name="JavadocMethod">
Expand All @@ -53,12 +57,12 @@
<module name="RedundantImport"/>
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="ImportOrder">
<property name="groups" value="java,javax,javafx,org.jabref,*"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="option" value="bottom"/>
<property name="sortStaticImportsAlphabetically" value="true"/>

<module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
<property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/>
</module>

<!-- Checks for whitespace: https://checkstyle.org/config_whitespace.html -->
Expand All @@ -67,19 +71,53 @@
<module name="EmptyLineSeparator">
<!-- check all except variable declarations -->
<property name="tokens"
value="IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF"/>
value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
STATIC_INIT, INSTANCE_INIT, CTOR_DEF, VARIABLE_DEF, RECORD_DEF,
COMPACT_CTOR_DEF"/>
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="MethodParamPad">
<property name="tokens"
value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF,
SUPER_CTOR_CALL, ENUM_CONSTANT_DEF, RECORD_DEF"/>
</module>
<module name="NoLineWrap">
<property name="tokens" value="PACKAGE_DEF, IMPORT, STATIC_IMPORT"/>
</module>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoLineWrap"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="NoWhitespaceBefore">
<property name="tokens"
value="COMMA, SEMI, POST_INC, POST_DEC, DOT,
LABELED_STAT, METHOD_REF"/>
<property name="allowLineBreaks" value="true"/>
</module>
<module name="ParenPad"/>
<module name="SeparatorWrap">
<property name="tokens" value="COMMA, SEMI, ELLIPSIS, ARRAY_DECLARATOR, RBRACK, METHOD_REF"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapDot"/>
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapComma"/>
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>

<module name="SingleSpaceSeparator"/>
<module name="NoWhitespaceBeforeCaseDefaultColon"/>
<module name="WhitespaceAfter"/>
Expand Down Expand Up @@ -135,6 +173,7 @@
<module name="OneStatementPerLine">
<property name="treatTryResourcesAsStatement" value="true"/>
</module>
<module name="ModifierOrder"/>

<module name="UnnecessarySemicolonInTryWithResources"/>

Expand All @@ -158,5 +197,11 @@
<module name="IllegalIdentifierName"/>

<module name="RecordTypeParameterNameCheck"/>

<module name="AnnotationLocation">
<property name="allowSamelineMultipleAnnotations" value="false"/>
<property name="allowSamelineSingleParameterlessAnnotation" value="false"/>
<property name="allowSamelineParameterizedAnnotation" value="false"/>
</module>
</module>
</module>
Loading