EmptyBlock check

37 views
Skip to first unread message

Christian Cecili

unread,
Jan 23, 2024, 10:08:03 AMJan 23
to checkstyle-devel
Hello! I was testing the EmptyBlock check feature, and I noticed that if I write a block with only a comment inside, Checkstyle marks it as an error. I was thinking that, since it's common for many programmers to write what needs to be done in that block in a comment (like TODO comments) and then come back to it at a later time, it would be useful to handle this situation as a kind of WARNING rather than an ERROR. Checkstyle could notify you that you're leaving an empty block, but if it detects a comment inside, it could issue a warning like: "You are leaving an empty block with only one comment inside." I wanted to know what you think about this, whether it's a bad idea or if it's worth discussing in a new issue, or if this feature is already implemented somewhere else (if so, I apologize, it may have escaped my notice😅). Having said that, I still want to express my compliments on the project itself. It's essential for writing clean and readable code, which is crucial for a Java programmer.
checkstyle.png

Roman Ivanov

unread,
Jan 28, 2024, 8:45:21 PMJan 28
to Christian Cecili, checkstyle-devel
Hi Christian,

I noticed that if I write a block with only a comment inside

this is not allowed in checstyle team code base.

since it's common for many programmers to write what needs to be done in that block in a comment (like TODO comments)

TODO also not allowed. You can keep such comments while you writing code, but then you send PR, please cleanup all code.

 it would be useful to handle this situation as a kind of WARNING rather than an ERROR

we do ERROR as clear definition it is not allowed to be in code on merge to main branch, but during Draft PR, sure please use anything you want.

> It's essential for writing clean and readable code,

You can write dirty code while your code is wet, but as you send PR it is considered as "ready final review and merge", so we apply all rules to what is not allowed to stay in code. 

thanks,
Roman Ivanov

On Tue, 23 Jan 2024 at 07:08, Christian Cecili <chri...@gmail.com> wrote:
Hello! I was testing the EmptyBlock check feature, and I noticed that if I write a block with only a comment inside, Checkstyle marks it as an error. I was thinking that, since it's common for many programmers to write what needs to be done in that block in a comment (like TODO comments) and then come back to it at a later time, it would be useful to handle this situation as a kind of WARNING rather than an ERROR. Checkstyle could notify you that you're leaving an empty block, but if it detects a comment inside, it could issue a warning like: "You are leaving an empty block with only one comment inside." I wanted to know what you think about this, whether it's a bad idea or if it's worth discussing in a new issue, or if this feature is already implemented somewhere else (if so, I apologize, it may have escaped my notice😅). Having said that, I still want to express my compliments on the project itself. It's essential for writing clean and readable code, which is crucial for a Java programmer.

--
You received this message because you are subscribed to the Google Groups "checkstyle-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/checkstyle-devel/fd4285dc-cd54-47fb-a924-d1f0a2e4d947n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages