ajgon/lint-pack

此包已被 弃用 并不再维护。没有建议的替代包。

为您的 Symfony2 项目提供各种代码检查器

安装: 1 164

依赖项: 0

建议者: 0

安全: 0

星星: 3

关注者: 1

分支: 1

开放问题: 0

类型:symfony-bundle

v1.2.1 2015-07-13 22:29 UTC

This package is not auto-updated.

Last update: 2020-08-21 18:13:50 UTC


README

Scrutinizer Quality Score Code Coverage Dependency Status Latest Stable Version Total Downloads License

Symfony AjgonLintPackBundle

安装

1. 使用 Composer (推荐)

要使用 Composer 安装 LintPackBundle,只需将以下内容添加到您的 composer.json 文件中

{
    // ...
    "require": {
        // ...
        "ajgon/lint-pack": "1.2.*@dev"
        // ...
    }
    // ...
}

然后,您可以从您的 composer.json 文件所在的目录运行 Composer 的更新命令来安装新的依赖项

$ php composer.phar update ajgon/lint-pack

现在,Composer 将自动下载所有必需的文件,并为您安装它们。接下来需要更新您的 AppKernel.php 文件,并注册新的包

<?php
// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Ajgon\LintPackBundle\LintPackBundle(),
    // ...
);

配置

此包在您的应用程序配置中的 lint_pack 键下配置。这包括与包中提供的每个代码检查器相关的设置。以下是一些带有描述的示例配置。

csslint

lint_pack:
    # Section for csslint options
    csslint:
        # Path to the csslint binary.
        # required: yes, default: "csslint"
        bin: "/somewhere/something/csslint"
        # List of csslint rules which will be ignored.
        # required: no, default: []
        disable_rules:
            - adjoining-classes
            - box-sizing
        ignores:
            - "ignore.css"
        # List of locations scanned for files.
        # required: no, default: ["%kernel.root_dir%", "%kernel.root_dir%/../src"]
        locations:
            - "%kernel.root_dir%/my-assets"

JSHint

lint_pack:
    # Section for jshint options
    jshint:
        # Path to the jshint binary.
        # required: yes, default: "jshint"
        bin: "/somewhere/something/jshint"
        # Path to the .jshintrc configuration file.
        # required: no, default: ""
        jshintrc: "/tmp/.jshintrc"
        # Path to jshintignore file, if set, disables "ignores" directive.
        # required: no, default: ""
        jshintignore: "/tmp/.jshintignore"
        # List of extensions which will be included for parsing.
        # required: no, default: ["js"]
        extensions:
            - js
            - javascript
        # List of regular expressions which will be tested against files found in locations.
        # Every file matching patterns will be ignored. Files are absolute paths.
        # required: no, default: []
        ignores:
            - "@r.js$@"
            - "@s[^/]+/jquery.js@"
        # List of locations scanned for files.
        # required: no, default: ["%kernel.root_dir%", "%kernel.root_dir%/../src"]
        locations:
            - "%kernel.root_dir%/my-assets"

phpcpd

lint_pack:
    phpcpd:
        # Path to the phpcs binary.
        # required: yes, default: "phpcs"
        bin: "vendor/bin/phpcpd"
        # Minimum number of identical lines.
        # required: no, default: 5
        min_lines: 4
        # Minimum number of identical tokens.
        # required: no, default: 70
        min_tokens: 60
        # List of extensions which will be included for parsing
        # required: no, default: ["php"]
        extensions:
            - php
            - php5
        # List of filespaths to ignore.
        # required: no, default: []
        ignores:
            - ignore.php
        # List of locations scanned for files.
        # required: no, default: ["%kernel.root_dir%/../src"]
        locations:
            - "%kernel.root_dir%/my-source"

phpcs

lint_pack:
    phpcs:
        # Path to the phpcs binary.
        # required: yes, default: "phpcs"
        bin: "vendor/bin/phpcs"
        # Display warnings?
        # required: no, default: false
        warnings: false
        # Enable recursion over directories?
        # required: no, default: true
        recursion: false
        # Coding standard against which files will be checked.
        # Can contain ruleset path.
        # required: false, default: PSR2
        standard: PEAR
        # List of extensions which will be included for parsing
        # required: no, default: ["php"]
        extensions:
            - php
            - php5
        # List of filespaths to ignore.
        # required: no, default: []
        ignores:
            - "ignore.php"
        # List of locations scanned for files.
        # required: no, default: ["%kernel.root_dir%/../src"]
        locations:
            - "%kernel.root_dir%/my-source"

phpmd

lint_pack:
    phpmd:
        # Path to the phpcs binary.
        # required: yes, default: "phpmd"
        bin: "vendor/bin/phpmd"
        # List of rulesets passed to the phpmd.
        # required: yes, default: ["codesize", "controversial", "design", "naming", "unusedcode"]
        rulesets:
            - naming
            - controversial
        # List of extensions which will be included for parsing
        # required: no, default: ["php"]
        extensions:
            - php
            - php5
        # List of filespaths to ignore.
        # required: no, default: []
        ignores:
            - "ignore.php"
        # List of locations scanned for files.
        # required: no, default: ["%kernel.root_dir%/../src"]
        locations:
            - "%kernel.root_dir%/my-source"

twig

lint_pack:
    twigviews:
        # List of regular expressions which will be tested against files found in locations.
        # Every file matching patterns will be ignored. Files are absolute paths.
        # required: no, default: []
        ignores:
            - "@ignore.twig@"
        # List of locations scanned for files.
        # required: no, default: ["%kernel.root_dir%", "%kernel.root_dir%/../src"]
        locations:
            - "%kernel.root_dir%/my-assets"

用法

此扩展将在 app/console 任务列表中添加一个新的 lint

$ php app/console
...
lint
  lint:all                              Lint all files with all linters
  lint:csslint                          Lint all files with csslint
  lint:jshint                           Lint all files with jshint
  lint:phpcpd                           Lint all files with phpcpd
  lint:phpcs                            Lint all files with phpcs
  lint:phpmd                            Lint all files with phpmd
  lint:twigviews                        Lint all files with twig linters

要使用特定的代码检查器,只需运行它,例如 php app/console lint:jshint

测试

php vendor/bin/phpcs --standard=PSR2 --extensions=php src/ test/Ajgon -p
php vendor/bin/phpmd --suffixes php src,test/Ajgon text codesize,controversial,design,unusedcode,naming
php vendor/bin/phpcpd src test
php vendor/bin/phpunit --coverage-text

贡献

有关详细信息,请参阅 CONTRIBUTING

致谢

许可

此包在 MIT 许可证 下发布。