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