phpro / grumphp

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

local succeeded, github action failed - exclude ignored #890

Closed Un1matr1x closed 3 years ago

Un1matr1x commented 3 years ago
Q A
Version 1.3.1 local & @github actions
Bug? yes
New feature? no
Question? yes
Documentation? no

Since grumphp doesn't always finish all checks (stuck without response) on my local windows mashine I decided to run grumphp checks manual local and to get all the checks on any commit I added grumphp to my github actions. Due to the nature of my project (symfony based) I don't want to change/correct all errors found on the base-files, so I used to exclude some dirs and files. When I run the check localy I recieve an "all good!", on github actions violations are found, as you can see here with FILE: /home/runner/work/website/website/src/Kernel.php 14 | VIOLATION | Avoid assigning values to variables in if clauses and the like (line '22', column '27'). 27 | VIOLATION | Avoid assigning values to variables in if clauses and the like (line '34', column '27'). as you will see, this file should be excluded by config

My configuration the full file can be seen here the intressting part is

        phpmd:
            whitelist_patterns: []
            exclude:
                - src\Kernel.php
            report_format: ansi
            ruleset: ['cleancode', 'codesize', 'controversial', 'design', 'naming', 'unusedcode']
            triggered_by: ['php']

Steps to reproduce:

# local
 ./vendor/bin/grumphp run --tasks phpmd 

# github actions, see at the action :-)
  - name: "Run GrumPHP"
        run: "php vendor/bin/grumphp run --no-interaction"

Result:

Run php vendor/bin/grumphp run --no-interaction
GrumPHP is sniffing your code!

Running tasks with priority 0!
==============================
FILE: /home/runner/work/website/website/src/Kernel.php
------------------------------------------------------
 14 | VIOLATION | Avoid assigning values to variables in if clauses and the like (line '22', column '27').
 27 | VIOLATION | Avoid assigning values to variables in if clauses and the like (line '34', column '27').

Found 2 violations and 0 errors in 267ms
To skip commit checks, add -n or --no-verify flag to commit command

https://github.com/Wayfapper/website/runs/2432199461?check_suite_focus=true

Un1matr1x commented 3 years ago

I could solve this issue by reducing the exclude

exclude:
    - Kernel.php

I tried several other ideas like \ vs / but didn't had any success