Reputation: 113
I'm using Eclipse and checkstyle to not have lines longer than 80 characters.
I've set the Eclipse formatter to follow that rule and it worked for most of the project, except some lines.
Some of those lines were strings so I was able to break them.
However the following lines are not formatted (or wrongly formatted) and automatically reformatted back if I were to change them.
for (final PersistentAuditEvent persistentAuditEvent : persistentAuditEvents) {
private final PersistenceAuditEventRepository persistenceAuditEventRepository;
* <pre>
* throw new CustomParameterizedException("myCustomError", "hello", "world");
* </pre>
@Import(springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration.class)
Note that I've also set the comment maximum length too
Upvotes: 0
Views: 769
Reputation: 17474
You could use an empty line comment to force line breaks against the autoformatter, e.g.
private final PersistenceAuditEventRepository //
persistenceAuditEventRepository;
This is a manual solution of course. Other IDEs, for example IntelliJ IDEA, have an autoformatter setting that says to never exceed the line length. Even that will not cover all cases, of course, so you may still have to suppress some of the warnings.
Upvotes: 1
Reputation: 1508
The line wrapping cannot apply everywhere, because it's used to make code clearer but not more compact.
On attributes, you can wrap the assignment :
private final PersistenceAuditEventRepository persistenceAuditEventRepository = new PersistenceAuditEventRepository();
can be wrapped to something like:
private final PersistenceAuditEventRepository persistenceAuditEventRepository =
new PersistenceAuditEventRepository();
but you can't wrap this code :
private final PersistenceAuditEventRepository persistenceAuditEventRepository;
to :
private final PersistenceAuditEventRepository
persistenceAuditEventRepository;
Because this is not clearer with line wrapping than without.
Now i would say that today 80 is a very low value. I use 150 on my project.
We all know that it's better to have longer attributes name to show intent than small attributes name like we used to see for years.
Upvotes: 1