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

Analyze not working with custom sniffs #72

Open
david-mk-lawrence opened this issue Mar 22, 2018 · 4 comments
Open

Analyze not working with custom sniffs #72

david-mk-lawrence opened this issue Mar 22, 2018 · 4 comments

Comments

@david-mk-lawrence
Copy link

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
Copy link

estahn commented Jun 28, 2018

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

@maxjacobson
Copy link
Contributor

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
Copy link

AJenbo commented Mar 15, 2019

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

@MPParsley
Copy link

This feature would make sense.

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

6 participants