在java代码库中自动向所有if / else / for / while等添加大括号 [英] automatically add curly brackets to all if/else/for/while etc. in a java code-base
问题描述
有谁知道可以执行批量操作的工具喜欢这个?或者为什么做这样的事情可能是一个坏主意,然后我花时间写自己的东西?如果我自己写一个,那么最好的工具是什么?理想情况下,这是一个Java语言的意识,所以我不必处理格式角落案件等。
该规则是不可谈判的方式,所以这真的是最好的办法。最简单的事情是使用 www.eclipse.orgrel =noreferrer> Eclipse ,然后在整个项目中点击清理
。在清理
配置文件配置中选择代码样式
选项卡。在那里你可以选择在if / while / for / do语句中使用块总是
。
I want to reduce the number of sonar violations in a large legacy java code-base, and it seems a "quick win" would be to update all these conditional statements to have curly brackets. This seems like an easy thing to do and I can't see why it wouldn't be readily automatable.
Does anybody know of a tool that could perform a bulk operation like this? Or why to do such a thing might be a bad idea before I go and spend the time writing something myself? If I were to write one myself what would be the best tools to use? Ideally something that is java language aware, so that I don't have to deal with formatting corner-cases and the like.
The rule is non-negotiable by the way, so this really is the best approach.
The easiest thing would be to use Eclipse and click Clean-up
on the whole project. In Clean-up
profile configuration select Code style
tab. There you can select Use blocks in if/while/for/do statements
as Always
.
这篇关于在java代码库中自动向所有if / else / for / while等添加大括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!