Blank line removed after class declaration
See original GitHub issueThis might be done on purpose, but I’m opening this issue to be able to discuss it. Before:
public class JWTFilter extends GenericFilterBean {
public static final String AUTHORIZATION_HEADER = "Authorization";
private TokenProvider tokenProvider;
After:
public class JWTFilter extends GenericFilterBean {
public static final String AUTHORIZATION_HEADER = "Authorization";
private TokenProvider tokenProvider;
I think it would be more readable to add/keep the extra line.
In the following example it’s hard to distinguish between the end of the class declaration (and its superclass and interfaces) and the first field:
public class MyLoooooongClass
extends AbstractAuditingEntity
implements Serializable, MyInterface<AAAAAAA, BBBBBBBBBBB> {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
Also if the first “content” of the class is an inner class the blank line is added:
/**
* some javadoc
*/
public class MyEntityCriteria implements Serializable, Criteria {
/**
* Class for filtering MyEntity
*/
public static class MyEntityFilter extends Filter<MyEntity> {
public MyEntityFilter() {}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Excess blank lines inside and after a class declaration are not ...
Excess blank lines inside and after a class declaration are not removed ... You can adjust minimum number of blank lines around methods...
Read more >How can I suppress the addition of a blank new line after the ...
1 Answer 1 ... In settings: Editor|Code Style|Java on the 'Blank Lines' tab you probably have 'After class header' set to 1. Change...
Read more >Fix coding Standard - There must be no blank line following ...
There must be no blank line following an inline comment Remove that blank line which are not as per coding standard.
Read more >Google Java Style Guide
Line break after the closing brace, only if that brace terminates a statement or terminates the body of a method, constructor, or named...
Read more >Rationale - Prettier
…all you need to do is remove the newline after { : ... Before running Prettier: @observer class OrderLine { @observable price: number...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Are there plans to merge #398 ? This particular issue has me on the fence about adopting prettier for our java project.
I don’t think adding a newline between the last method and end of class is a common style so I would advocate for prettier not doing it.
In terms of adding a newline at the beginning of a class, I think there are definitely cases where this improves readability. And in the cases where it doesn’t seem necessary, it doesn’t actively harm readability (it’s just a minor annoyance that people will get used to). So I would be in favor of keeping the behavior simple/predictable and unconditionally adding a newline at the beginning of a class declaration