def lint(self): self.all_tokens = self.flatten_tokens(parse(self.get_file_contents()), []) linting_errors = [] for token in self.all_tokens: if token.is_keyword: keyword_linter = KeywordLinter(self.get_rule_list()) if keyword_linter.is_invalid(token.value): linting_errors.append( keyword_linter.get_invalid_message( token.value, self.get_line_number(token))) if len(linting_errors) > 0: self.print_file_name() Reporter.add_message(f'{len(linting_errors)} error(s) found:') for linting_error in linting_errors: Reporter.add_message(linting_error)
def format(self): file_contents = self.get_file_contents() formatter = Formatter() file_contents = formatter.format(file_contents, **self.get_rule_list()) Reporter.add_message(file_contents)
def print_file_name(self): Reporter.add_message(f'\nFile: {self.sql_file}')