ajgon/lint-pack

This package is abandoned and no longer maintained. No replacement package was suggested.

Various linters for your Symfony2 project

Installs: 1 165

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 1

Open Issues: 0

Type: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

Installation

1. Using Composer (recommended)

To install LintPackBundle with Composer just add the following to your composer.json file:

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

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:

$ php composer.phar update ajgon/lint-pack

Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your AppKernel.php file, and register the new bundle:

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

Configuration

This bundle configured under the lint_pack key in your application configuration. This includes settings related every linter available in package. Below are example configurations with descriptions.

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"

Usage

This extension will add a new group lint to app/console task list:

$ 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

To use specific linter, just launch it, e.g. php app/console lint:jshint.

Testing

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

Please see CONTRIBUTING for details.

Credits

License

This bundle is released under the MIT license.