codeclimate / codeclimate-phpcodesniffer

Code Climate Engine for PHP Code Sniffer
MIT License
28 stars 23 forks source link

php7-xmlreader required for WordPress Coding Standards beta container image #94

Open lucyllewy opened 2 years ago

lucyllewy commented 2 years ago

I've tried using the beta docker image of codeclimate-phpcodesniffer to get access to a more recent phpcs build than is in stable. (I need access to disabling specific sniffs on a single line as documented at https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file. The inline // phpcs:ignore form is only available in phpcs since version 3.2.0, where the stable docker image by codeclimate is still on 2.9.1.

When I run the beta docker image I am greeted with the following log showing that the container is missing the php7-xmlreader package from the Alpine repository.

Log of execution ```plain $ docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -e phpcodesniffer Starting analysis Running phpcodesniffer: Done! error: (CC::CLI::Analyze::EngineFailure) engine phpcodesniffer failed with status 1 and stderr Unable to find image 'codeclimate/codeclimate-phpcodesniffer:beta' locally beta: Pulling from codeclimate/codeclimate-phpcodesniffer 5758d4e389a3: Already exists 4ae1f45a9f69: Pulling fs layer 0676d8c6ca5f: Pulling fs layer 5dd9411e7f0f: Pulling fs layer c0105a21377e: Pulling fs layer 7072198dee72: Pulling fs layer 119f7d69fd65: Pulling fs layer f4466a97c155: Pulling fs layer b5fd0274c371: Pulling fs layer c0105a21377e: Waiting 7072198dee72: Waiting 119f7d69fd65: Waiting f4466a97c155: Waiting b5fd0274c371: Waiting 0676d8c6ca5f: Download complete 4ae1f45a9f69: Verifying Checksum 4ae1f45a9f69: Download complete 4ae1f45a9f69: Pull complete 0676d8c6ca5f: Pull complete 5dd9411e7f0f: Verifying Checksum 5dd9411e7f0f: Download complete 5dd9411e7f0f: Pull complete 7072198dee72: Download complete c0105a21377e: Download complete c0105a21377e: Pull complete 7072198dee72: Pull complete f4466a97c155: Verifying Checksum f4466a97c155: Download complete b5fd0274c371: Verifying Checksum b5fd0274c371: Download complete 119f7d69fd65: Verifying Checksum 119f7d69fd65: Download complete 119f7d69fd65: Pull complete f4466a97c155: Pull complete b5fd0274c371: Pull complete Digest: sha256:670d7b4e245222e6735ccc29b7548baffd053dd9f267fbb0f0448af08d46feae Status: Downloaded newer image for codeclimate/codeclimate-phpcodesniffer:beta Exception: Class 'XMLReader' not found in /usr/src/app/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php #0 /usr/src/app/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php(464): WordPressCS\WordPress\Sniffs\WP\I18nSniff->check_text() #1 /usr/src/app/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php(390): WordPressCS\WordPress\Sniffs\WP\I18nSniff->check_argument_tokens() #2 /usr/src/app/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php(288): WordPressCS\WordPress\Sniffs\WP\I18nSniff->process_matched_token() #3 /usr/src/app/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php(200): WordPressCS\WordPress\AbstractFunctionRestrictionsSniff->check_for_matches() #4 /usr/src/app/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php(213): WordPressCS\WordPress\AbstractFunctionRestrictionsSniff->process_token() #5 /usr/src/app/vendor/wp-coding-standards/wpcs/WordPress/Sniff.php(910): WordPressCS\WordPress\Sniffs\WP\I18nSniff->process_token() #6 /usr/src/app/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): WordPressCS\WordPress\Sniff->process() #7 /usr/src/app/vendor/squizlabs/php_codesniffer/src/Runner.php(631): PHP_CodeSniffer\Files\File->process() #8 /usr/src/app/Executor.php(124): PHP_CodeSniffer\Runner->processFile() #9 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1934): Executor->run() #10 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1846): fork_daemon->invoke_callback() #11 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1747): fork_daemon->fork_work_unit() #12 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1499): fork_daemon->process_work_unit() #13 /usr/src/app/Executor.php(33): fork_daemon->process_work() #14 /usr/src/app/engine.php(26): Executor->queueDirectory() #15 {main} ```
My `.codeclimate` file ```yaml plugins: editorconfig: enabled: true fixme: enabled: true git-legal: enabled: true phpcodesniffer: enabled: true channel: beta config: standard: phpcs.xml.dist scss-lint: enabled: true ```
My `.phpcs.dist.xml` file ```xml Generally-applicable sniffs for WordPress plugins . /build/ */node_modules/* /tests/ */vendor/* /wp-includes scoper.inc.php ```