Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New GitHub Action: phpcs #748

Open
shirobrak opened this issue Aug 30, 2020 · 2 comments
Open

New GitHub Action: phpcs #748

shirobrak opened this issue Aug 30, 2020 · 2 comments

Comments

@shirobrak
Copy link

shirobrak commented Aug 30, 2020

Hello !

Thank you for the awesome project!

Based on the GitHub Actions example in the reviewdog org, I created a new action for running phpcs.
If that’s all right with you, could I move my repository to reviewdog org.

@haya14busa
Copy link
Member

I'm sry for the late reply. I sent an invitation to the org. Please feel free to move the repo to the org.

@fabianmarz
Copy link

fabianmarz commented Oct 3, 2021

@shirobrak, thanks for your work on this project/action! I was trying to setup code suggestions for PHPCS and the following is the only way I got them working:

php ./vendor/bin/phpcs --report=diff -- $(git diff --name-only --diff-filter=ACMR origin/master | grep \\.php | xargs) | sed -r 's/[[:cntrl:]]\[[0-9]{1,3}m//g' | sed -E 's/--- (. )$/\0\n \1/g; /\ \ \ PHP_CodeSniffer$/d' | reviewdog -f=diff -f.diff.strip=0 -name=phpcs -reporter=github-pr-review -filter-mode=nofilter -fail-on-error

The first sed command removes some special characters which seem to be added when getting a diff report. The second one replaces the PHP_CodeSniffer filename with the actual file name so reviewdog is able to pick it up and add the suggestions to the right line/file.

Did you also have a look into how this can be done? Maybe there's a simpler way to achieve it? 🤔 This only reports the diff without the actual code violation. I assume for this an rdjson converter has to be written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants