phpro / grumphp

A PHP code-quality tool
MIT License
4.14k stars 430 forks source link

core.commentChar Explicit Configuration Required #816

Closed timnolte closed 4 years ago

timnolte commented 4 years ago
Q A
Version 0.21.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets #729, #813

Since the changes made with PR https://github.com/phpro/grumphp/pull/808 GrumPHP now expects that core.commentChar is explicitly set. Previously GrumPHP always assumed #. This change should have been made to respect core.commentChar if it was set otherwise fallback to the previous behavior. I'm having to help contributors fix there local Git configuration since this setting is rarely set.

My configuration

# grumphp.yml
grumphp:
  hide_circumvention_tip: true
  stop_on_failure: true
  process_timeout: 120
  parallel:
    enabled: true
    max_workers: 32
  fixer:
    enabled: false
    fix_by_default: false
  environment:
    variables:
      GRUMPHP_BIN_DIR: 'vendor/bin'
    paths:
      - 'node_modules/.bin'
  tasks:
    git_blacklist:
      keywords:
        - 'wp_die('
        - 'die('
    git_branch_name:
      blacklist:
        - 'main'
        - 'master'
        - 'dev*'
      allow_detached_head: false
    git_commit_message:
      allow_empty_message: false
      enforce_capitalized_subject: true
      enforce_no_subject_punctuations: true
      enforce_no_subject_trailing_period: true
    npm_script:
      script: 'i18n:check'
      is_run_task: true
      triggered_by: [php]
      metadata:
        label: 'i18n Check'
    phpcs:
      standard: './phpcs.xml.dist'
      report: 'full'
      ignore_patterns:
        - '/^assets\/(.*)/'
      triggered_by: [php]
    phpstan:
      configuration: './phpstan.neon.dist'
      level: 5
      ignore_patterns:
        - '/^assets\/(.*)/'
      memory_limit: '-1'
      triggered_by: [php]
    securitychecker: ~

Steps to reproduce:

# Generate empty folder
mkdir tmp
cd tmp
git init
echo "vendor" > .gitignore
pbpaste > grumphp.yml
composer require --dev phpro/grumphp

# Your actions
touch test.php
echo "<?php" >> test.php
echo "phpinfo();" >> test.php

# Run GrumPHP:
git add -A && git commit -m"Test"
# or
./vendor/bin/grumphp run

Result:

Error while running git command:
'git' '--git-dir' '/Users/daggerhart/sites/wp/plugins/openid-connect-generic/.git' '--work-tree' '/Users/daggerhart/sites/wp/plugins/openid-connect-generic' 'config' '--get' 'core.commentChar'
veewee commented 4 years ago

Thanks for reporting!

This has been fixed in https://github.com/phpro/grumphp/pull/814 Please upgrade to v0.22.0