I've been revisiting some of my code and realized that my styling methods are pretty unique. Years back, I ran into issues with unreadable code, and the only solution I found was to use @formatter:off, which feels like a pretty terrible trade-off—losing almost all formatter functionality for just one small benefit. To work around this, I developed a technique I call the 'formatter barrier' using empty comments. Even after all this time, I haven't found another viable solution. I'd love to know if @formatter:off is still commonly used or if there are any other methods I might not be aware of. The situation was made worse when Sonar flagged it as a problem, which I really didn't expect!
4 Answers
I totally get where you're coming from! I use the '//' comments as a formatter barrier too, and I thought I was the only one. Those tools like Sonar can be so frustrating, which is why I've switched to alternatives like Checker and Error Prone instead.
Right? Sometimes those tools just don't get the practical side of coding.
I see your argument about longer lines, but there are still many places where shorter lines will display better, especially with side-by-side diffs or on smaller screens. Embracing these restrictions could keep your code looking cleaner across different platforms!
For sure, it’s about how it translates across different environments. Keeping that in mind is key!
Totally agree! Flexibility in style really makes a difference, especially in collaborative projects.
I get your point about modern screens making long lines easier to read, but I think it's still important to keep lines shorter for contexts like split screenings or mobile devices. Shorter lines can really enhance readability in certain setups, so it might be worth considering that too!
Exactly! It’s all about balance. I'd prefer a blend of styles that maintains clarity.
Agreed! Some coding environments definitely benefit from shorter lines.
If you're looking for a solution, you might want to check out gofmt. It enforces a consistent style so you don’t have to rely on barriers. I think a lot of elements in code can be structured more like lists rather than flowing like poetry, which could help with readability.

Yeah, I find Sonar can be quite harsh! It's good to hear I'm not alone in this.