I'm just starting to setup a pipeline that checks my code against an existing standard that is local to the project in it's own phpcs.xml.dist file. When I run phpcs locally, I get the following output:
```
-----------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------
9 | WARNING | Possible parse error: class missing opening or closing brace
9 | WARNING | Possible parse error: class missing opening or closing brace
9 | WARNING | Possible parse error: class missing opening or closing brace
11 | WARNING | Consider putting global function "__construct" in a static class
16 | WARNING | Consider putting global function "findNext" in a static class
31 | WARNING | Consider putting global function "markAsProcessing" in a static class
-----------------------------------------------------------------------------------------
```
My pipeline file looks like this:
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- composer install --prefer-source --no-interaction --dev
- vendor/bin/phpcs src/
The call to phpcs is identical to how I call it locally. But the results are very different:
```
----------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 7 LINES
----------------------------------------------------------------------
11 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 0
14 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 0
16 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 0
29 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 0
31 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 0
32 | ERROR | [x] Opening brace indented incorrectly; expected 0
| | spaces, found 4
32 | ERROR | [x] Opening brace indented incorrectly; expected 0
| | spaces, found 4
48 | ERROR | [x] Closing brace indented incorrectly; expected 0
| | spaces, found 4
48 | ERROR | [x] Closing brace indented incorrectly; expected 0
| | spaces, found 4
----------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
```
Any help would be greatly appreciated.
Hello @thomas.belknap,
Thanks for reaching out and welcome to the Community!
I'm not familiar with phpcs, so these are only guesses:
Greatly simplified, a pipeline in Bitbucket runs your script inside a Docker container (which you specify in your YML, or in the default container), so in fact you can debug it locally by following this guide. Once you get your build Docker container up and running, you can execute the commands you have in your script and investigate the results.
Hope this helps. Let me know if you have any questions.
Cheers,
Daniil
Daniil,
Thanks so much for the reply back! For background to some of your questions: PHP CS is PHP Code Sniffer and is a code format checking app. I'm running it against my repo to ensure that all commits match our guidelines. PHP CS will detect the existence of a phpcs.xml.dist file and automatically pick it up and use it for configuration. Yes, the file is under version control.
It's a bit of a mystery as to why this happens. But I'm beginning to suspect perhaps the config file itself may be suspect: it may be that conflicting directives are being interpreted differently by the two sides. Still really not sure.
Thanks so much for the debugging info! Glad to not have to clog up my repo with testing branches. Please let me know if you think of any other advice!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.