def test__rules__user_rules(): """Test that can safely add user rules.""" # Set up a linter with the user rule linter = Linter(user_rules=[Rule_T042], dialect="ansi") # Make sure the new one is in there. assert ("T042", "A dummy rule.") in linter.rule_tuples() # Instantiate a second linter and check it's NOT in there. # This tests that copying and isolation works. linter = Linter(dialect="ansi") assert not any(rule[0] == "T042" for rule in linter.rule_tuples())
def format_rules(self, linter: Linter, verbose: int = 0) -> str: """Format the a set of rules given a `Linter`.""" text_buffer = StringIO() text_buffer.write("==== sqlfluff - rules ====\n") text_buffer.write( self.cli_table( linter.rule_tuples(), col_width=80, cols=1, label_color=Color.blue, val_align="left", )) return text_buffer.getvalue()
def rules() -> List[RuleTuple]: """Return a list of available rule tuples.""" linter = Linter() return linter.rule_tuples()