使用 Checkstyle 报告可视化 PHP 代码(来自 CodeSniffer)
PHP CodeSniffer是一个非常好的工具,可以帮助我们检查我们的PHP源代码。但 CodeSniffer 的报告并不容易阅读。
我发现 CodeSniffer 可以输出“Checkstyle”xml 报告。有没有办法用 Checkstyle xml 报告可视化 PHP 代码,以便每个开发人员都可以在一页中阅读代码和报告?
事实上,我发现了一个名为 phpUnderControl 的工具,它看起来是一个非常好的持续集成工具,里面的东西可以满足我的要求。但我没有计划更改我的持续集成工具(我正在使用 Apache Continuum)。
所以如果有人能告诉我一个简单的工具或插件,那就最好了。
谢谢。
PHP CodeSniffer is a very good tool to help us check our PHP source code. But the report from CodeSniffer is not easy to read.
I found that CodeSniffer can output 'Checkstyle' xml report. Is that any way to Visualize PHP code with Checkstyle xml report, so that every developer can read code and report in one page?
In fact, I found a tool named phpUnderControl, which looks like a very good Continuous Integration tool and something inside it could cover my requirement. But I have no plan to change my Continuous Integration tool (I'm using Apache Continuum).
So if anyone can tell me a simple tool or plug-in, that would be the best.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上更像是一个评论/问题,但SO认为它太长了,所以我将其表述为答案:
假设您想要像这样输出:
并渲染原始源代码的版本,并突出显示指示的部分不知何故,那么我认为你将不得不“自己动手”。
您必须编写一个脚本,将代码存储库中源文件的路径作为输入参数(例如 path/to/code),并将一大块“checkstyle”XML 作为输入(通过 STDIN),并呈现文件内容(到 STDOUT)作为 HTML 标记。
内部文件的主体应该位于 PRE 元素中(以保留格式),并且带有指向错误/警告“列表元素”的 HREF 链接的每个指定行 + 列将位于 HTML 页面的底部(我不是确定什么样的附加颜色/突出显示可以在 PRE 元素内工作)。
这是一个好主意 - 我想自己拥有这样一个脚本/工具/实用程序!如果我有时间写一篇文章,我承诺将其发布到 Github 上并在此处添加链接。
如果您找到/写了一个,请回答您自己的问题,好吗?
This is really more of a comment/question, but SO thinks it is too long so I'll phrase it as an answer:
Assuming you want to take output like this:
and render a version of the original source code with the indicated sections highlighted somehow, then I think you're going to have "to roll your own".
You'd have to write a script which takes the path to a source file in your code repository as an input parameter (e.g. path/to/code) and a chunk of "checkstyle" XML as input (via STDIN), and renders the contents of the file (to STDOUT) as HTML markup.
The body of the file inside should be in a PRE element (to preserve formatting) and each specified line + column with an HREF link to an error/warning "list element" would be at the bottom of the HTML page (I'm not sure what kind of addition color/highlighting can work inside a PRE element).
This is a good idea - I would like to have such a script/tool/utility myself! If I ever get around to writing one I promise to publish it on Github and add a link to it here.
And if you ever find/write one, PLEASE answer your own question, OK?