Faux Pas

Rules

This page lists all of the 111 rules in Faux Pas.

Each rule is annotated with tags, and they are grouped below based on their “primary” tag. Rules with the “Recommended” tag are enabled by default.

BestPractice

Rules that check for departures from best practices.

Undetached delegate or data source UndetachedDelegate

When an object sets itself as the delegate or data source of one of its members, it must detach that reference in its -[NSObject dealloc] method.

Tags:

BestPractice
Recommended

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Memory allocation without using sizeof MallocWithoutSizeof

The sizeof operator should be used to obtain the correct size for any allocated structure or variable — the sizes of some data types vary between the 32-bit and 64-bit runtimes.

This rule is naïve and may produce false positives in many cases.

Tags:

BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Potential assertion side effects AssertionSideEffects

Warns if assertion macro bodies contain invocations of non-getter methods or functions.

Assertions should not have side effects because they are normally disabled in release builds — the program’s behavior should not be dependent on whether assertions are enabled or not.

This rule considers only Foundation assertion macros.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

+[NSObject load] method without an @autoreleasepool LoadMethodWithoutAutoreleasePool

Applies to projects targeting an OS prior to iOS 6 or Mac OS 10.8.

When the +[NSObject load] method is executed, there may not be an autorelease pool in place, so you must set one up yourself.

This only applies to iOS 5 (and earlier) and OS X 10.7 (and earlier).

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Invocation of superclass implementation of +[NSObject initialize] InitializeSuperInvocation

Implementations of +[NSObject initialize] should not invoke the superclass implementation: this method is special in that the runtime invokes it separately for every subclass.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Hardcoded self class reference HardcodedSelfClass

Warns if an Objective-C class (or an instance of a class) sends a message to its own class object using a hardcoded reference to the class, e.g. [FOOThing alloc].

It is recommended to use self instead (e.g. [self alloc] or [[self class] alloc]) so that the concrete class would receive the message, and subclassing behavior would not be impeded.

Tags:

Recommended
BestPractice

Options:

  • Warn only about allocations
    [warnOnlyAboutAlloc]
    (Boolean)
    Restrict these warnings to allocations of the ‘self’ class.
  • Check only factory methods
    [checkOnlyFactoryMethods]
    (Boolean)
    Enforce this rule only in factory methods.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Macro-based include guard MacroBasedIncludeGuard

Simplify the header by replacing the macro definition check -based include guard with the ‘once’ pragma.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Non-copying property of immutable NSCopying type RetainingImmutableProperty

Warns if “retaining” semantics are specified in a @property declaration for a common immutable NSCopying class type that also has a mutable subclass variant (for example NSString).

This rule helps avoid situations where the value of a property could change without the setter being invoked (i.e. the object gets mutated).

Tags:

Recommended
BestPractice

Options:

  • Ignore private properties
    [ignorePrivateProperties]
    (Boolean)
    Do not warn about properties declared outside of public header files.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Complete NSNotificationCenter detachment CompleteNotificationCenterDetachment

Warns when an object removes itself as an observer to all notifications (by invoking -[NSNotificationCenter removeObserver:] with self).

This can be a problem if a superclass or a subclass wants to keep observing some notifications. The recommended way to handle this is to remove self as an observer only for the specific notifications that you have previously begun observing.

This rule does not warn about such removals occuring in -dealloc.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Old, verbose Objective-C syntax OldVerboseObjCSyntax

Warns if Objective-C literals, boxed expressions and subscript notation are not used whenever possible.

Note that Xcode can automatically fix your code to do this (see the Edit → Refactor → Convert To Modern Objective-C Syntax… menu item).

Tags:

Recommended
BestPractice
Style

Options:

  • Expect literal syntax for mutable collections
    [expectLiteralSyntaxForMutableCollections]
    (Boolean)
    Warn if literal syntax is not used to initialize NSMutableArray and NSMutableDictionary.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Retaining or copying delegate StrongDelegate

To avoid retain cycles, delegate setter methods should not retain or copy the delegate object.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Constructor return type ConstructorReturnType

Warns if an init or factory method return type is anything other than instancetype.

Properly specifying the return type for factory methods (e.g. +[NSArray arrayWithObject:]) allows the compiler to perform more type checking, which helps catch bugs. Even though the compiler automatically determines the return types of init methods (even if they are declared as id) it is still good to be explicit and use instancetype.

Tags:

Recommended
BestPractice

Options:

  • Check init methods
    [checkInitMethods]
    (Boolean)
    Warn about init methods with a return type other than instancetype.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Setter invocation in init or dealloc method SetterInvocationInInitOrDealloc

It is recommended to avoid invoking setter methods on self in init methods, or in -[NSObject dealloc]. Doing so might trigger KVC notifications, which others might observe, and expect the object to be in a valid, consistent state.

Tags:

Recommended
BestPractice

