• Stars
    star
    255
  • Rank 158,814 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Objective-C style checker

ocstyle

Objective-C style checker

Installation

pip install ocstyle

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

You can check style like this:

$ ocstyle test.*
test.h
ERROR: 0:-97 [0] - ExpectedInterfaceDocInHeader - Interface requires /** documentation */
ERROR: 3:30 [51] - MissingSpace - Expected 1, got 0
ERROR: 5:1 [65] - ExpectedPropertyDocInHeader - Property requires /** documentation */

test.m
ERROR: 3:2 [28] - MissingSpace - Expected 1, got 0
ERROR: 3:9 [35] - ExtraSpace - Did not expect ' ' here
ERROR: 3:30 [56] - MissingSpace - Expected 1, got 0
ERROR: 3:42 [68] - MissingNewline - Should have newline after ;
ERROR: 3:42 [68] - MissingSemicolon - Expected a semicolon
ERROR: 4:35 [104] - BadLocalVariableName - Local variable must start with a lower case letter```

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 ocstyle!

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:

License

Apache License version 2.0

Authors

Cue

More Repositories

1

scales

scales - Metrics for Python
Python
920
star
2

hookshot

Instrumentation for Objective C for debugging and profiling
Objective-C
392
star
3

fast-python-pb

Fast Protocol Buffers in python (by using the C++ API)
Python
250
star
4

TheKitchenSync

A Tool Belt for iOS Concurrency
Objective-C
197
star
5

greplin-bloom-filter

Java implementation of a probabilistic set data structure
Java
141
star
6

hop

Script to hop to common directories and servers
Lua
112
star
7

greplin-lucene-utils

Some utilities for Lucene
Java
111
star
8

CueTableReloader

A really handy class that automatically figures out insertions, deletions, and reloads in UITableView based on unique item keys.
Objective-C
92
star
9

greplin-exception-catcher

Exception catcher that runs on Google App Engine
Python
74
star
10

greplin-tornado-ses

An asynchronous client for Amazon SES
Python
42
star
11

greplin-zookeeper-utils

Utilities for dealing with Apache Zookeeper
Java
41
star
12

greplin-nagios-utils

Utilities for monitoring with Nagios
Python
39
star
13

lucene-interval-fields

Lucene fields and queries for interval fields.
Java
37
star
14

greplin-tornado-sendgrid

A client for the Sendgrid API
Python
32
star
15

greplin-twisted-utils

Utilities for working with Twisted
Python
28
star
16

qc

QuickCheck for Python
Python
27
star
17

greplin-tornado-stripe

Tornado bindings for Stripe's API
Python
27
star
18

polarbear

OOM diagnostics for Java.
C++
21
star
19

greplin-tornado-mixpanel

A client for the Mixpanel API
Python
20
star
20

greplin-tornado-kissmetrics

A client for the Kissmetrics API
Python
17
star
21

evernote-python-api

Packaged version of latest Evernote Python API
Python
14
star
22

htmltotext

Fork of flaxcode htmltotext module
C++
13
star
23

jsnappy

Java implementation of the Snappy compression/decompression algorithm from Google.
Java
11
star
24

phpserialize

PHP style serialize and unserialize in Python
Python
6
star
25

hegemon

(java)script utilities
Java
5
star
26

skia

Fork of Google's Skia library
C++
4
star
27

pyiso8601

Forked version of pyiso8601 - http://code.google.com/p/pyiso8601
Python
3
star
28

eventlet

Fork of eventlet with patches from Greplin
Python
3
star
29

greplin-vobject

Greplin fork of vobject
Python
2
star
30

hegemon-example

Java
1
star