qafoo/quality-analyzer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

qafoo/quality-analyzer

Composer 安装命令:

composer require qafoo/quality-analyzer

包简介

Helper for code reviews

README 文档

README

Travis Status

This software is a tool to visualize metrics and source code. We use this software for Code Reviews together with our customers.

Screeenshot

Running the analyzers requires the respective PHP tools, which are installed using composer and can all be run using a convenience command. You may also run the tools in your common build process, though.

To display the metrics a pure JavaScript / CSS stack is used so you could build and serve the results inside continuous integration tools like Jenkins. This might seem strange but it works really well even with software spanning 800,000 lines of PHP code.

If you want to improve, enhance the software or just fix some annoying bugs, you are very welcome to do so. The technology stack involved sadly is not that simple, though (PHP, Symfony2, Ant, Babel, D3, Grunt, Jasmine, Karma, SASS, PhantomJs, React, React-Router, Underscore, Webpack). A Code of Conduct applies for any interaction with this project – if you feel like it is violated get in contact with Kore.

Setup

To use the software there are very few steps involved. The only requirement is a current version of PHP.

Run the following commands to install the software:

git clone https://github.com/Qafoo/QualityAnalyzer.git
cd QualityAnalyzer
composer install

In the next step you can already analyze some software using something like this:

bin/analyze analyze src/php/

See "Usage" for more details on the command. The results of this command can be found in the data/ folder.

Finally you can start the webserver to view the results:

bin/analyze serve

Click around and enjoy the data!

Usage

You start by analyzing a certain project or providing the tool with the paths to existing analyze files, like code coverage reports:

bin/analyze analyze /path/to/source

With the default command the tool will analyze the source code itself. For tools like PHPMD or PDepend this makes a lot of sense since the tool already knows which options to use for each tool.

There are some reports we cannot generate ourselves like code coverage from your tests. You can tell the tool where to find certain files to make sure they are available and ready to be used:

bin/analyze \
    --coverage=/path/to/clover.xml \
    --tests=/path/to/junit.xml \
    analyze /path/to/source

You can also specify already generated files for all the other tools. But the visualization might behave strangely if some reports are generated in the wrong formats or some options are missing. We do not verify this (yet) properly.

To view the report in HTML format, run bin/analyze bundle /path/for/generated/html and then open /path/for/generated/html/index.html with your browser.

Ignore Sub-Directories

You might also want to tell the tools which directories there are to ignore by the tools. This is especially important if you have (large) libraries in your source directory – you do not want to analyze those. For this you may use the --exclude option:

bin/analyze \
    --coverage=/path/to/clover.xml \
    --tests=/path/to/junit.xml \
    --exclude=libraries,vendor \
    analyze /path/to/source

After the analyzer has finished use bin/analyze serve or similar means to access the index.html with your browser and enjoy the results visualization.

Exclude Analyzers

You might also to avoid some analyzers to be run on your code intentionally, e.g. if you don't want your git usage be analysed. For this you may use the --exclude_analyzers option:

bin/analyze \
    --exclude_analyzers=git,gitDetailed \
    analyze /path/to/source

To get a list of all available analyzers, run:

bin/analyze list:analyzers

Customize Tools

If you want to customize tool execution you can always run all the tools yourself and pass the existing result files to the analyze command. An example customizable ant build file doing this can be found here: src/examples/customize.xml or src/examples/parallel.xml.

The parameters to pass you custom results, which wil omit running the tool by the analyzer command itself are:

--pdepend=PDEPEND            Path to PDepend summary XML file
--dependencies=DEPENDENCIES  Path to PDepend dependencies XML file
--phpmd=PHPMD                Path to mess detector (PMD / PHPMD) XML file
--checkstyle=CHECKSTYLE      Path to checkstyle violations (PHP Code Sniffer) XML file
--cpd=CPD                    Path to C&P violations (PHP Copy Paste Detector) XML file
--phploc=PHPLOC              Path to PHPLoc result XML file

Feel free to provide examples using different build environments by creating a pull request.

Building & Developing The Software

The build system of the Quality Analyzer is based on ant. You must have ant >= 1.8 installed. To be able to use it you should first initilaize the submodule containing the build commons:

git submodule update --init

To develop the Quality Analyzer we heavily depend on a JavaScript build stack. For this you must have node and npm installed. All other required tools will be installed by the build tool. To set the project into development mode run:

echo env=dev > environment.local

As long as you do not remove this line from the environment.local file any more or change it to prod all development tools and libraries will be installed and used. This also means JavaScript and CSS will be compiled by commands like ant serve.

Running The Tests

You can run the tests by executing ant.

It will run run tests through Karma & Jasmine for parts of the JavaScript stack and PHPUnit tests for the PHP stack (once we have some).

Building CSS & JavaScript

The project uses ECMAScript 6 and transpiles it using Babel. Thus we need to update the bundle.js when working on the client. This is done when the project is prepared but can also be executed continuously using:

ant watch

This also compiles the SASS from the project and Bootstrap file into a single CSS file.

Trying Out The Project

If you want to try out the project you can serve the root directory with basically any webserver. The webserver should rewrite all requests to unknown resources to the index.html file which does the routing using JavaScript.

For your convenience we included a working server setup using PHPs internal webserver. You can start it using:

ant serve

Generating The Bundle Files

The following task ensures the bundle files are generated, compressed and comitted:

ant deploy

Use this command to update the distributed files.

It will run the package task first (after running all tests, of course). If there are changes in the assets/ folder those changes will be comitted and the current development state will then be pushed.

qafoo/quality-analyzer 适用场景与选型建议

qafoo/quality-analyzer 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 15.79k 次下载、GitHub Stars 达 492, 最近一次更新时间为 2015 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 qafoo/quality-analyzer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 qafoo/quality-analyzer 我们能提供哪些服务?
定制开发 / 二次开发

基于 qafoo/quality-analyzer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15.79k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 492
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 492
  • Watchers: 23
  • Forks: 30
  • 开发语言: JavaScript

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2015-10-27