-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Uncaught InvalidArgumentException: The $sniffClass parameter was not passed a fully qualified sniff(test) class name. Received: CompanyNameStandard\Sniffs\JsonSniff
#675
Comments
@williamdes Thank you for reporting this. I kind of was afraid something might break with the change from #524.
The short answer is that the sniffs do not comply with the directory structure and naming conventions which sniffs must follow, as outlined in: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial The sniffs are missing the You can also see this if you run the sniffs over code which triggers an error (I've just hacked it a little to show this, but do test this yourself with PHPCS 3.10.3). While the current sniffs may "work", certain standard PHPCS features will not work intuitively with a setup like this, and may not work at all. I'm talking about features like:
Fixing the sniffs to follow the required naming conventions will fix the exception and make the sniffs compatible with the above mentioned PHPCS features too. Having said that, I agree that if the change made in #524 breaks such unconventional setups, this change needs to be (partially) reverted. I've now opened PR #676 to fix this. Testing would be much appreciated. As a side-note (unrelated to the current issue): you may want to clean up the ruleset header as it references an XSD schema of a completely unrelated project.... (PHP Mess Detector) You should change it to: <ruleset name="Company"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd"> |
Thank you @jrfnl !
Indeed, good catch.
Since another project tested it and I did review it the changes look okay.
True, this is a breaking change I applied this patch and it all works fine now: diff --git a/CompanyStandard/Sniffs/JsonSniff.php b/CompanyStandard/Sniffs/Schemas/CheckJsonIsSafeSniff.php
similarity index 99%
rename from CompanyStandard/Sniffs/JsonSniff.php
rename to CompanyStandard/Sniffs/Schemas/CheckJsonIsSafeSniff.php
index a6b0f0872..013818cdf 100644
--- a/CompanyStandard/Sniffs/JsonSniff.php
+++ b/CompanyStandard/Sniffs/Schemas/CheckJsonIsSafeSniff.php
@@ -1,6 +1,6 @@
<?php
-namespace CompanyStandard\Sniffs;
+namespace CompanyStandard\Sniffs\Schemas;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;
diff --git a/CompanyStandard/Sniffs/TranslationSniff.php b/CompanyStandard/Sniffs/Translations/DisallowUnusedTranslationSniff.php
similarity index 98%
rename from CompanyStandard/Sniffs/TranslationSniff.php
rename to CompanyStandard/Sniffs/Translations/DisallowUnusedTranslationSniff.php
index c4b76f1f9..93fbc3a99 100644
--- a/CompanyStandard/Sniffs/TranslationSniff.php
+++ b/CompanyStandard/Sniffs/Translations/DisallowUnusedTranslationSniff.php
@@ -1,6 +1,6 @@
<?php
-namespace CompanyStandard\Sniffs;
+namespace CompanyStandard\Sniffs\Translations;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;
diff --git a/phpcs.xml b/phpcs.xml
index e9de574d7..cc1654a85 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<ruleset name="Company"
- xmlns="http://pmd.sf.net/ruleset/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
- xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+<ruleset name="Company">
<!-- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<description>Company PHP_CodeSniffer custom coding standard</description>
@@ -27,8 +23,8 @@
<config name="installed_paths" value="vendor/slevomat/coding-standard"/>
- <rule ref="./CompanyStandard/Sniffs/JsonSniff.php" />
- <rule ref="./CompanyStandard/Sniffs/TranslationSniff.php" />
+ <rule ref="./CompanyStandard/Sniffs/Schemas/CheckJsonIsSafeSniff.php" />
+ <rule ref="./CompanyStandard/Sniffs/Translations/DisallowUnusedTranslationSniff.php" />
|
Describe the bug
After #524 I get the following error:
The rules are added to a normal phpcs ruleset
I can not figure out how to fix the current situation
Code sample
Custom ruleset
To reproduce
Use the ruleset and add the file at the rule location
Expected behavior
Work fine like in the previous version
Versions (please complete the following information)
Additional context
Please confirm
master
branch of PHP_CodeSniffer.The text was updated successfully, but these errors were encountered: