blob: 2b1c14ce57696fe5ea351d4a8d8b587ff41188a9 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3
George Keishing69c5c1c2023-02-21 09:07:05 -06002r"""
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
Joy Onyerikwu1483ce02019-06-26 14:56:36 -05009import re
Patrick Williams20f38712022-12-08 06:18:26 -060010
11from rflint.common import ERROR, SuiteRule
Joy Onyerikwu1483ce02019-06-26 14:56:36 -050012
13
14class ExtendInvalidTable(SuiteRule):
Patrick Williams20f38712022-12-08 06:18:26 -060015 r"""
George Keishing69c5c1c2023-02-21 09:07:05 -060016 Extend robotframework-lint SuiteRule function for InvalidTable to allow a
17 table section if it is a section of comments.
18 e.g "*** Comments ***"
Patrick Williams20f38712022-12-08 06:18:26 -060019 """
Joy Onyerikwu1483ce02019-06-26 14:56:36 -050020 severity = ERROR
21
22 def apply(self, suite):
George Keishing69c5c1c2023-02-21 09:07:05 -060023 r"""
24 Walk through the code and report.
25 """
Joy Onyerikwu1483ce02019-06-26 14:56:36 -050026 for table in suite.tables:
Patrick Williams20f38712022-12-08 06:18:26 -060027 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,
George Keishing69c5c1c2023-02-21 09:07:05 -060035 table.name,
Patrick Williams20f38712022-12-08 06:18:26 -060036 table.linenumber,
37 )