Spotless should flag newline in heading of file #3

Closed
opened 2026-03-15 13:43:57 +01:00 by lars.winzer · 2 comments
lars.winzer commented 2026-03-15 13:43:57 +01:00 (Migrated from git.scicore.unibas.ch)

Both files in the lobbyui test folder have a (unused) newline in the heading of the file.

The rules of both Checkstyle and Spotless should be modified to disallow it.

Both files in the [lobbyui test folder](https://git.scicore.unibas.ch/cs108-fs26/Gruppe-13/-/tree/830c04a7066913aa74f01078e5f71eb1093e7db1/src/test/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/lobbyui) have a (unused) newline in the heading of the file. The rules of both Checkstyle and Spotless should be modified to disallow it.
lars.winzer commented 2026-03-18 18:23:37 +01:00 (Migrated from git.scicore.unibas.ch)

assigned to @lars.winzer

assigned to @lars.winzer
lars.winzer (Migrated from git.scicore.unibas.ch) closed this issue 2026-03-18 19:14:24 +01:00
lars.winzer commented 2026-03-18 19:14:25 +01:00 (Migrated from git.scicore.unibas.ch)

Sadly there is no good way for accomplishing this.

One possible solution would be to utilize the RegexpHeader module of Checkstyle to flag every file, that doesn’t match, for example, the package.

<module name="RegexpHeader">
    <property name="header" value="^package "/>
</module>

The other would be to use the Regexp module for flagging the first line, if it doesn’t contain either the package or import.

<module name="Regexp">
    <property name="format" value="^\s*\n(package|import)"/>
    <property name="illegalPattern" value="true"/>
    <property name="message" value="No blank lines before package declaration."/>
</module>

The advantage of both would be that style is enforced consistently, with the downside of limiting what you can put in the first line (license, BOM, …)

Sadly there is no good way for accomplishing this. One possible solution would be to utilize the `RegexpHeader` module of Checkstyle to flag every file, that doesn’t match, for example, the `package`. ```xml <module name="RegexpHeader"> <property name="header" value="^package "/> </module> ``` The other would be to use the `Regexp` module for flagging the first line, if it doesn’t contain either the `package` or `import`. ```xml <module name="Regexp"> <property name="format" value="^\s*\n(package|import)"/> <property name="illegalPattern" value="true"/> <property name="message" value="No blank lines before package declaration."/> </module> ``` The advantage of both would be that style is enforced consistently, with the downside of limiting what you can put in the first line (license, BOM, …)
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: University-of-Basel-Studentprojects/Programmierprojekt#3