Title: Single argumentless annotation exception from rule 4.8.5 not honored · Issue #342 · google/google-java-format · GitHub
Open Graph Title: Single argumentless annotation exception from rule 4.8.5 not honored · Issue #342 · google/google-java-format
X Title: Single argumentless annotation exception from rule 4.8.5 not honored · Issue #342 · google/google-java-format
Description: https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations states: Exception: A single parameterless annotation may instead appear together with the first line of the signature, for example: @Override public int hashCode() { ....
Open Graph Description: https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations states: Exception: A single parameterless annotation may instead appear together with the first line of the signature, for exam...
X Description: https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations states: Exception: A single parameterless annotation may instead appear together with the first line of the signature, for exam...
Opengraph URL: https://github.com/google/google-java-format/issues/342
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Single argumentless annotation exception from rule 4.8.5 not honored","articleBody":"https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations states:\r\n\r\n> **Exception**: A single parameterless annotation may instead appear together with the first line of the signature, for example:\r\n>\r\n> ```java\r\n> @Override public int hashCode() { ... }\r\n> ```\r\n\r\nGiven code like\r\n```java\r\n@Test public void stuff() {\r\n // ...\r\n}\r\n```\r\nand\r\n```java\r\n@Override public void run() {\r\n // ...\r\n}\r\n```\r\nGJF formats them like\r\n```diff\r\n+@Test\r\n+public void stuff() {\r\n-@Test public void stuff() {\r\n // ...\r\n }\r\n```\r\nand\r\n```diff\r\n+@Override\r\n+public void run() {\r\n-@Override public void run() {\r\n // ...\r\n }\r\n```\r\nin contradiction to this exception.\r\n\r\nWhile I understand why you might not want to format the own-line style _into_ the single-line style, changing the single-line style to the own-line style when it's already in compliance with the rules seems erroneous.\r\n\r\nI'm observing this with version 1.7.\r\n\r\n```\r\n$ cat Test.before | java -jar google-java-format-1.7-all-deps.jar - > Test.after && diff -u Test.before Test.after\r\n--- Test.before\t2019-02-06 13:19:29.000000000 -0500\r\n+++ Test.after\t2019-02-06 13:21:33.000000000 -0500\r\n@@ -3,7 +3,8 @@\r\n import org.junit.Test;\r\n\r\n class Test {\r\n- @Test public void stuff() {\r\n+ @Test\r\n+ public void stuff() {\r\n System.out.println(\"hi\");\r\n }\r\n }\r\n```","author":{"url":"https://github.com/JakeWharton","@type":"Person","name":"JakeWharton"},"datePublished":"2019-02-06T18:21:59Z","url":"https://github.com/google/google-java-format/issues/342"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5133c11c-c00c-5456-8d17-11d07cf739c5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82EC:107463:3DF13:5121C:6AFBD88C |
| html-safe-nonce | 6304f6df07f0f86e9f2ccbbbdee79073375ffa4d802ac33715e11ace9c03523a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkVDOjEwNzQ2MzozREYxMzo1MTIxQzo2QUZCRDg4QyIsInZpc2l0b3JfaWQiOiIxNzU3Mzg2MTkyNzk5Mzg5ODM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 694b95cef25b89ff08741ec5bc5d9981adb2c27c0cdfcc8fb913b64a87834ab8 |
| hovercard-subject-tag | issue:407367757 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/google/google-java-format/342/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0d7e27311638315e23c05d8143bf38476b90cffeb6cd147ad95822ba29152ccc/google/google-java-format/issues/342 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0d7e27311638315e23c05d8143bf38476b90cffeb6cd147ad95822ba29152ccc/google/google-java-format/issues/342 |
| og:image:alt | https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations states: Exception: A single parameterless annotation may instead appear together with the first line of the signature, for exam... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JakeWharton |
| hostname | github.com |
| expected-hostname | github.com |
| None | 18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07 |
| turbo-cache-control | no-preview |
| go-import | github.com/google/google-java-format git https://github.com/google/google-java-format.git |
| octolytics-dimension-user_id | 1342004 |
| octolytics-dimension-user_login | |
| octolytics-dimension-repository_id | 35448780 |
| octolytics-dimension-repository_nwo | google/google-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 35448780 |
| octolytics-dimension-repository_network_root_nwo | google/google-java-format |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 820be804f18e1ef3940bd74a00d41d73d02e2b91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width