Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GJF adds <p> tag prior to the <div> tag #1180

Open
Zopsss opened this issue Nov 9, 2024 · 0 comments
Open

GJF adds <p> tag prior to the <div> tag #1180

Zopsss opened this issue Nov 9, 2024 · 0 comments

Comments

@Zopsss
Copy link

Zopsss commented Nov 9, 2024

Detected at: checkstyle/checkstyle#15865, User's got his answer at: checkstyle/checkstyle#15865 (comment)

GJF adds <p> prior to <div> tag, but the style guide says that block-level tags should not be preceded by <p> tag:

https://google.github.io/styleguide/javaguide.html#s7.1.2-javadoc-paragraphs

HTML tags for other block-level elements, such as <ul> or <table>, are not preceded with <p>.

Here's an example of it:

01: /**
02:  * Plugin to standardize all directions to their appropriate abbreviation.
03:  *
04:  * <div>Some javadoc here....</div>
05:  *
06:  * <ul>
07:  * <li>Item - 1 </li>
08:  * <li>Item - 2 </li>
09:  * <li>Item - 3 </li>
10:  * </ul>
11:  *
12:  * <p>This plugin assumes numbered streets have the correct suffix, when applicable.
13:  */
14: public class Test {
15:   /** Some javadoc. */
16:   public static void main(String[] args) {
17: 
18:   }
19: }
20: 
$ java -jar .\checkstyle-10.20.1-all.jar -c .\google_checks.xml  .\Test.java
Starting audit...
Audit done.
$ java -jar .\google-java-format-1.24.0-all-deps.jar .\Test.java > TestUpdated.java
01: /**
02:  * Plugin to standardize all directions to their appropriate abbreviation.
03:  *
04:  * <p><div>Some javadoc here....</div>
05:  *
06:  * <ul>
07:  *   <li>Item - 1
08:  *   <li>Item - 2
09:  *   <li>Item - 3
10:  * </ul>
11:  *
12:  * <p>This plugin assumes numbered streets have the correct suffix, when applicable.
13:  */
14: public class Test {
15:   /** Some javadoc. */
16:   public static void main(String[] args) {}
17: }
18: 
java -jar .\checkstyle-10.20.1-all.jar -c .\google_checks.xml .\TestUpdated.java
Starting audit...
[WARN] C:\checkstyle testing\.\TestUpdated.java:4:4: <p> tag should not precede HTML block-tag '<div>', <p> tag should be removed. [JavadocParagraph]
[WARN] C:\checkstyle testing\.\TestUpdated.java:14:1: The name of the outer type and the file do not match. [OuterTypeFilename]
Audit done.

Ignore the OuterTypeFilename violation.

The formatter added <p> tag preceding to <div> tag, Checkstyle was complaining about it. But this did not happened in case of <ul> tag, formatter didn't added preceding <p> tag to it.

Edit: After formatting, GJF also removes closing li tags ( </li> )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant