Objective-Clean and SwiftLint

Objective-Clean and SwiftLint are apps which help facilitate automatically checking style in Objective-C and Swift (respectively). When set up properly with the Vokal style files, these apps will give you warnings for various style inconsistencies.

We have a site license available for Objective-Clean and SwiftLint is open source, so they are both free for any engineer at Vokal to use. Their use is therefore strongly encouraged.

Download the trial version of Objective-Clean from the website. Upon running the app successfully, a dialog box will appear in which you can enter our license information.

Note that the style files do not cover all of our code standards, since Objective-Clean and SwiftLint only cover certain formatting options. You and your code reviewer are still responsible for keeping an eye out for anything the app might have missed. It is, however, a great way to keep from getting "Hey, you missed a bracket on the wrong line" comments in code review.

##Initial Setup

If nobody on your project has already set up Objective-Clean or SwiftLint, the steps to do so are pretty simple. Here are the steps for both apps:


Make sure you commit your Style Settings file with the project so all members of a team are getting warnings based on the same style.


##Ignoring Specific Lines

Note that if you ever need to have Objective-Clean skip a part of your file because you're breaking the rules for a good reason, you can force it to skip with a specially formatted comment:


//The code you want to ignore


With SwiftLint, you specify the rule you want to ignore in balanced swiftlint:disable and swiftlint:enable comments. In the example below the force_cast rule is being ignored:

//swiftlint:disable force_cast

//The code you want to ignore for the force_cast rule
let foo = NSNumber() as! Int

//swiftlint:enable force_cast

If you want to prevent Objective-Clean from throwing a warning when it runs on a computer without the appropriate app installed, update the warning line which is added by the app to instead just echo the following: echo "NOTE: You have to install and set up [app name] to use its features!"

More documentation is available at the Objective-Clean site and the SwiftLint site.

##Vokal Limitations