jdlabails/php-project-analyzer-bundle

PhpProjectAnalyzer 的 Symfony Bundle

1.5.2 2018-04-15 13:01 UTC

README

提供分析结果的统一视图。

Build Status Total Downloads Latest Stable Version SensioLabsInsight

它提供了一个类似

功能

  • 汇总 php 分析指标
  • 提供用户友好的界面
  • 快速扫描您的项目
  • 英语或法语界面
  • 与代码覆盖率报告链接
  • 基于数量和质量指标评分
  • 启用 PhpUnit 或 Atoum 单元测试
  • 提供安全检查器

它执行

  • Php Mess Detector
  • Php Unit Tests
  • Atoum 测试
  • Php Code Sniffer ( + 通过 phpcbf 的修复工具)
  • 复制粘贴检测器
  • Php Depend
  • Php Loc

并将它们的报告解析以提供对您项目的快速分析视图。

安装

  • composer require jdlabails/php-project-analyzer-bundle --dev
  • 将 Bundle 添加到内核
/* app/AppKernel.php */
public function registerBundles()
    {
// ...
        $bundles[] = new JD\PhpProjectAnalyzerBundle\JDPhpProjectAnalyzerBundle();
// ...
}
  • 添加路由
# app/config/routing.yml
ppa:
    resource: '@JDPhpProjectAnalyzerBundle/Resources/config/routing.yml'
  • 添加安全异常
access_control:
    # PPA
    - { path: "^(/[a-z]{2})?/ppa(/[a-z]*)?", roles: IS_AUTHENTICATED_ANONYMOUSLY }
  • 设置您的配置
framework:
    translator: { fallback: %locale% }

jd_php_project_analyzer:
    title:          Php project analyzer
    description:    It's a ouaaaouhh project !

    gitRepositoryURL:      https://github.com/jdlabails/PhpProjectAnalyzerBundle

    # directory to analyze
    srcPath : /home/jd/Dev/ppa/src/JD

    # quantitative metric
    count : true

    # quality metric : copy-paste
    cpd : true

    # quality metric : code sniffer
    cs :
        enable: true
        standard: PSR2

    # security checker
    security: true

    # quality metric : phpdepend
    depend : true

    # quality metric : phploc
    loc : true

    # quality metric : mess detector
    md :
        enable: true
        rules:
            cleancode: true
            codesize: true
            controversial: true
            design: true
            naming: true
            unusedcode: true

    # generate phpdoc
    docs : true

    # testing
    test :
        enable: false
        lib : phpunit       # phpunit || atoum
        phpunitTestSuite : ppa
#        atoumPath : /home/smith/www/projectX/vendor/bin/atoum
#        atoumTestDir : /absolute/path/to/your/test/dir

    # score
    score:
        enable:         true
        csWeight:       100     # between 0 and 100, weighting of code sniffer
        testWeight:     100     # between 0 and 100, weighting of testing
        locWeight:      100     # between 0 and 100, weighting of code coverage
  • 设置资源
php app/console assets:install
  • 设置 web 目录中 ppa 目录的权限
sudo php app/console ppa:init
  • 在 .gitignore 中添加 web/ppa

使用

更新您的 phar

cd Resources/_phar
chmod +x  update.sh
./update.sh

可用命令

ppa:analyse:launch ==> 无 Web 界面启动分析 ppa:analyse:read ==> 无 Web 界面读取分析。结果为 json 格式

需要贡献

示例

  • 避免 symfony 依赖项中的 phar 文件
  • 重构代码
  • 单元测试
  • 每次扫描时下载安全检查器
  • behat

只需在 master 上提交 pull request

代码风格检查
bin/phpcs --standard=PSR2 --extensions=php Entities Manager Command Controller DependencyInjection Traits
单元测试
bin/simple-phpunit -c phpunit.xml
本地项目的提示

将以下内容放入您的 composer.json

  "minimum-stability": "dev",
  "prefer-stable": true,
  "repositories": [
    {
      "type": "path",
      "url": "/path/to/your/project/dir/jdlabails-php-project-analyzer-bundle/"
    }
  ],