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
21    severity = ERROR
22
23    def apply(self, suite):
24        r"""
25        Walk through the code and report.
26        """
27        for table in suite.tables:
28            if not re.match(
29                r"^(settings?|metadata|(test )?cases?|(user"
30                r" )?keywords?|variables?|comments?)$",
31                table.name,
32                re.IGNORECASE,
33            ):
34                self.report(
35                    suite,
36                    table.name,
37                    table.linenumber,
38                )
39