wunderio / code-quality

List of tools that aims to help with static code quality inspection.
GNU General Public License v3.0
2 stars 5 forks source link

Integrate vscode and PhpStorm #108

Open hkirsman opened 3 months ago

hkirsman commented 3 months ago

How to integrate code checks into Visual Studio Code and PhpStorm?

hkirsman commented 3 months ago

I initially tested with this script that we would have put under vendor/bin/:

#!/bin/bash

# Run PHP_CodeSniffer inside Docker container using the PHP 8.2 CLI image.
# The container will automatically be removed after execution (--rm).
# Mount the current working directory ($(pwd)) to the /app directory inside
# the container (-v $(pwd):/app).
# Set the working directory inside the container to /app (-w /app).
# Execute the PHP CodeSniffer command (./vendor/bin/phpcs) with the WunderAll
# standard inside the container.
# Pass any additional arguments ($*) from the script to the phpcs command.

docker run -i --rm -v $(pwd):/app -w /app php:8.2-cli ./vendor/bin/phpcs --standard=WunderAll $*

Then we can point to the script from IDE eg: image

Result in the vscode: image (132)

Plugin used: https://marketplace.visualstudio.com/items?itemName=shevaua.phpcs

But why spin up yet another container, we already have Lando or DDEV running? Maybe only because we would create scanner images that we could use anywhere?

Another solution that would re-use Lando or DDEV would be to expose the phpcs (and other tools) eg lando phpcsor ddev phpcs.