From 9f392d4f807d5e56eb22eba5b75d9b1985fd7c3a Mon Sep 17 00:00:00 2001 From: James Adams Date: Fri, 29 Nov 2024 15:18:56 +0000 Subject: [PATCH] panlint: Ignore length of bind lines These are often required to be very long due to binds being made deep into the profile path. There is is no good way to refactor these, so they should not be flagged. --- panc/src/main/scripts/panlint/panlint.py | 2 +- panc/src/main/scripts/panlint/tests.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/panc/src/main/scripts/panlint/panlint.py b/panc/src/main/scripts/panlint/panlint.py index 7407e6e5..0e2dc7ff 100755 --- a/panc/src/main/scripts/panlint/panlint.py +++ b/panc/src/main/scripts/panlint/panlint.py @@ -92,7 +92,7 @@ def diagnose(self): "Use dicts instead of nlists": re.compile(r'\b(?P(?:is_)?nlist)\s*\('), "Include statements no longer need curly braces": re.compile(r'''include\s+(?P{[^;]+})'''), "Line is longer than %s characters" % LINE_LENGTH_LIMIT: - re.compile(r'''^.{0,%s}(?P.*?)$''' % LINE_LENGTH_LIMIT), + re.compile(r'''^(?!bind ).{0,%s}(?P.*?)$''' % LINE_LENGTH_LIMIT), "Commas should be followed by exactly one space": re.compile(r'(?P,(?:\S|\s{2,}))'), "Whitespace before semicolon": re.compile(r'(?P\s+;)'), "Semicolons should be followed exactly one space or end-of-line": re.compile(r';(?P(?:\S|\s{2,}))'), diff --git a/panc/src/main/scripts/panlint/tests.py b/panc/src/main/scripts/panlint/tests.py index 68d14f14..5a66c9d3 100755 --- a/panc/src/main/scripts/panlint/tests.py +++ b/panc/src/main/scripts/panlint/tests.py @@ -482,6 +482,8 @@ def test_check_line_patterns(self): ('error("is_asndate: invalid format for time");', []), ('debug(format("%s: bar: %s", OBJECT, ARGV[0]));', ['Redundant use of format within error or debug call']), ('debug("Foo" + bar + " has an unexpected format (should be a dict)");', []), + ('"/software/components/metaconfig/services/{/etc/example_service_with_long_name/conf.d/dropin_config.cfg}/contents/foo" = "bar";', ['Line is longer than 120 characters']), + ('bind "/software/components/metaconfig/services/{/etc/example_service_with_long_name/conf.d/dropin_config.cfg}/contents" = type_example_service;', []), ] for text, messages in lines: