• <i id='QCIkK'><tr id='QCIkK'><dt id='QCIkK'><q id='QCIkK'><span id='QCIkK'><b id='QCIkK'><form id='QCIkK'><ins id='QCIkK'></ins><ul id='QCIkK'></ul><sub id='QCIkK'></sub></form><legend id='QCIkK'></legend><bdo id='QCIkK'><pre id='QCIkK'><center id='QCIkK'></center></pre></bdo></b><th id='QCIkK'></th></span></q></dt></tr></i><div id='QCIkK'><tfoot id='QCIkK'></tfoot><dl id='QCIkK'><fieldset id='QCIkK'></fieldset></dl></div>

  • <legend id='QCIkK'><style id='QCIkK'><dir id='QCIkK'><q id='QCIkK'></q></dir></style></legend>
    <tfoot id='QCIkK'></tfoot>

    <small id='QCIkK'></small><noframes id='QCIkK'>

      <bdo id='QCIkK'></bdo><ul id='QCIkK'></ul>
      1. 自动将大括号添加到 java 代码库中的所有 if/else/for/while 等

        时间:2024-05-10
        <legend id='9LIPu'><style id='9LIPu'><dir id='9LIPu'><q id='9LIPu'></q></dir></style></legend>
          <tbody id='9LIPu'></tbody>

          <small id='9LIPu'></small><noframes id='9LIPu'>

              • <bdo id='9LIPu'></bdo><ul id='9LIPu'></ul>
              • <i id='9LIPu'><tr id='9LIPu'><dt id='9LIPu'><q id='9LIPu'><span id='9LIPu'><b id='9LIPu'><form id='9LIPu'><ins id='9LIPu'></ins><ul id='9LIPu'></ul><sub id='9LIPu'></sub></form><legend id='9LIPu'></legend><bdo id='9LIPu'><pre id='9LIPu'><center id='9LIPu'></center></pre></bdo></b><th id='9LIPu'></th></span></q></dt></tr></i><div id='9LIPu'><tfoot id='9LIPu'></tfoot><dl id='9LIPu'><fieldset id='9LIPu'></fieldset></dl></div>

                <tfoot id='9LIPu'></tfoot>
                  本文介绍了自动将大括号添加到 java 代码库中的所有 if/else/for/while 等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想减少大型遗留 Java 代码库中声纳违规的数量,似乎速赢"是将所有这些条件语句更新为带有大括号.这似乎是一件容易的事情,我不明白为什么它不容易自动化.

                  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.

                  有人知道可以执行这样的批量操作的工具吗?或者为什么在我花时间自己写东西之前做这样的事情可能是个坏主意?如果我自己写一个,最好的工具是什么?理想情况下是 Java 语言感知的东西,这样我就不必处理格式化极端情况等.

                  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.

                  推荐答案

                  最简单的方法是使用 Eclipse然后点击整个项目的Clean-up.在 Clean-up 配置文件中选择 Code style 选项卡.在那里你可以选择 Use blocks in if/while/for/do statements as Always.

                  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 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何忽略 Sonar 中的重复代码报告? 下一篇:如果违反声纳阈值,我如何让 Hudson/Jenkins 失败?

                  相关文章

                  <legend id='BrXNL'><style id='BrXNL'><dir id='BrXNL'><q id='BrXNL'></q></dir></style></legend>
                    <bdo id='BrXNL'></bdo><ul id='BrXNL'></ul>

                  1. <small id='BrXNL'></small><noframes id='BrXNL'>

                      <tfoot id='BrXNL'></tfoot>

                      <i id='BrXNL'><tr id='BrXNL'><dt id='BrXNL'><q id='BrXNL'><span id='BrXNL'><b id='BrXNL'><form id='BrXNL'><ins id='BrXNL'></ins><ul id='BrXNL'></ul><sub id='BrXNL'></sub></form><legend id='BrXNL'></legend><bdo id='BrXNL'><pre id='BrXNL'><center id='BrXNL'></center></pre></bdo></b><th id='BrXNL'></th></span></q></dt></tr></i><div id='BrXNL'><tfoot id='BrXNL'></tfoot><dl id='BrXNL'><fieldset id='BrXNL'></fieldset></dl></div>