objccheckstyle
Objective-C style checker with jenkins checkstyle format support
Extension of ocstyle from https://github.com/cue/ocstyle
Installation
pip install objccheckstyle
Arguments
--xmlLogFolderPath
- Required path to provide. By default you need to provide path to root folder of project to be searched by Checkstyle Jenkins plugin
--maxLineLength
- Optional. By default = 120
--excludedDirs
- Optional. By default = None. For example 3d party libs dirs. csv
--checkstyleResultFilename
- Optional. By default = "checkstyle-result.xml"
Example
If you have a file called test.m
like this:
@implementation SomeClass
+(void) someMessage:(NSString*)subdomain {
NSString *ShouldStartLowerCase;
// ...
}
@end
and test.h
like this:
@interface SomeClass
+ (void)someMessage:(NSString*)subdomain;
@property NSInteger value;
@end
Goal
Make it easy to share and enforce style rules for Objective C. The less human time we spend thinking about whitespace and naming the better! Also enforces the existence of basic documentation.
At Cue we use this as a git pre-commit hook. This way we ensure everyone maintains a consistent coding style with a minimum of effort.
Related
OCLint runs static analysis that helps to detect common logic errors. Use it alongside objccheckstyle!
Status
This is a pretty early stage project. We fully expect bugs and feature requests!
One notable absence is that right now style rules are not configurable. For example, we use the following style for message implementations:
+(void) someMessage:(NSString*)subdomain;
{
}
Note the inclusion of the ;
and the {
being on the next line. We like this style because it makes it easy to copy
and paste from .h
to .m
and back, but maybe you have your own preferences. We'd be very happy to accept pull
requests that make ocstyle more configurable.
For the motivated pull requesters out there, other notable TODOs include:
Allow inline disabling of specific errors.
Fix various whitespace false negatives noted in test files
Links
ocstyle is built using parcon, a really nice parser generator library for Python.
Other linters and style checkers we use at Cue include:
Objective C: OCLint
Java: checkstyle
JavaScript: Closure Linter
All: IntelliJ has great code inspections in the editor
License
Apache License version 2.0