phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

Pre-commit hook not listening to config options - and does not run all tasks. #798

Closed NickBelhomme closed 4 years ago

NickBelhomme commented 4 years ago
Q A
Version 0.20.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets none - found

When executing grumphp run it takes into account the config option:

grumphp:
    parallel:
      enabled: false
      max_workers: 19

But on pre-commit it just runs it in parallel. And it looks like it does not run all tasks.

My configuration

grumphp:
    process_timeout: 240
    parallel:
      enabled: false
      max_workers: 19
    stop_on_failure: false
    tasks:
      rector:
        ignore_patterns:
          - database
      check_whitespace: ~
      composer: ~
      git_commit_message:
        enforce_capitalized_subject: false
        max_subject_width: 72
        max_body_width: 250
        matchers:
          - /^(bugfix|feature|refactor|cleanup|typo|other|test|doc|release|sync|staging) - /
      git_blacklist:
        keywords:
          - 'console.log('
          - '::whereHas'
          - '->whereHas'
          - '->dump'
        triggered_by: ['js', 'php']
        whitelist_patterns:
          - /^app\/(.*)/
          - /^cfa\/(.*)/
          - /^tests\/(.*)/
          - /^resources\/assets\/js\/(.*)/
      jsonlint:
        ignore_patterns:
          - 'storage/app/seeds/'
          - 'database/migrations/dumps/'
        detect_key_conflicts: true
      phpcpd:
        exclude:
          - database/migrations
          - vendor
          - config
          - bootstrap/cache
          - storage/framework/views
          - other
          - resources/lang
          - cfa/Planner/Domain/CollectionV2
          - node_modules
          - tests/Unit
        min_lines: 5
        min_tokens: 70
        triggered_by: ['php']
      phpcs_cfa:
        standard: 'grump-config/phpcs.xml'
        whitelist_patterns:
          - /^cfa\/(.*)/
        metadata:
          task: phpcs
      phpcs_app_other:
        standard: 'grump-config/phpcs.xml'
        whitelist_patterns:
          - /^app\/(.*)/
          - /^database\/(.*)/
          - /^nova-components\/(.*)/
          - /^routes\/(.*)/
          - /^storage\/(.*)/
        ignore_patterns:
          - database/migrations
          - database/seeds
        metadata:
          task: phpcs
      phpcs_tests:
        standard: 'grump-config/phpcs_tests.xml'
        whitelist_patterns:
          - /^tests\/(.*)/
        metadata:
          task: phpcs
      phpcsfixer2:
        allow_risky: true
        config: 'grump-config/.php_cs'
        verbose: true
      phplint:
        exclude:
          - other
          - vendor
      phpmd:
        whitelist_patterns:
          - /^app\/(.*)/
          - /^cfa\/(.*)/
          - /^nova-components\/(.*)/
          - /^routes\/(.*)/
          - /^storage\/(.*)/
        ruleset: ['grump-config/ruleset.xml']
      phpparser:
        ignore_patterns:
          - other
          - vendor
        triggered_by: ['php']
        visitors:
          forbidden_function_calls:
            blacklist:
              - 'var_dump'
              - 'dd'
              - 'die'
              - 'dump'
          no_exit_statements: ~
      phpstan_cfa_care_eval:
        configuration: 'grump-config/phpstan.neon'
        level: null
        triggered_by: ['php']
        force_patterns:
          - /^cfa\/Care.*.php/
          - /^cfa\/Evaluation.*.php/
        ignore_patterns:
          - /.*/
        memory_limit: '2G'
        metadata:
          task: phpstan
      phpstan_cfa_other:
        configuration: 'grump-config/phpstan.neon'
        level: null
        triggered_by: ['php']
        force_patterns:
          - /^cfa\/Admin.*.php/
          - /^cfa\/Common.*.php/
          - /^cfa\/License.*.php/
          - /^cfa\/Planner.*.php/
        ignore_patterns:
          - /.*/
        memory_limit: '2G'
        metadata:
          task: phpstan
      phpstan_other:
        configuration: 'grump-config/phpstan.neon'
        level: null
        triggered_by: ['php']
        force_patterns:
          - /^app.*.php/
          - /^config.*.php/
          - /^database.*.php/
          - /^nova-components.*.php/
          - /^resources.*.php/
          - /^routes.*.php/
        ignore_patterns:
          - /.*/
        memory_limit: '2G'
        metadata:
          task: phpstan
      securitychecker: ~
      xmllint: ~
      yamllint: ~
      phpmnd:
        exclude:
          - storage
    testsuites:
      ci:
        tasks:
          - rector
          - check_whitespace
          - composer
          - jsonlint
          - phpcpd
          - phpcs_cfa
          - phpcs_app_other
          - phpcs_tests
          - phpcsfixer2
          - phplint
          - phpmd
          - phpparser
          - phpstan_cfa_care_eval
          - securitychecker
          - xmllint
          - yamllint
          - phpmnd
services:
    Other\GrumPHP\Task\CheckWhitespace:
      arguments:
        - '@process_builder'
        - '@formatter.raw_process'
      tags:
        - {name: grumphp.task, task: check_whitespace}
    Other\GrumPHP\Task\Rector:
      arguments:
        - '@process_builder'
        - '@formatter.raw_process'
      tags:
        - {name: grumphp.task, task: rector}

# Your actions
git commit. <= ignored parallel flag.
(bij een *grumphp run* word alles wel mooi in sequentieel uitgevoerd)

# Run GrumPHP
/vendor/bin/grumphp git:init
daarna een commit.

Result:

2020-08-13_08-52

expected

runs sequentially and all tasks.

NickBelhomme commented 4 years ago

ok hij runt sequentieel en enkel de relevante tasks. closing Dit was verwarrend tov van de vroegere output die we kregen, waarbij elke task afgetikt werd. Het jumpen lijkt alsof het parallel was en zonder alle taken te runnen, die voorheen wel afgehandeld werden.