Allow special java statements (for example imports) to be as long as neccessary.


BUG=152209


Review URL: https://chromiumcodereview.appspot.com/11043031

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@160956 0039d316-1c4b-4281-b951-d872f2087c98
parent e6b162cf
......@@ -323,7 +323,14 @@ def CheckLongLines(input_api, output_api, maxlen=80, source_file_filter=None):
# Note: these are C++ specific but processed on all languages. :(
MACROS = ('#define', '#include', '#import', '#pragma', '#if', '#endif')
# Special java statements.
SPECIAL_JAVA_STARTS = ('package ', 'import ')
def no_long_lines(file_extension, line):
# Allow special java statements to be as long as neccessary.
if file_extension == 'java' and line.startswith(SPECIAL_JAVA_STARTS):
return True
file_maxlen = maxlens.get(file_extension, maxlens[''])
# Stupidly long symbols that needs to be worked around if takes 66% of line.
long_symbol = file_maxlen * 2 / 3
......
......@@ -1828,6 +1828,12 @@ class CannedChecksUnittest(PresubmitTestsBase):
self.ContentTest(check, 'A ' * 50, 'foo.java', 'A ' * 50 + 'B', 'foo.java',
presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckSpecialJavaLongLines(self):
check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y)
self.ContentTest(check, 'import ' + 'A ' * 150, 'foo.java',
'importSomething ' + 'A ' * 50, 'foo.java',
presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckLongLinesLF(self):
check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
self.ContentTest(check, '012345678\n', None, '0123456789\n', None,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment