blob: d953783c2a832a8de79c4c824c47600052f40a3f [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 """
George Keishing9c223092024-01-29 21:18:25 +053020
Joy Onyerikwu1483ce02019-06-26 14:56:36 -050021 severity = ERROR
22
23 def apply(self, suite):
George Keishing69c5c1c2023-02-21 09:07:05 -060024 r"""
25 Walk through the code and report.
26 """
Joy Onyerikwu1483ce02019-06-26 14:56:36 -050027 for table in suite.tables:
Patrick Williams20f38712022-12-08 06:18:26 -060028 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,
George Keishing69c5c1c2023-02-21 09:07:05 -060036 table.name,
Patrick Williams20f38712022-12-08 06:18:26 -060037 table.linenumber,
38 )