1#!/usr/bin/env python3
2# Custom rules file for robotframework-lint.
3# Installation : pip3 install --upgrade robotframework-lint
4# Example usage: python3 -m rflint -rA robot_standards -R robot_custom_rules.py .
5import re
6
7from rflint.common import ERROR, SuiteRule
8
9
10class ExtendInvalidTable(SuiteRule):
11    r"""
12    Extend robotframework-lint SuiteRule function for InvalidTable to allow a table section if it is
13    a section of comments. e.g "*** Comments ***"
14    """
15    severity = ERROR
16
17    def apply(self, suite):
18        for table in suite.tables:
19            if not re.match(
20                r"^(settings?|metadata|(test )?cases?|(user"
21                r" )?keywords?|variables?|comments?)$",
22                table.name,
23                re.IGNORECASE,
24            ):
25                self.report(
26                    suite,
27                    "Unknown table name '%s'" % table.name,
28                    table.linenumber,
29                )
30