-
Notifications
You must be signed in to change notification settings - Fork 0
CodeStyle
#K-9 Code Style
Indentation and formatting are enforced by software:
find src/com/fsck/ -name \*.java | xargs astyle --style=ansi --mode=java --indent-switches --indent=spaces=4 --convert-tabs --unpad=paren
Indentation for things outside src/com/fsck is to be left alone.
We use Astyle 1.23
When in doubt, try to follow the Android code style guide but mainly the code style should be CONSISTENT for it to be readable.
http://source.android.com/source/code-style.html
We're trying to make sure all source and resource files consistently use LFs as line delimiters to avoid merge conflicts. For this someone should now and then run:
svn propset svn:eol-style LF -R src res/values* res/layout* res/menu res/xml
to set the property for newly created files.
This should be synchronized with the committers, as it could cause merge problems.
Some files may be inconsistent already, using a mix of LF and CRLF (or possibly even CR). SVN can't automatically fix those, so here's a script to find them (./check_eols.py) and also to fix them (./check_eols.py fix).
#!/usr/bin/python
import os
import re
import sys
dirs = ['src', 'res']
fix = False
if len(sys.argv) > 1 and sys.argv[1] == 'fix':
fix = True
def exclude_dir(path):
excludes = [r'.*/[.]svn.*', r'.*/drawable.*', r'.*src/org/.*']
for exclude in excludes:
if re.match(exclude, path):
return True
return False
for d in dirs:
for (path, dirs, files) in os.walk(d):
if exclude_dir(path):
continue
for fn in files:
fullpath = path + '/' + fn
data = file(fullpath, 'r').read()
crlfs = data.count('\r\n')
lfs = data.count('\n') - crlfs
crs = data.count('\r') - crlfs
if crlfs > 0 or crs > 0:
print "%4d LFs, %4d CRs, %4d CRLFs, %s" % (lfs, crs, crlfs, fullpath),
if fix:
fixed_data = data.replace('\r\n', '\n')
fixed_data = fixed_data.replace('\r', '\n')
file(fullpath, 'w').write(fixed_data)
print "...fixed."
else:
print