Closed jitsni closed 5 years ago
+1 👍
You can change this behaviour easily, just by adding the following lines to the configuration tag of the plugin inside the pom.xml:
<mapping>
<java>SLASHSTAR_STYLE</java>
</mapping>
The comment styles are documented at the README.md file.
An alternative way to mark these comments is with /*- ... */
which indicates that they shouldn't be reformatted which is normally the case for license headers:
http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#350
This is supported by another license plugin through a property:
would it make sense for this plugin to have a standard format for this style?
And there's already a PR for this (/*- .. */
): #115
SLASHSTAR_STYLE
should be default for *.java
The current default /**
for Java isn't just "not preferred". It is outright incorrect. Javadocs are HTML markup, so they should be subject to formatting as HTML by build tooling (for example, to remove redundant whitespace in HTML source). Obviously, we don't want licenses to be interpreted as HTML markup and to be reformatted accordingly.
Additionally, Javadocs are also supposed to document specific language elements which they precede. A javadoc comment prefacing a package
statement is invalid javadoc, because it cannot be rendered in any meaningful way into the generated javadoc pages. As such, this can really mess with some IDEs and Java parsers, which expect valid syntax for javadoc comments and (like the OP said) report this as a dangling comment.
The default behavior can be overridden, yes, but there are at least two problems with this:
The plugin uses
/** ... */
instead of/* ... */
for license headers in java files. Some of the IDEs (like intellij) marks them as "Dangling javadoc comment" (rightly so).