George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
George Keishing | 69c5c1c | 2023-02-21 09:07:05 -0600 | [diff] [blame] | 2 | r""" |
| 3 | Custom rules file for robotframework-lint. |
| 4 | Installation : pip3 install --upgrade robotframework-lint |
| 5 | Example usage: |
| 6 | python3 -m rflint -rA robot_standards -R robot_custom_rules.py . |
| 7 | """ |
| 8 | |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 9 | import re |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 10 | |
| 11 | from rflint.common import ERROR, SuiteRule |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 12 | |
| 13 | |
| 14 | class ExtendInvalidTable(SuiteRule): |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 15 | r""" |
George Keishing | 69c5c1c | 2023-02-21 09:07:05 -0600 | [diff] [blame] | 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 ***" |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 19 | """ |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 20 | severity = ERROR |
| 21 | |
| 22 | def apply(self, suite): |
George Keishing | 69c5c1c | 2023-02-21 09:07:05 -0600 | [diff] [blame] | 23 | r""" |
| 24 | Walk through the code and report. |
| 25 | """ |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 26 | for table in suite.tables: |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 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, |
George Keishing | 69c5c1c | 2023-02-21 09:07:05 -0600 | [diff] [blame] | 35 | table.name, |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 36 | table.linenumber, |
| 37 | ) |