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 | """ |
George Keishing | 9c22309 | 2024-01-29 21:18:25 +0530 | [diff] [blame^] | 20 | |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 21 | severity = ERROR |
| 22 | |
| 23 | def apply(self, suite): |
George Keishing | 69c5c1c | 2023-02-21 09:07:05 -0600 | [diff] [blame] | 24 | r""" |
| 25 | Walk through the code and report. |
| 26 | """ |
Joy Onyerikwu | 1483ce0 | 2019-06-26 14:56:36 -0500 | [diff] [blame] | 27 | for table in suite.tables: |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 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, |
George Keishing | 69c5c1c | 2023-02-21 09:07:05 -0600 | [diff] [blame] | 36 | table.name, |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 37 | table.linenumber, |
| 38 | ) |