Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def violations(src_path):
"""Return list of violations.
Given the path to a .sql file, analyze it and return a list of
violations (i.e. formatting or style issues).
:param src_path:
:return: list of Violation
"""
linter = get_linter(get_config())
linter.output_func = None
linted_path = linter.lint_path(src_path, ignore_non_existent_files=True)
result = []
for violation in linted_path.get_violations():
try:
# Normal SQLFluff warnings
message = violation.description
except AttributeError:
# Parse errors
message = str(violation)
result.append(Violation(violation.line_no(), message))
return result