Options:

  • Apply to init methods
    [applyToInit]
    (Boolean)
    Whether to warn about setter invocations in init methods.
  • Apply to dealloc methods
    [applyToDealloc]
    (Boolean)
    Whether to warn about setter invocations in dealloc methods.
  • Warn only if ivar available
    [onlyIfIvarAvailable]
    (Boolean)
    Only warn about cases where an instance variable matching the setter is available.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Modifying the value of an argument variable ArgumentModification

Argument variable values should not be modified directly — code is easier to follow if you can always trust that argument variable values do not change.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Element variable of fast enumeration loop declared outside the loop FastEnumElementOutside

The element variable of a fast enumeration loop should not be used for anything other than holding the loop iteration element, so it follows that there is no reason for the variable to be visible outside the loop.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unused error value UnusedErrorValue

Warns when NSError or CFErrorRef variable values are never used.

If you are not interested in the error return value of a method or function, pass NULL for the error argument.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Copying property of mutable NSCopying type CopyingMutableProperty

Warns if “copying” semantics are specified in a @property declaration for a common mutable NSCopying class type that has an immutable superclass (for example NSMutableArray).

Invoking -[NSCopying copy] for such objects will in many cases return an immutable copy. This means that after assigning a mutable object value to such a property, it may in fact get an immutable copy of the assigned value (which will lead to crashes as soon as any attempt is made to mutate this immutable object).

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Instance method writes to static variable InstanceMethodWritesToStaticVariable

Writing to static variables (which is essentially global state) in instance methods is generally considered bad practice, because it easily leads to undesireable behavior when multiple instances are being manipulated.

Warnings are suppressed for assignments occurring inside dispatch_once() blocks.

Tags:

BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Associated object on value-like type AssociatedObjectOnValueType

Warns when associated objects are attached to value-like types such as NSNumber or UIFont.

Instances of these classes may be shared and/or immortal due to de-duplication and tagged pointers.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Moving common inclusions into prefix header PrefixHeaderIncludeSuggestion

Applies to projects that use a prefix header, and have at least 10 source code files.
Moving commonly used header inclusion directives into a precompiled prefix header improves compilation time.

Tags:

Recommended
BestPractice

Options:

  • Show including files
    [showFiles]
    (Boolean)
    In the diagnostic description, show a list of the files containing the inclusion.
  • Warning threshold percentage
    [warningThresholdPercent]
    (Positive integer)
    The percentage (0-100) of source code files an inclusion must be in to elicit a diagnostic.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Terminating the app in a release build TerminatingApp

Applies to release builds of iOS targets.
The iOS Human Interface Guidelines say that you should never quit an iOS app programmatically.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Category used for “private” declarations PrivateCategory

A class extension should be used instead, because they enable compiler warnings for detecting unimplemented methods.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

IBOutlets in public interface IBOutletsInPublicInterface

IBOutlets are often private implementation details, and should thus be in a private class extension.

This rule warns only about cases where the class is the “File’s Owner” of a XIB whose basename is the same as the class name, and that contains a connection to the outlet.

Tags:

BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Overridden +[NSObject initialize] method in a category InitializeMethodCategoryOverride

The +[NSObject initialize] method should not be overridden in categories, because this will prevent the original implementation from being executed. In many cases, +[NSObject load] may be used instead — it will be executed separately for classes and categories.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Implicitly atomic property ImplicitAtomicProperty

Warns for implicitly atomic properties.

If neither the atomic keyword nor the nonatomic keyword is specified, a property is synthesized as atomic by default.

Tags:

BestPractice

Options:

  • Apply only to UIKit/AppKit subclasses
    [applyOnlyToUIClasses]
    (Boolean)
    UIKit/AppKit classes should only ever be accessed from the main thread, which renders atomicity unnecessary in their properties.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Assigning delegate property AssigningDelegate

Delegate properties should be declared weak instead of assign. Weak references are safer because they become nil when the referenced object is deallocated.

This rule only applies to code compiled with Automatic Reference Counting (ARC).

Tags:

Recommended
BestPractice

Options:

  • Allow unsafe_unretained delegates
    [allowUnsafeUnretained]
    (Boolean)
    Don’t warn about assigning delegates that are declared with the unsafe_unretained attribute.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Method swizzling Swizzling

Warns whenever there are calls to Objective-C runtime API functions that are used to change method implementations.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Discarded opaque NSNotificationCenter observer DiscardedOpaqueNotificationObserver

Warns if the return value of -[NSNotificationCenter addObserverForName:object:queue:usingBlock:] is not stored anywhere. This method returns an opaque observer object that is needed in order to stop observing.

Tags:

Recommended
BestPractice

Options:

  • Do not warn if explicitly cast to void
    [suppressViaVoidCast]
    (Boolean)
    If YES, diagnostics from this rule can be suppressed by casting the return value to (void).
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Fragile error condition check ErrorConditionCheck

Methods that pass back NSError objects by reference return NO or nil to indicate an error condition. This rule warns if the NSError pointer is checked against nil without checking the return value.

Tags:

Recommended
BestPractice
APIUsage

Options:

  • Apply only to system framework methods
    [onlySystemFrameworks]
    (Boolean)
    Don’t warn when the invoked method is not declared in a system framework header.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Redundant inclusion directive RedundantInclude

Applies to projects using a prefix header.

If a header is included in the project’s prefix header, it needn’t be included anywhere else.

This rule does not check header files that are themselves included in the precompiled prefix header.

Tags:

Recommended
BestPractice

Options:

  • Ignore system headers
    [ignoreSystemHeaders]
    (Boolean)
    Allow redundant system header inclusions.
  • Ignore indirect inclusions
    [ignoreIndirectInclusions]
    (Boolean)
    Warn only about inclusions redundant with the prefix header’s direct inclusions.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

NSLog() used in release build NSLogUsed

Applies to release builds.
Logging should be disabled in release builds (except perhaps for fatal errors).

Tags:

Recommended
BestPractice

Options:

  • Allow calling NSLog() via macros
    [allowMacros]
    (Boolean)
    This lets you log e.g. fatal errors even in release builds, but still get warnings if NSLog() is used directly.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unprefixed category method UnprefixedCategoryMethod

Category methods on system classes must be prefixed in order to avoid name collisions.

By default, this rule considers a method name prefixed if it begins with at least three lowercase characters (or the lowercase version of the ‘Class Prefix’ configured for the project), followed by an underscore.

Tags:

Recommended
BestPractice

Options:

  • Allowed prefixes
    [prefixes]
    (Array of strings)
    Prefixes that may be used for category method names. Case sensitive.
  • Ignore setters
    [ignoreSetters]
    (Boolean)
    Do not warn about setter methods.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unidiomatic accessor naming UnidiomaticAccessorNaming

Warns if getter methods are named in the form getSomething instead of something.

Tags:

Recommended
BestPractice
Style

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Using -[UIViewController initWithNibName:bundle:] outside the UIViewController implementation ViewControllerInitWithNibName

It is not advisable to use -[UIViewController initWithNibName:bundle:] to instantiate UIViewController subclasses outside of the subclass implementation itself. This breaks encapsulation (the subclass should be the one to decide which NIB to use) and makes it more likely that a typo in the NIB name string will crash the app during runtime.

Tags:

Recommended
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Resources

Rules that check for mistakes related to static assets or other project resources.

Unexpected retina image resolution RetinaImagesResolution

The retina (‘@2x’ or ‘@3x’) version of an image resource must be exactly double or triple the size of the corresponding low-resolution image (assuming the point size of the presentation context remains the same regardless of screen resolution). Otherwise the effective resolution of the image will not match the effective resolution of its presentation context, which will lead to a blurry image, empty space at the edges, or overflow.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Suspicious bundle resources SuspiciousResources

Some files that are part of the project but only needed at build/development time (e.g. Xcode build configuration (.xcconfig) files) may be added as bundle resources by mistake.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Code refers to unknown resource UnknownResourceCodeReference

Applies to application targets.
Resources loaded from disk at runtime should be included in the bundle resources under the correct path. Remember that unlike most Macs (and thus iOS simulators run on those Macs), iOS devices have a case sensitive filesystem.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Possibly unused resource UnusedResource

Warns about resource files that do not seem to be referred to in code or XIBs.
Please ensure that each resource you remove from your project is in fact unused — in some cases this rule may flag resource files that are not actually unused (for example if file name references are somehow dynamically determined).

Tags:

Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

XIB Reference to unknown class XIBUnknownClassReference

Warns if an Interface Builder file refers to an unknown Objective-C class.

This rule will warn about all references to classes that are not declared in the source code files that Faux Pas checks, or exported in linked libraries.

Tags:

Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

XIB User-defined runtime attribute mismatch XIBRuntimeAttributeMismatch

Warns when a XIB specifies user-defined runtime attributes that don’t match the source code of the associated class.

A key path that doesn’t match any of the class properties or setter methods yields a diagnostic, as does a mismatch in the type of the assigned value and the value type declared for the property or setter.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Missing device type resource MissingDeviceTypeResource

Applies to iOS targets.
Warns if a device type is not covered by the variants of a resource file. E.g. if image~iphone.png exists but image~ipad.png does not.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Missing image resolution variant MissingImageResolutionVariant

Warns when either the high-resolution (@2x or @3x) or the low-resolution variant of an image resource is missing.

Tags:

Recommended
Resources

Options:

  • Expected resolution scales
    [expectedScales]
    (Array of numbers)
    Which resolution variant scales are expected to exist for all images.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Weak reference to top-level XIB object WeakReferenceToTopLevelXIBObject

IBOutlet references to top-level objects in XIBs should be strong, so as to ensure that the object is not deallocated prematurely.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

XIB refers to unknown resource UnknownResourceXIBReference

Applies to application targets.
Resources loaded from disk at runtime should be included in the bundle resources under the correct path. Remember that unlike most Macs (and thus iOS simulators run on those Macs), iOS devices have a case sensitive filesystem.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Global and localized resource GlobalAndLocalizedResource

There should never be both a global and localized version of a given resource, because global resources take precedence over language-specific resources. If a global version of a resource exists, language-specific versions of the same resource are never returned by the platform APIs.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unknown resource file name modifier UnknownResourceModifier

Device type modifiers for device-specific resource files (like ~iphone or ~ipad), as well as the resolution modifier @2x, must be spelled correctly (and case sensitively, due to the case-sensitive filesystem on iOS devices).

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Suspicious missing bundle resources SuspiciousMissingResources

Warns when the project contains certain types of files that are not included into any target as resources, but probably should be.

Tags:

Recommended
Resources

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Duplicate resource DuplicateResource

Warns if two resource files are equal.

Tags:

Resources
Recommended

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Config

Rules that check for mistakes in project configuration.

Build settings set in Xcode GUI BuildSettingsSetInGUI

Applies to projects that use Xcode build configuration files.
Enable this rule if you want to set all of your build configuration values in .xcconfig files, and get warnings whenever something gets accidentally set in the GUI.

Tags:

Config

Options:

  • Which settings are allowed to be set in the GUI
    [allowedGUISettings]
    (Array of strings)
    Some settings are difficult to set in .xcconfig files.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Recommended compiler warning options CompilerWarnings

Some compiler warnings and warning groups are so useful that they should be enabled at all times.

Tags:

Recommended
Config
BestPractice

Options:

  • Recommended warning flags
    [flags]
    (Array of strings)
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Missing API usage description MissingAPIUsageDescription

Applies to application targets.
Some APIs (that access e.g. contacts or calendars) require a usage description (“purpose string”) in the application metadata. This will be shown to the user when the system asks them to allow the application access to the related user data or system resource. This rule warns when some such APIs are used, but the associated usage description is missing.

Tags:

Recommended
Config

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Erroneous view layout in XIB ViewLayoutInXIB

Warns about views that are marked as ‘misplaced’ or ‘ambiguous’ in XIBs or storyboards that use autolayout.

This rule relies on XIB annotations added by Xcode, which means that no diagnostics will be emitted for misplaced or ambiguous views that have not (yet) been annotated by Xcode.

Tags:

Recommended
Config

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Recommended project settings BasicProjectSettings

The ‘Organization’ and ‘Class Prefix’ settings should always be set. The expected values for other settings are configurable.

Tags:

Recommended
Config
BestPractice

Options:

  • The indentation type that should be set
    [indentType]
    ("tabs" / "spaces")
    An empty value disables this check.
  • The ‘tab width’ that should be set
    [tabWidth]
    (Positive integer)
    An empty value disables this check.
  • The ‘indent width’ that should be set
    [indentWidth]
    (Positive integer)
    An empty value disables this check.
  • Whether the ‘wrap lines’ setting should be set or not
    [wrapLines]
    ("wrap" / "nowrap")
    An empty value disables this check.
  • Whether the ‘class prefix’ project setting should have a value
    [expectClassPrefix]
    (Boolean)
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Implicit bundle identifier ImplicitBundleId

It is recommended to choose an explicit value for the bundle identifier: an explicit, matching value must be chosen in iTunes Connect before publishing in the App Store (Xcode by default makes the bundle ID dependent on the PRODUCT_NAME variable).

Tags:

Recommended
Config
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Problematic release build compiler arguments ReleaseBuildCompilerArgs

Applies to release builds.
For release builds, warns when some expected arguments are missing, or some unexpected arguments are present.

Tags:

Recommended
Config

Options:

  • Required compiler arguments for all files
    [requiredArguments]
    (Array of strings)
    Warn whenever any of these arguments is not present.
  • Disallowed compiler arguments for all files
    [disallowedArguments]
    (Array of strings)
    Warn whenever any of these arguments is present.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Xcode build configuration file overwrites previously set value XcconfigOverwrites

Overwriting a previously set value in a build configuration file is often a sign of a mistake somewhere.

It is recommended to set custom intermediary settings in “parent” configuration files and then compose final values for actual build settings in leaf configuration files.

Tags:

Recommended
Config
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Xcode build setting refers to itself BuildSettingSelfReference

Build settings should not refer to themselves. The $(inherited) keyword should be used to append something to an inherited value, and custom intermediary build setting keys should be used to compose values from multiple definitions in an .xcconfig file.

Tags:

Recommended
Config

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Incorrect placement of build setting value BuildSettingPlacement

Warns if preprocessor definitions are defined explicitly using the -D argument instead of defining them in the GCC_PREPROCESSOR_DEFINITIONS (“Preprocessor macros”) build setting.

Also warns if non-warning flags are defined in WARNING_CFLAGS (instead of OTHER_CFLAGS).

Tags:

Recommended
Config

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Absolute path in build setting value AbsPathInBuildSetting

The project build configurations should not contain absolute path references. This will become a problem as soon as the project is moved to another developer’s computer.

Tags:

Recommended
Config

