This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathREADME
158 lines (119 loc) · 6.63 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
NAME
capp_lint.py -- check formatting of Objective-J files
SYNOPSIS
capp_lint.py [options] [file ... | -]
DESCRIPTION
capp_lint.py is a formatting checker for Objective-J. It performs a number of checks that catch
common formatting mistakes, as defined in the Cappuccino coding style guidelines
(http://cappuccino.org/contribute/coding-style.php).
capp_lint.py operates on a list of files and/or directory. You may pass one or more paths (relative to the
current working directory) as arguments to capp_lint.py, or if the first path is "-", the
list of paths is taken from stdin, in which case everything after the "-" is ignored.
If a path is a directory, the directory is recursively scanned for *.j files to check. Symbolic links
are not followed.
The following options are available:
-b/--basedir=BASEDIR
The base directory relative to which filenames will be resolved. If not passed,
it defaults to the current working directory.
-d/--var-declarations=[none|single|strict]
Determines the policy in flagging consecutive var declarations. The choices are:
none - No checking is done.
single - If two var blocks appear consecutively and one of them is
a single variable, the second var block will be flagged.
strict - Any consecutive var declarations will be flagged.
Given the following code:
var foo = "bar",
bar = "foo";
var bow = "foobar",
wow = "woof";
The "none" policy will obviously not flag this. The "single" policy will not flag
this because both blocks contain more than one declaration. The "strict" policy
will flag this. Given the following code:
var foo = "bar",
bar = "foo";
var bow = "foobar";
The "single" policy will flag this because the second block is a single declaration.
-f/--format=[text|html]
Determines the format of the error output. See the OUTPUT section below for more information
on the different formats.
-q/--quiet
Normally capp_lint.py will print a list of the errors it finds. If this option is passed,
the error list is suppressed. This option is mutually exclusive with the -v option.
-v/--verbose
Displays each line as it is processed by capp_lint.py with a line number,
along with some information about syntactic information it finds.
--version
Displays the current version and exits.
-h/--help
Shows a synopsis of the usage and options and exits.
The following formatting errors are flagged by capp_lint.py:
- Lines which contain one or more tabs.
- Lines which contain non-ASCII characters not within quoted strings.
- Lines which contain malformed UTF-8.
- Missing space between control statements and their opening parentheses.
- Trailing whitespace.
- Binary operators without surrounding space.
- Assignment operators without surrounding space.
- Comparison operators without surrounding space.
- Useless unary + operators.
- Extra or missing space in a method declaration.
- Superflous function names.
- Unterminated variable blocks.
- Consecutive var statements.
- Incorrect indentation in a var block.
- Missing statement separators in a var block.
- Inadvertent global variables in a var block.
- Unbalanced [, { or ( in a variable block.
- Opening braces on the same line as a statement.
- Code following a var block that is not outdented from the var block.
EXIT STATUS
capp_lint.py exits with a return status of one if it finds any errors. If no errors are found,
it exits with a return status of zero.
OUTPUT
For each error that capp_lint.py finds, if the -q/--quiet option was not passed, capp_lint.py
will output an error like the following if the error format is text:
AppKit/CPObjectController.j:482: assignment operator without surrounding spaces.
+ for (var i=0, count=[_observationProxies count]; i<count; i++)
^ ^
The filename (relative to the working directory), line number, and type of error are displayed
first, followed by the offending line of source code. When possible and necessary (as in this example),
the location of the errors is indicated below the source line. If only a single file was checked,
the filename is suppressed.
If the error format is html, the output is similar, but instead of using markers to indicate where
the errors occurred, the character at that position is highlighted. In addition, clicking on the
error open TextMate to the file and line number of the error.
WHITESPACE
Cappuccino coding standards stipulate that there should be no trailing whitespace, and that tabs
should consist of 4 spaces, not tab characters. capp_lint will report trailing whitespace and hard tabs.
You should fix those errors before paying attention to any other errors, as the presence of hard tabs
may cause some false positives.
TEXTMATE INTEGRATION
To integrate capp_lint.py into TextMate, double-click capp_lint.tmbundle to install it into TextMate.
Before the bundle can be used, you must make capp_lint.py available to TextMate. The bundle will
look in the following places:
- capp_lint.tmbundle/Support/bin/capp_lint.py
- The path specified by the TextMate shell variable TM_CAPP_LINT (set in TextMate Preferences).
The path should include the filename of the executable file.
- capp_lint.py or capp_lint in your PATH.
The bundle has four commands, accessed by default by pressing Control-L:
- Check current document, show the results in HTML with clickable errors.
- Check current document, show the results in a tooltip.
- Recursively check the selected documents and/or directories in the project drawer.
- Recursively check the entire project.
VAR_DECLARATIONS POLICY
You can set a value for --var-declarations by creating and enabling the TextMate
shell variable TM_CAPP_LINT_VAR_DECLARATIONS in TextMate Preferences. The value should
be one of [none|single|strict]. If not set, the default policy is single.
KNOWN BUGS
capp_lint.py will currently flag false positives for the following cases I know of:
var foo =
[
"bar"
]
- missing statement separator
var x, y, z;
- unterminated var block. This is not actually a bug -- multiple variables are not supposed
to be declared on a single line. The error condition is not properly described.
AUTHORS
Aparajita Fishman, Victory-Heart Productions
aparajita@aparajita.com