codeclimate / codeclimate-phpcodesniffer

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

Analyze not working with custom sniffs #72

Open david-mkl opened 6 years ago

david-mkl commented 6 years ago

It seems that when custom sniffs are present, everything in the ruleset will be ignored, including the custom sniffs themselves, and phpcodesniffer will just report everything as having passed.

Codeclimate cli version: 0.71.1

My .codeclimate.yml file

version: "2"

plugins:
  phpcodesniffer:
    enabled: true
    config:
      file_extensions: "php"
      standard: "./standards/phpcs/ruleset.xml"

And ./standards/phpcs/ruleset.xml

<?xml version="1.0"?>
<ruleset name="MyStandard">
    <description>Coding Standard.</description>
    <rule ref="PSR2"/>
</ruleset>

I then make some purposeful mistakes in some code that violate PSR2, and run

codeclimate analyze

It will correctly report the issues according to PSR2.

Now, when I add some custom Sniffs, just the mere presence of them will cause everything to pass.

For example, a completely empty sniff

<?php

namespace PHP_CodeSniffer\Standards\MyStandard\Sniffs;

use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;

class MyCustomSniff implements Sniff
{
    public function register()
    {
        return [];
    }

    public function process(File $phpcsFile, $stackPtr)
    {
    }
}

Now when

codeclimate analyze

is run, everything will report as passed, and the PSR2 enforcements are completely ignored.

estahn commented 6 years ago

Any update on this? Is that working in the CodeClimate platform? We would like to use SlevomatCodingStandard.

maxjacobson commented 6 years ago

Hi there. No update on this. Apologies, we haven't had bandwidth to dig into it. It definitely sounds like a bug.

One bit of context: while plugins are running, they don't have network access, which means that extra dependencies aren't downloaded. For some other plugins, we've baked some popular dependencies into the engine, so they can be included. Do you think a similar approach would work here?

AJenbo commented 5 years ago

Any news on this, the standard is in the repo so no network access should be required.

MPParsley commented 4 years ago

This feature would make sense.