Options:

  • Allow system paths
    [allowSystemPaths]
    (Boolean)
    Do not warn about absolute references to system paths.
  • Regexes for allowed paths
    [allowedPathRegexes]
    (Array of regular expression strings)
    Do not warn about absolute references to paths that match any of these ICU regular expressions.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Project reference to file using absolute path FileRefWithAbsPath

The project should not contain references to files using absolute paths. This will become a problem as soon as the project is moved to another developer’s computer.

Tags:

Recommended
Config

Options:

  • Allow system paths
    [allowSystemPaths]
    (Boolean)
    Do not warn about absolute references to system paths.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Problematic release build settings ReleaseBuildConfig

Applies to release builds.

Warns when certain problematic build setting values are used for release builds.

For example, if program flow instrumentation is enabled, the compiler optimization level is too low, or if the static analyzer is not run.

Tags:

Recommended
Config

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Dynamic library install name DylibInstallName

Applies to OS X targets.

Warns if the install names of dynamic libraries are absolute (@loader_path, @executable_path, or @rpath should be used instead.)

You can use install_name_tool to change dynamic library install names.

Tags:

Recommended
Config

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Localization

Rules that check for mistakes in localization.

Invalid string resource file InvalidStringsFile

Applies to localized projects.
String resource files should be valid dictionary-format property lists.

Tags:

Recommended
Localization

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unused translation UnusedTranslation

Applies to localized projects.
Warns about entries in string resource files that are not directly loaded in code (using NSLocalizedString and its variants).
Please ensure that each entry you remove from your string resource files is in fact unused — in some cases this rule may flag entries that are not actually unused (for example if string resource keys are somehow dynamically determined before supplying them as an argument to NSLocalizedString).

Tags:

Localization

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.
  • Functions used in place of NSLocalizedString
    [localizedStringRoutines]
    (Array of strings)
    The first argument is assumed to be the string key.

Stringsdict file without matching string resource file StringsdictWithoutStrings

Applies to localized projects.
If a .stringsdict file is included as a resource, a .strings file with the same name also needs to be included, even if empty — otherwise translations will not be read from the .stringsdict file.

Tags:

Recommended
Localization

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

UI String not localized HardcodedUIString

Applies to localized projects.
All strings that are given to APIs that display them in the user interface should be routed through NSLocalizedString() and friends.

Tags:

Recommended
Localization

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Missing translation MissingTranslation

Applies to localized projects.
Warns if a translation is missing for a key that is used as argument to NSLocalizedString or its variants.

Tags:

Recommended
Localization

Options:

  • Warn about missing development region translations
    [checkDevRegion]
    (Boolean)
    Enable this if you do not use the key as an implicit default value.
  • Ignored key prefixes
    [ignoredKeyPrefixes]
    (Array of strings)
    Do not warn about missing translations for keys that start with these prefixes.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.
  • Functions used in place of NSLocalizedString
    [localizedStringRoutines]
    (Array of strings)
    The first argument is assumed to be the string key.

Duplicate translation DuplicateTranslation

Applies to localized projects.
Warns if a string resource file contains multiple entries with the same key.

Tags:

Recommended
Localization

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Translation border punctuation mismatch TranslationPunctuation

Applies to localized projects.
Warns if the punctuation at the start or end of translation strings differs between languages.

Tags:

Recommended
Localization

Options:

  • Punctuation characters that should match
    [punctuationChars]
    (String)
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Translation format mismatch TranslationFormatMismatch

Applies to localized projects.
Warns when different language translations for the same key contain mismatched format specifiers.

Tags:

Recommended
Localization

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Uncommented localized string UncommentedLocalizedString

Applies to localized projects.
Warns if NSLocalizedString() or one of its variants is used without a non-empty comment argument.

Tags:

Recommended
Localization

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

APIUsage

Rules that check for deviations from API usage guidelines.

Observing UIKit object using KVO UIKitKVO

The classes of the UIKit framework generally do not support Key-Value Observing (KVO). If KVO does happen to work for some properties, it is undefined behavior and thus not guaranteed to work in future versions.

Tags:

Recommended
APIUsage

Options:

  • Allow observing custom UIKit subclasses
    [allowSubclasses]
    (Boolean)
    Don’t warn about observing custom UIKit subclasses: KVO conformance can be manually implemented for them.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Use of API not available in the minimum deployment target APIAvailability

Warns about usages of system APIs that are not available in the minimum deployment target that your project target is configured to support.
This rule will produce false positives in many cases due to the fact that it cannot detect many runtime API availability checks that your code may contain.

Tags:

APIUsage

Options:

  • Avoid false positives
    [avoidFalsePositives]
    (Boolean)
    Suppress warnings if it looks like appropriate runtime API availability checks might be in place. Will most likely produce false negatives instead.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Restricted direct method call RestrictedDirectMethodCall

Some methods of system classes should not be called directly.

This rule will not warn about overriding methods that call the superclass implementation.

Tags:

Recommended
APIUsage

Options:

  • Allow direct calls from subclasses
    [allowInSubclass]
    (Boolean)
    Do not warn if the called restricted method is defined in a superclass.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Restricted method override RestrictedMethodOverride

Some methods of system classes should not be overridden.

Tags:

Recommended
APIUsage

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Class implements -isEqual: but not -hash IsEqualAndHash

If -isEqual: determines that two objects are equal, they must have the same hash value.

Tags:

Recommended
APIUsage

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Literal string for key path LiteralStringKeyPath

Warns when literal strings are used to specify key paths.

Something like NSStringFromSelector(@selector(foo)) is safer because it makes the compiler aware of the selector being specified — this helps find typos at compile time and allows automatic refactoring tools to make appropriate changes.

Tags:

Recommended
APIUsage

Options:

  • Ignore -valueForKey: (etc) for collections
    [ignoreCollectionsValueForKey]
    (Boolean)
    Many collections implement these by invoking the selector on each item, and the items might be NSDictionaries.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Fixed-format NSDateFormatter not using invariant (POSIX) locale FixedFormatDateFormatter

Warns when an NSDateFormatter is used with fixed-format dates without using the invariant en_US_POSIX locale. If any other locale is used, the date format string may be overwritten, depending on system date and time settings.

When working with user-visible dates, date and time styles should be used instead of setting a date format.

Tags:

Recommended
APIUsage

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Suspicious date-time format SuspiciousDateTimeFormat

Warns about date-time formats that are likely to have unintentional behavior, e.g. “week-year” specifiers (uppercase Y) instead of normal calendar year specifiers (lowercase y).

Tags:

Recommended
APIUsage

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Retain cycle in block API usage BlockAPIRetainCycle

Warns if self is referenced in a block that is used in a context where it is known to cause a retain cycle.

The Clang compiler’s -Warc-retain-cycles warning implements generic retain cycle detection — this rule only considers specific known system framework APIs that the compiler warning does not warn about.

Please carefully review code that this rule warns about before modifying it — retain cycles and object lifetimes are a delicate issue where you must fully understand the context and use case in order to avoid unexpected and undesireable behavior. In other words, this rule may produce false positive diagnostics.

Tags:

Recommended
APIUsage

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Missing NSNotificationCenter observer detachment MissingNotificationCenterDetachment

Applies to projects targeting an OS prior to iOS 9 or Mac OS 10.11.

You must invoke -[NSNotificationCenter removeObserver:] or -[NSNotificationCenter removeObserver:name:object:] before the observer object is deallocated.

This rule only considers cases where the observer reference is self, or an instance variable or an Objective-C property in self.

This only applies to iOS 8 (and earlier) and OS X 10.10 (and earlier).

Tags:

Recommended
APIUsage

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

VCS

Rules that check for mistakes in the project's usage of version control.

String resource file is not UTF-8 StringsFileEncoding

Applies to projects under Git version control.
Git prefers UTF-8 encoding, and doesn’t handle some other encodings (e.g. UTF-16) very well. It thinks UTF-16 -encoded files are binary, and will thus not display line diffs for them.

Tags:

Recommended
VCS
Localization
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Recommended VCS ignores RecommendedVCSIgnores

Applies to projects under Git version control.
Warns whenever some files that are recommended to be ignored by the version control system are not ignored, or vice versa.

Tags:

Recommended
VCS

Options:

  • Whether the Xcode workspace data should be ignored
    [workspaceIgnored]
    (Boolean)
  • Whether CocoaPods data should be ignored
    [cocoaPodsIgnored]
    (Boolean)
    i.e. The Pods folder. Warns only if CocoaPods is used.
  • Whether Carthage/Build should be ignored
    [carthageBuildIgnored]
    (Boolean)
    Warns only if Carthage is used.
  • Whether Carthage/Checkouts should be ignored
    [carthageCheckoutsIgnored]
    (Boolean)
    Warns only if Carthage is used.
  • Whether user-specific AppCode data should be ignored
    [appCodeUserDataIgnored]
    (Boolean)
    i.e. Specific files under the .idea folder. Warns only if this folder exists.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Project reference to file outside version control root FileRefOutsideVCS

Applies to projects using one of these version control systems: Git, Mercurial, Bazaar, Subversion, Fossil.
The project should not contain references to files that are outside the version control working copy root.

Tags:

Recommended
VCS

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Project reference to file ignored in the VCS FileRefIgnoredInVCS

Applies to projects under Git version control.
The project should not contain references to files that are ignored by the version control system.

Tags:

Recommended
VCS

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Style

Rules that check for stylistic issues (as opposed to functional issues).

Usage of retain in ARC code StrongInsteadOfRetain

In files compiled with ARC, warns if the retain property attribute is used. The strong and retain attributes are functionally equivalent, but the former could be considered more idiomatic with ARC.

Tags:

Style

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Null coalescing operator usage NullCoalescingOp

Expressions of the form (obj ? obj : other) should be written as obj ?: other.
Please note that in the form (obj ? obj : other) the obj expression is evaluated twice, while in the obj ?: other form it is evaluated only once.

Tags:

Recommended
Style

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Direction of ordered comparison operators OrderedComparisonOpDirection

Warns if the > or >= operators are used (the < or <= operators should be used instead). This is based on the idea that it is easier to read comparisons where the smaller values are on the left.

Tags:

Style

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Throwing an Objective-C exception ThrowingObjCException

Throwing exceptions in Objective-C is not very idiomatic, and should only be reserved for truly exceptional cases (if that,) and never for flow control.

This rule can help you enforce a policy to never throw exceptions.

Tags:

Style
BestPractice

Options:

  • Allow if sole statement
    [allowIfSoleStatement]
    (Boolean)
    Suppress diagnostics when the exception-raising statement is the only one in the routine.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Shortcut initializer NewInitializer

Some people prefer [[NSObject alloc] init] instead of [NSObject new], or vice versa.

Tags:

Style

Options:

  • Prefer the alloc-init style
    [preferAllocInit]
    (Boolean)
    Warn about [NSObject new] instead of [[NSObject alloc] init].
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Block-typed declaration without typedef NonTypedefBlockDeclaration

It is recommended that typedef be used for all block-typed declarations, for readability.

Tags:

Style
BestPractice

Options:

  • Apply only to function/method arguments
    [onlyArguments]
    (Boolean)
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Spelling error Spelling

Applies on systems that have either the en_US or the en_GB dictionary installed.

Warns if some words in code symbol names are spelled incorrectly.

This rule expects code symbol names to be in English (US and/or GB).

Tags:

Style
Pedantic

Options:

  • Known words
    [knownWords]
    (Array of strings)
    Don’t consider these words misspelled. Case insensitive.
  • Check only public interfaces
    [checkOnlyPublicInterfaces]
    (Boolean)
    Limits spell checking to public headers.
  • Check variables and parameters
    [checkVariablesAndParameters]
    (Boolean)
    Check also variable and parameter declarations.
  • Check C functions
    [checkCFunctions]
    (Boolean)
    Check also function declarations.
  • Minimum word length
    [minWordLength]
    (Positive integer)
    Don’t warn about words shorter than this.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Source file header comment format SourceFileHeaderComment

Warns about errors in source file header comments (that are formatted using the default Xcode template), for example if the file name in the comment does not match the actual file name, or if the placeholder __MyCompanyName__ is present.

Tags:

Style
Pedantic

Options:

  • Expect comments to start with the file name
    [expectCommentToStartWithFilename]
    (Boolean)
    Warn if the first line of a header comment is not the basename of the file.
  • Require header comments in all source files
    [requireHeaderComments]
    (Boolean)
    Warn about missing header comments in source code files.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unprefixed Objective-C class UnprefixedClass

Warns when an Objective-C class name has no prefix (e.g. Thing instead of FPXThing).

Tags:

Recommended
Style
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Dot syntax usage DotSyntax

Warns about [obj foo] or [obj setFoo:x] instead of obj.foo or obj.foo = x.

Can also be configured to enforce dot syntax only for accessors declared with the @property syntax.

Tags:

Style

Options:

  • Enforce dot syntax only for properties
    [onlyForProperties]
    (Boolean)
    Warn if the square bracket syntax is used to access a property, or if dot syntax is used to invoke a non-property accessor.
  • Square bracket syntax method whitelist
    [allowedMethods]
    (Array of strings)
    Whitelist of Objective-C method names that are allowed to be called with the square bracket syntax.
  • Allow factory methods like +[NSArray array]
    [allowConstructors]
    (Boolean)
    Whitelist all class methods whose name is a suffix of the class name.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Identifier naming IdentifierNaming

This rule allows enforcing custom naming guidelines for different kinds of identifiers via regular expressions.

Tags:

Style

Options:

  • Instance variable name format regex
    [ivarNameFormat]
    (Regular expression)
  • Local variable name format regex
    [localVarNameFormat]
    (Regular expression)
    Local variable in a function or method.
  • Function name format regex
    [functionNameFormat]
    (Regular expression)
  • Typedef name format regex
    [typedefNameFormat]
    (Regular expression)
  • Macro name format regex
    [macroNameFormat]
    (Regular expression)
  • Objective-C method name format regex
    [objcMethodNameFormat]
    (Regular expression)
  • Objective-C class name format regex
    [objcClassNameFormat]
    (Regular expression)
  • Objective-C category name format regex
    [objcCategoryNameFormat]
    (Regular expression)
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Macro definition for literal value MacroLiteral

Instead of using a macro definition for a literal value that is used as a constant, define it as an actual constant.

This makes the scope of the constant more explicit (it’s not available in all imported files until undefined) and it cannot be redefined or undefined in some later part of the code. Macro definitions are also not available in the debugger.

Tags:

Style
BestPractice

Options:

  • Allowed literal values
    [allowedLiterals]
    (Array of strings)
    Don’t warn about macro definitions with these values.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Pedantic

