Skip to content

Commit

Permalink
Merge pull request facebookarchive#586 from samyzee/master
Browse files Browse the repository at this point in the history
Updates to the lint script

- Check for Copy Headers phase.
- --maxline option for overriding the default line length (100).
  • Loading branch information
jverkoey committed Jun 24, 2011
2 parents f7a93be + e122e6a commit 726841e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/scripts/lint 100755 → 100644
Expand Up @@ -44,6 +44,7 @@ from Pbxproj import relpath


gcopyrightyears = '2009-2011' gcopyrightyears = '2009-2011'
gdivider = '///////////////////////////////////////////////////////////////////////////////////////////////////' gdivider = '///////////////////////////////////////////////////////////////////////////////////////////////////'
maxlinelength = 100


# Program entry. The meat of this script happens in the lint() method below. # Program entry. The meat of this script happens in the lint() method below.
def main(): def main():
Expand All @@ -56,9 +57,16 @@ Verify Three20 style guidelines for source code.'''
parser.add_option("-d", "--delint", dest="delint", parser.add_option("-d", "--delint", dest="delint",
help="Delint the source", help="Delint the source",
action="store_true") action="store_true")
parser.add_option("-l", "--maxline", dest="maxlinelength",
help="Maximum permissible length of a line",type="int",
action="store")


(options, args) = parser.parse_args() (options, args) = parser.parse_args()


global maxlinelength
if options.maxlinelength:
maxlinelength = options.maxlinelength

if len(args) == 0: if len(args) == 0:
parser.print_help() parser.print_help()


Expand Down Expand Up @@ -138,8 +146,9 @@ def lint_project(project_path, options):
# The "Compile sources" phase files # The "Compile sources" phase files
filenames = project.get_built_sources() filenames = project.get_built_sources()


# The "Copy headers" phase files # The "Copy headers" phase files if they exist
filenames = filenames + project.get_built_headers() if project.get_built_headers():
filenames = filenames + project.get_built_headers()


# Iterate through and lint each of the files that have been modified since we last ran # Iterate through and lint each of the files that have been modified since we last ran
# the linter, unless we're forcelinting, in which case we lint everything. # the linter, unless we're forcelinting, in which case we lint everything.
Expand Down Expand Up @@ -204,6 +213,7 @@ def lint(filename, options):
# If isdelinting is True, this method will try to fix as many lint issues as it can and then # If isdelinting is True, this method will try to fix as many lint issues as it can and then
# write the results out to disk. # write the results out to disk.
def lint_basics(filedata, filename, linenofilter, isdelinting = False): def lint_basics(filedata, filename, linenofilter, isdelinting = False):

logger = logging.getLogger() logger = logging.getLogger()


lines = string.split(filedata, "\n") lines = string.split(filedata, "\n")
Expand All @@ -220,15 +230,15 @@ def lint_basics(filedata, filename, linenofilter, isdelinting = False):


for line in lines: for line in lines:
# Check line lengths. # Check line lengths.
if len(line) > 100: if len(line) > maxlinelength:
did_lint_cleanly = False did_lint_cleanly = False
nwarnings = nwarnings + 1 nwarnings = nwarnings + 1


# This is not something we can fix with the delinter. # This is not something we can fix with the delinter.
if isdelinting: if isdelinting:
logger.error('I don\'t know how to split this line up.') logger.error('I don\'t know how to split this line up.')
else: else:
logger.error('Line length > 100') logger.error('Line length > %d'% maxlinelength)


# Check method dividers. # Check method dividers.
if not re.search(r'.h$', filename) and re.search(r'^[-+][ ]*\([\w\s*]+\)', line): if not re.search(r'.h$', filename) and re.search(r'^[-+][ ]*\([\w\s*]+\)', line):
Expand Down

0 comments on commit 726841e

Please sign in to comment.