George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 2 | # Custom rules file for robotframework-lint. |
George Keishing | 3c23088 | 2022-04-29 03:20:24 -0500 | [diff] [blame] | 3 | # Installation : pip3 install --upgrade robotframework-lint |
| 4 | # Example usage: python3 -m rflint -rA robot_standards -R robot_custom_rules.py . |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 5 | import re |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 6 | |
| 7 | from rflint.common import ERROR, SuiteRule |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 8 | |
| 9 | |
| 10 | class ExtendInvalidTable(SuiteRule): |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 11 | r""" |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 12 | Extend robotframework-lint SuiteRule function for InvalidTable to allow a table section if it is |
| 13 | a section of comments. e.g "*** Comments ***" |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 14 | """ |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 15 | severity = ERROR |
| 16 | |
| 17 | def apply(self, suite): |
| 18 | for table in suite.tables: |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 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 | ) |