├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── grumphp.yml ├── phpstan.neon └── ruleset.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = space 7 | indent_size = 4 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.yml] 12 | indent_style = space 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | composer.lock 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Lasse Lehtinen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Goal 3 | 4 | Configuration for [grumphp](https://github.com/phpro/grumphp) that is checking on each commit that the committed code passes the unit tests, complies with the PSR2 coding style and static analysis check. It runs the following checks: 5 | 6 | - Check that composer.json is valid 7 | - Check that composer does not have any dependencies for known security vulnerabilities with [Local PHP Security Checker](https://github.com/fabpot/local-php-security-checker) 8 | - Check that the PHP syntax is valid 9 | - Check that commit does not contain any debugging (var_dump, die, exit) 10 | - Check that code complies with the PSR2 coding style 11 | - Perform static code analysis using [phpstan](https://github.com/phpstan/phpstan) 12 | - Check code for unnecessary complexity etc. with [PHP Mess Detector](https://github.com/phpmd/phpmd) 13 | - Check that unit tests pass with PHPUnit 14 | 15 | ## Installation 16 | 17 | ### 1. Add checker to your `composer.json`: 18 | 19 | ``` 20 | composer require --dev lasselehtinen/laravel-conventions-checker 21 | ``` 22 | 23 | ### 2. Download Local PHP Security Checker 24 | 25 | Download a binary from the [Releases page on Github](https://github.com/fabpot/local-php-security-checker/releases), rename it to `local-php-security-checker` and make it executable. 26 | 27 | ### 3. Add path to grumphp configuration file to your `composer.json`'s extra: 28 | 29 | ``` 30 | "extra": { 31 | "grumphp": { 32 | "config-default-path": "vendor/lasselehtinen/laravel-conventions-checker/grumphp.yml" 33 | } 34 | } 35 | ``` 36 | ## Test suites 37 | If you want to run the coding syntax, style or static analysis checks only, you can run the following commands: 38 | ``` 39 | vendor/bin/grumphp run --testsuite=syntax 40 | vendor/bin/grumphp run --testsuite=style 41 | vendor/bin/grumphp run --testsuite=static 42 | ``` 43 | 44 | ## License 45 | 46 | The MIT License (MIT). Please see [License File](LICENSE) for more information. 47 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"lasselehtinen/laravel-conventions-checker", 3 | "description":"grumphp config to automatically check conventions for Laravel projects", 4 | "license":"MIT", 5 | "authors":[ 6 | { 7 | "name":"Lasse Lehtinen", 8 | "email":"lasse.lehtinen@iki.fi" 9 | } 10 | ], 11 | "require":{ 12 | "phpro/grumphp":"^2.3", 13 | "phpmd/phpmd":"^2.10", 14 | "squizlabs/php_codesniffer":"^3.7", 15 | "larastan/larastan":"^3.0", 16 | "php-parallel-lint/php-parallel-lint":"^1.4" 17 | }, 18 | "minimum-stability": "dev", 19 | "prefer-stable": true, 20 | "config": { 21 | "allow-plugins": { 22 | "phpro/grumphp": false 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /grumphp.yml: -------------------------------------------------------------------------------- 1 | grumphp: 2 | ascii: 3 | failed: null 4 | succeeded: null 5 | process_timeout: 600 6 | testsuites: 7 | security: 8 | tasks: 9 | - securitychecker_composeraudit 10 | style: 11 | tasks: 12 | - phpmd 13 | syntax: 14 | tasks: 15 | - composer 16 | - git_blacklist 17 | - phplint 18 | static: 19 | tasks: 20 | - phpstan 21 | tasks: 22 | composer: 23 | metadata: {priority: 800} 24 | securitychecker_composeraudit: 25 | metadata: {priority: 700} 26 | git_blacklist: 27 | keywords: [die(, var_dump(, exit;] 28 | metadata: {priority: 600} 29 | phpcs: 30 | standard: PSR2 31 | whitelist_patterns: ['/^app(.*)/', '/^config(.*)/', '/^recources(.*)/', , '/^test(.*)/'] 32 | metadata: {priority: 500} 33 | exclude: ['Generic.Files.LineLength'] 34 | phplint: 35 | metadata: {priority: 400} 36 | triggered_by: ['php'] 37 | phpstan: 38 | ignore_patterns: ['/^tests(.*)/', '/^database(.*)/', '/^config(.*)/', '/^routes(.*)/', '/deploy.php/', '/^nova(.*)/',] 39 | configuration: vendor/lasselehtinen/laravel-conventions-checker/phpstan.neon 40 | level: 5 41 | metadata: {priority: 300} 42 | phpmd: 43 | whitelist_patterns: ['/^app(.*)/', '/^config(.*)/', '/^recources(.*)/'] 44 | ruleset: ['vendor/lasselehtinen/laravel-conventions-checker/ruleset.xml'] 45 | metadata: {priority: 200} 46 | phpunit: 47 | metadata: {priority: 100} 48 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | includes: 2 | - ../../larastan/larastan/extension.neon -------------------------------------------------------------------------------- /ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | PHPMD rule set for lasselehtinen/laravel-conventions-checker 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | --------------------------------------------------------------------------------