-
Notifications
You must be signed in to change notification settings - Fork 0
CodeStyle
#K-9 Code Style
Indentation and formatting are enforced by software:
astyle --style=java --indent=spaces=4 --brackets=attach --convert-tabs --unpad-paren --pad-header --pad-oper --suffix=none --recursive "src/com/fsck/k9/*.java"
We use Astyle 1.24
Indentation for things outside src/com/fsck is to be left alone.
Try to follow the AOSP Java style guide wherever possible, but as a volunteer project, please read their admonition:
The rules below are not guidelines or recommendations, but strict rules. Contributions to Android generally will not be accepted if they do not adhere to these rules.
as
We would very much like it if you would try not to deviate too wildly from this standard. If you do, it makes our lives a bit harder. But we'd rather work with you to get your code into shape than have you not contribute.
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