这实际上更像是一个评论/问题,但 SO 认为它太长了,所以我将其作为答案:
假设你想像这样输出:
$ phpcs --report=checkstyle /path/to/code
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="1.0.0">
<file name="/path/to/code/myfile.php">
<error line="2" column="1" severity="error" message="Missing file doc comment" source="PEAR.Commenting.FileComment"/>
<error line="20" column="43" severity="error" message="PHP keywords must be lowercase; expected "false" but found "FALSE"" source="Generic.PHP.LowerCaseConstant"/>
<error line="47" column="1" severity="error" message="Line not indented correctly; expected 4 spaces but found 1" source="PEAR.WhiteSpace.ScopeIndent"/>
<error line="47" column="20" severity="warning" message="Equals sign not aligned with surrounding assignments" source="Generic.Formatting.MultipleStatementAlignment"/>
<error line="51" column="4" severity="error" message="Missing function doc comment" source="PEAR.Commenting.FunctionComment"/>
</file>
</checkstyle>
并以某种方式突出显示指定部分的原始源代码版本,然后我认为您将不得不“自己动手”。
您必须编写一个脚本,将代码存储库中源文件的路径作为输入参数(例如 path/to/code),并将一大块“checkstyle”XML 作为输入(通过 STDIN),并呈现文件的内容(到 STDOUT)作为 HTML 标记。
内部文件的主体应位于 PRE 元素中(以保留格式),并且每个指定的行 + 列带有指向错误/警告“列表元素”的 HREF 链接将位于 HTML 页面的底部(我不是确定什么样的添加颜色/突出显示可以在 PRE 元素中起作用)。
这是个好主意——我想自己拥有这样的脚本/工具/实用程序!如果我有时间写一篇文章,我保证会在 Github 上发布它并在此处添加一个链接。
如果你找到/写过一个,请回答你自己的问题,好吗?