xref: /openbmc/openbmc-test-automation/docs/code_standards_check.md (revision 12e3352651ad95eb463088726d628c30a7835e8f)
188bd082aSGeorge Keishing### To check common code misspellings, syntax and standard checks.
288bd082aSGeorge Keishing
388bd082aSGeorge Keishing**Requirement Python 3.x and above**
488bd082aSGeorge Keishing
588bd082aSGeorge KeishingIt is recommended to run these tools against the code before pushing to gerrit.
688bd082aSGeorge KeishingIt helps catches those silly mistake earlier before the review.
788bd082aSGeorge Keishing
888bd082aSGeorge Keishing### 1. codespell
988bd082aSGeorge Keishing
10*12e33526SPatrick WilliamsProject [codespell](https://github.com/codespell-project/codespell) designed
11*12e33526SPatrick Williamsprimarily for checking misspelled words in source code
1288bd082aSGeorge Keishing
1388bd082aSGeorge Keishing```
1488bd082aSGeorge Keishing    $ pip install codespell
1588bd082aSGeorge Keishing```
1688bd082aSGeorge Keishing
1788bd082aSGeorge KeishingExample:
18*12e33526SPatrick Williams
1988bd082aSGeorge Keishing```
2088bd082aSGeorge Keishing    $ codespell templates/test_openbmc_setup.robot
2188bd082aSGeorge Keishing    templates/test_openbmc_setup.robot:13: setings ==> settings
2288bd082aSGeorge Keishing```
2388bd082aSGeorge Keishing
2488bd082aSGeorge Keishing### 2. robotframework-lint
2588bd082aSGeorge Keishing
26*12e33526SPatrick WilliamsProject [robotframework-lint](https://pypi.org/project/robotframework-lint/) for
27*12e33526SPatrick Williamsstatic analysis for robot framework plain text files.
2888bd082aSGeorge Keishing
2988bd082aSGeorge Keishing```
3088bd082aSGeorge Keishing    $ pip install –upgrade robotframework-lint
3188bd082aSGeorge Keishing```
3288bd082aSGeorge Keishing
3388bd082aSGeorge KeishingExample:
34*12e33526SPatrick Williams
3588bd082aSGeorge Keishing```
3688bd082aSGeorge Keishing    $ rflint redfish/service_root/test_service_root_security.robot
3788bd082aSGeorge Keishing    + redfish/service_root/test_service_root_security.robot
3888bd082aSGeorge Keishing    W: 19, 100: Line is too long (exceeds 100 characters) (LineTooLong)
3988bd082aSGeorge Keishing```
4088bd082aSGeorge Keishing
41*12e33526SPatrick WilliamsYou can refer a script with example as well
42*12e33526SPatrick Williams[custom rules](https://github.com/openbmc/openbmc-test-automation/blob/master/robot_custom_rules.py)
43afe4a310SGeorge Keishing
44afe4a310SGeorge Keishing### 3. robot tags check
45afe4a310SGeorge Keishing
46*12e33526SPatrick WilliamsProject [check_robot_tags](https://github.com/generatz/check_robot_tags) Checks
47*12e33526SPatrick Williamsthat Tags are equivalent to test case names or task names.
48afe4a310SGeorge Keishing
49afe4a310SGeorge KeishingExample:
50*12e33526SPatrick Williams
51afe4a310SGeorge Keishing```
52afe4a310SGeorge Keishing    $ git clone https://github.com/generatz/check_robot_tags
53afe4a310SGeorge Keishing    $ cd check_robot_tags/
54afe4a310SGeorge Keishing
55afe4a310SGeorge Keishing    $ awk -f check_robot_tags.awk ~/openbmc-test-automation/redfish/test_xit.robot
56afe4a310SGeorge Keishing     --- /home/openbmc-test-automation/redfish/test_xit.robot:
57afe4a310SGeorge Keishing     Verify No BMC Dump And Application Failures In BMC
58afe4a310SGeorge Keishing     Iam_different_here
59afe4a310SGeorge Keishing```
60