机器人框架的静态代码分析工具linter
robotframework-robocop的Python项目详细描述
机器人操作系统
Introduction
Robocop是一个对Robot Framework代码执行静态代码分析的工具。在
它使用官方的Robot Framework parsing API来解析文件并运行大量的检查, 寻找潜在的错误或违反代码质量标准。在
Hosted on GitHub
Documentation
提供完整的文档here。在
Values
最初的RoboCop——一个虚构的控制论警察——遵循了3个主要指令 它也推动了机器人的进步:
First Directive: Serve the public trust
这是创建项目的背后,它将服务于开发人员和测试人员,使他们能够信任
Second Directive: Protect the innocent
无辜的测试人员和开发人员无意生成难看的代码,但有时,你知道,它只是发生了, 所以Robocop是用来保护它们的
Third Directive: Uphold the law
遵循项目中制定的编码指南对于保持代码的整洁非常重要, 其他人和Robocop可读和理解可以帮助维护法律
Requirements
Python3.6+和Robot Framework 3.2.1+。在
Example Output
执行命令:
robocop --report rules_by_error_type tests\test.robot
将产生以下输出:
C:\OCP_project\tests\test.robot:7:0 [W] 0509 Section is empty C:\OCP_project\tests\test.robot:22:0 [E] 0801 Multiple test cases with name "Simple Test" in suite C:\OCP_project\tests\test.robot:42:0 [E] 0810 Both Task(s) and Test Case(s) section headers defined in file C:\OCP_project\tests\test.robot:48:0 [W] 0302 Keyword name should be capitalized C:\OCP_project\tests\test.robot:51:13 [I] 0606 This tag is already set by Force Tags in suite settings Found 5 issue(s): 2 WARNING(s), 2 ERROR(s), 1 INFO(s).
Main features
在支持glob模式的命令行中包含/排除规则:
--include *missing* -i W0507 --exclude rule,rule2 -e *doc*
在直接从源代码禁用规则
在Ignoring rules in one line:
This is Keyword # robocop: disable=not-capitalized-keyword-name
Ignoring all rules or selected ones:
Log ${var} Log ${var} # robocop: disable log ${var} # robocop: disable=0301,0302
Ignoring whole blocks or even files:
# robocop: disable=unnecessary-default-tags,0102 *** Settings *** Library RobotLibrary.py # robocop: enable=0102
筛选出低于给定严重级别的所有规则:
--threshold E
在自定义输出消息格式:
--format "{source}:{line}:{col} [{severity}] {rule_id} {desc}"
在每个严重级别的可配置返回状态:
--configure return_status:quality_gate:E=2:W=39
在生成自定义报告:
--reports rules_by_id,rules_by_error_type Issues by ids: W1007 (uneven-indent) : 5 E0904 (nested-for-loop) : 4 W0302 (not-capitalized-keyword-name) : 4 Found 12 issue(s): 9 WARNING(s), 4 ERROR(s).
在可配置的lint规则:
--configure 0507:line_length:100 -c uneven-indent:severity:W
在外部规则支持:
--ext_rules path/to/your/rules.py -rules supports_many_paths.py
在输出重定向到文件:
--output robocop.log
在加载文件时的参数:
--argumentfile jenkins_args.txt
在可配置的扫描文件类型:
--filetypes .txt,.rst
在可以忽略匹配模式的路径:
--ignore *.robot,resources/* --ignore special_file.txt
在
Excuse me, I have to go. Somewhere there is a crime happening. - Robocop
- 项目
标签: