Simon
Simon

Reputation: 25983

How do I make naked if statements into a compiler warning in XCode?

We've inherited a codebase with a lot of naked if statements, like so:

if (some_condition)
    do_something();

Our house style forbids this, so I'd like (if possible) for it to be a compiler warning. Can I do that in XCode, and if so, how?

Upvotes: 1

Views: 262

Answers (2)

Karim Mourra
Karim Mourra

Reputation: 57

This can be done with ObjClean http://objclean.com/index.php

Upvotes: 0

Andy Friese
Andy Friese

Reputation: 6479

trojanfoe is right, there's no way to get a warning. You can check that by putting -Weverything in your "Build Settings" in "Other Warning Flags".

Uncrustify is a pretty good code beautifier for many languages, including Objective-C. The config takes some time to setup, for your if-statements you want:

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

Upvotes: 3

Related Questions