Rules that are pedantic about conforming to specifications or conventions.

Unnecessary NULL check before free() UnnecessaryNullCheck

Passing NULL to free() is a no-op.

Tags:

Recommended
Pedantic

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Possibly unused Objective-C method UnusedMethod

Warns about Objective-C methods to which no references are found.

This rule will not warn about IBAction methods, initializer methods, or public methods (methods with a declaration in a header file, excluding header files named in the form *+Private.h). It also won’t warn about unused getter methods whose setter is used, and vice versa.

Please ensure that each method you remove from your code is in fact unused — in some cases this rule may flag methods that are not actually unused (for example some that are referenced from code that has not been checked by this tool).

Tags:

Pedantic

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Reserved identifier name ReservedIdentifierNaming

Warns when identifiers are named using conventions reserved by the C standard or POSIX.

Tags:

Pedantic

Options:

  • Check for identifier names reserved by the C standard
    [checkCStandard]
    (Boolean)
    Identifiers that begin with two underscores, or an underscore and an uppercase letter.
  • Check for identifier names reserved by the POSIX standard
    [checkPOSIXStandard]
    (Boolean)
    Typedef identifiers that end in “_t”.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Cyclomatic complexity CyclomaticComplexity

Warns if a routine has high cyclomatic complexity (that is, the number of linearly independent paths through the routine’s source code).

Tags:

Pedantic

Options:

  • Cyclomatic complexity number warning threshold
    [warningThresholdCCN]
    (Positive integer)
    Warn if a routine’s cyclomatic complexity number exceeds this value.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unnecessary default case in exhaustive switch statement DefaultInExhaustiveSwitch

If a switch statement explicitly handles all possible values, then the default case is unnecessary dead code, and might even be misleading to people reading the code.

If the intended purpose of the default case is to safeguard against enum fields that are added in the future but accidentally left unhandled in the switch, the compiler warning -Wswitch-enum is recommended for that purpose instead.

Tags:

Pedantic

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Casting the return value of malloc() MallocCast

In C, it is not recommended to explicitly cast the return value of malloc() (and other related memory allocation functions.)

This rule does not warn about casts that occur in compilation units compiled in C++ (or Objective-C++) mode.

Tags:

Pedantic
BestPractice

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Reserved symbol prefix ReservedPrefix

Two-character prefixes (such as NS) are reserved for Apple’s system frameworks. Your own code should use prefixes that are three characters long.

Tags:

Recommended
Pedantic

Options:

  • Allow two-character prefixes that don’t overlap system frameworks
    [allowNonOverlappingTwoCharPrefix]
    (Boolean)
    Don’t warn if there are no known system frameworks using the prefix.
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Using a variable marked unused UsedVariableMarkedUnused

Warns when a variable is annotated with the “unused” attribute, but is actually used. This rule does not warn about cases where a variable is marked unused via a pragma directive.

Tags:

Pedantic

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Miscellaneous

Miscellaneous rules

Assignment of weak-unavailable object to a weak property UnsupportedWeakReference

Applies to OS X targets.

In OS X, you cannot create weak references to instances of some classes (see the full list from Apple’s documentation.)

The Clang compiler should warn about assignments of such objects to weak variables.

Tags:

Recommended

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Globally caching a thread-unsafe class instance ThreadUnsafeInstanceCaching

Warns about variables with global storage whose type is an object pointer to a known thread-unsafe class.

-[NSThread threadDictionary] can be used to cache instances of thread-unsafe classes — one instance for each thread.

This rule does not warn about code occuring in subclasses of (or categories on) UIKit or AppKit classes, because it can be assumed that these are always accessed solely from the main thread.

Tags:

Recommended

Options:

  • The thread-unsafe classes to warn about
    [classNames]
    (Array of strings)
  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Unnecessary Nib method UnnecessaryNibMethod

Applies to application targets.
Warns if -[NSObject awakeFromNib] is implemented in a class that is not archived in any known XIB.

Tags:

Recommended

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Ordered comparison of pointer and zero OrderedPointerToZeroComparison

Warns whenever a pointer value is compared to zero using an ordered comparison operator.

The Clang compiler should warn about similar comparisons to values other than zero.

Tags:

Recommended

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Assignment of literal zero to pointer ZeroAssignmentToPointer

Assigning the literal zero to a pointer value might be an indication of a mistake where the programmer actually wanted to assign to an integer-typed member of the pointer type value. Assigning NULL, nil, or Nil instead suppresses warnings from this rule.

Tags:

Recommended

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.

Conflicting category methods CategoryMethodConflict

If the name of a method declared in a category is the same as a method in the original class, or a method in another category on the same class (or even a superclass), the behavior is undefined as to which method implementation is used at runtime.

Tags:

Recommended

Options:

  • Regexes for ignored file paths
    [ignoredFileRegexes]
    (Array of regular expression strings)
    Suppress diagnostics from this rule in files whose full path matches any of these ICU regular expressions.