diff --git a/odoo/tools/cloc.py b/odoo/tools/cloc.py index 3d18968319258aee5f8c6ecaa03a564d10db7081..e3241144f93033f7436ca09da56dc45a2fc499cb 100644 --- a/odoo/tools/cloc.py +++ b/odoo/tools/cloc.py @@ -21,6 +21,7 @@ DEFAULT_EXCLUDE = [ STANDARD_MODULES = ['web', 'web_enterprise', 'website_animate', 'base'] MAX_FILE_SIZE = 25 * 2**20 # 25 MB +MAX_LINE_SIZE = 100000 class Cloc(object): def __init__(self): @@ -60,6 +61,10 @@ class Cloc(object): # Based on https://stackoverflow.com/questions/241327 s = s.strip() + "\n" total = s.count("\n") + # To avoid to use too much memory we don't try to count file + # with very large line, usually minified file + if max(len(l) for l in s.split('\n')) > MAX_LINE_SIZE: + return -1, "Max line size exceeded" def replacer(match): s = match.group(0) return " " if s.startswith('/') else s