Code Monkey home page Code Monkey logo

Comments (7)

Bittarman avatar Bittarman commented on May 28, 2024 2

I have also experienced this same issue.
This config file also does not work

<?xml version="1.0"?>
<ruleset name="Coding Standards">
<description>coding standards</description>
<file>./src</file>
<rule ref="PSR2"/>
<rule ref="PSR12"/>
<rule ref="ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff">
    <properties>
        <property name="maxNestingLevel" value="2" />
    </properties>
</rule>
</ruleset>

and produces ERROR: Referenced sniff "ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff" does not exist

from phpcs-calisthenics-rules.

amandiobm avatar amandiobm commented on May 28, 2024 1

@Bittarman, I still don't know how to fix that issue. So I changed to symplify/easy-coding-standard, the configuration file is simple as they say and it works in conjunction with this package.

Let me know if that also worked for you.

from phpcs-calisthenics-rules.

amandiobm avatar amandiobm commented on May 28, 2024 1

Guys, let me know if I can close this one.

from phpcs-calisthenics-rules.

Bittarman avatar Bittarman commented on May 28, 2024 1

@amandiobm This can be resolved with different configuration.
I will submit a PR for updated docs shortly

from phpcs-calisthenics-rules.

TomasVotruba avatar TomasVotruba commented on May 28, 2024

Hi,

have you tried using class instead?

ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff

It's less magical and more clear than string naming

from phpcs-calisthenics-rules.

KEINOS avatar KEINOS commented on May 28, 2024

I am facing the same issue with ObjectCalisthenics.Files.FunctionLength too.

<?xml version="1.0"?>
<ruleset name="Coding Standards">
    <description>coding standards</description>
    <file>./src</file>
    <rule ref="PSR2"/>
    <rule ref="PSR12"/>
    <rule ref="ObjectCalisthenics.Files.FunctionLength">
        <properties>
            <property name="maxLength" value="20"/>
        </properties>
    </rule>
</ruleset>
bash-5.0# ./vendor/bin/phpcs -v
Registering sniffs in the Coding Standards standard... ERROR: Referenced sniff "ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff" does not exist

Run "phpcs --help" for usage information
How to reproduce
# Dockerfile
FROM composer:latest
COPY . /app
WORKDIR /app
RUN composer install
ENTRYPOINT [ "/app/vendor/bin/phpcs", "-v" ]
<?php
// ./src/sample.php
declare(strict_types=1);

namespace MyVendor\MyPackage;

class MyClass
{
    /**
     * General-purpose dummy function.
     *
     * @param string $data
     *
     * @return string Returns the same value of the given parameter.
     */
    public function parrotry(string $data): string
    {
        return $data;
    }
}
{
    "require-dev": {
        "squizlabs/php_codesniffer": "^3.5",
        "object-calisthenics/phpcs-calisthenics-rules": "^3.7"
    }
}
$ ls
Dockerfile	composer.json	phpcs.xml	src

$ docker build -t sample:local .
...
$ docker run --rm sample:local
Registering sniffs in the Coding Standards standard... ERROR: Referenced sniff "ObjectCalisthenics.Files.FunctionLength" does not exist

Run "phpcs --help" for usage information

$ # Envs
$ docker run --rm --entrypoint composer sample:local --version
Composer version 1.10.6 2020-05-06 10:28:10

$ docker run --rm --entrypoint composer sample:local show
nette/utils                                  v3.1.2 🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
object-calisthenics/phpcs-calisthenics-rules v3.7.0 PHP CodeSniffer Object Calisthenics rules/sniffs
phpstan/phpdoc-parser                        0.4.4  PHPDoc parser with support for nullable, intersection and generic types
slevomat/coding-standard                     6.3.8  Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.
squizlabs/php_codesniffer                    3.5.5  PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.

from phpcs-calisthenics-rules.

TomasVotruba avatar TomasVotruba commented on May 28, 2024

Closing as repository is deprecated. We migrated to PHPStan rules.

See https://tomasvotruba.com/blog/2020/09/07/introducing-object-calisthenics-rules-for-phpstan/

from phpcs-calisthenics-rules.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.