2017 © Pedro Peláez
 

symfony-bundle lint-pack

Various linters for your Symfony2 project

image

ajgon/lint-pack

Various linters for your Symfony2 project

  • Tuesday, July 14, 2015
  • by ajgon
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,116 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 1 % Grown

The README.md

Scrutinizer Quality Score Code Coverage Dependency Status Latest Stable Version Total Downloads License, (*1)

Symfony AjgonLintPackBundle

Installation

To install LintPackBundle with Composer just add the following to your composer.json file:, (*2)

{
    // ...
    "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:, (*3)

$ 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:, (*4)

<?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., (*5)

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:, (*6)

$ 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., (*7)

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., (*8)

Credits

License

This bundle is released under the [MIT license][5]., (*9)

The Versions

14/07 2015
03/03 2014
28/01 2014