【问题标题】:How do I make naked if statements into a compiler warning in XCode?如何在 XCode 中将裸 if 语句变成编译器警告?
【发布时间】:2012-05-09 09:51:48
【问题描述】:

我们继承了一个包含大量 if 语句的代码库,如下所示:

if (some_condition)
    do_something();

我们的房屋风格禁止这样做,因此我希望(如果可能)将其作为编译器警告。我可以在 XCode 中这样做吗?如果可以,怎么做?

【问题讨论】:

  • 不,你不能。您需要查看一些支持 Objective-C 的重新格式化工具,并在 Xcode 之外重新格式化您的代码。

标签: xcode compiler-warnings


【解决方案1】:

木马是对的,没有办法得到警告。您可以通过将-Weverything 放在“其他警告标志”的“构建设置”中来检查。

Uncrustify 是一个非常好的代码美化器,适用于许多语言,包括 Objective-C。对于您想要的 if 语句,配置需要一些时间来设置:

# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'.
mod_full_brace_if                        = force

【讨论】:

    【解决方案2】:

    这可以通过 ObjClean http://objclean.com/index.php 来完成

    【讨论】:

      猜你喜欢
      • 2010-11-27
      • 1970-01-01
      • 2018-03-18
      • 2015-01-01
      • 2011-03-26
      • 2016-06-11
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      相关资源
      最近更新 更多