Skip to content

Analyze not working with custom sniffs #72

Open
@david-mkl

Description

@david-mkl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions