joonty / vim-phpqa

PHP QA tools for Vim
http://www.joncairns.com
MIT License
290 stars 32 forks source link

Cannot find specified ruleset #6

Closed jdewit closed 11 years ago

jdewit commented 11 years ago

Thanks for this plugin!

I'm getting the error

"M Cannot find specified rule-set "Gene". (PHPMD)"

Any ideas on how to resolve this? I can't find anything and am at a loss.

Let me know if you need any info.

joonty commented 11 years ago

Hi @jdewit, glad you like the plugin!

Do you have anything set in your g:phpqa_messdetector_ruleset global variable? This is either the name of an existing rule set or a path to an XML file with the rule set defined. It seems that PHP mess detector is trying to use a non existent rule set called "Gene", which is strange.

When you get the error again, run:

:echo g:phpqa_messdetector_ruleset

And see what gets spit out. Paste it here if you're unsure. If it isn't obvious we'll go into some more detailed debugging.

Thanks

jdewit commented 11 years ago

Thanks for the reply joonty.

I had dowloaded a ruleset for Symfony2 so I thought that may have been the problem.

in my gvimrc.local let g:phpqa_messdetector_ruleset = "/usr/share/php/PHP/CodeSniffer/Standards/Symfony2/ruleset.xml" let g:phpqa_codesniffer_args = "--standard=Symfony2"

But I also tried just setting it to the default Zend ruleset and I get the same "Gene" error. let g:phpqa_messdetector_ruleset = "/usr/share/php/PHP/CodeSniffer/Standards/Zend/ruleset.xml" let g:phpqa_codesniffer_args = "--standard=Zend"

echoing as you suggested outputs the ruleset path properly. For the Zend ruleset it shows: /usr/share/php/PHP/CodeSniffer/Standards/Zend/ruleset.xml

setting let g:phpqa_open_loc = 0 makes it less annoying although I think I'm missing out on some functionality with that.

phpmd and phpcs are both the latest versions.

Would love to get to the bottom of this!

joonty commented 11 years ago

Ok, plan b! What version of mess detector do you have?

phpmd --version

Thanks

jdewit commented 11 years ago

phpmd 1.4.1 by Manuel Pichler phpcs 1.4.3 (stable) by Squiz Pty Ltd.

Vim is compiled with perl

On Xubuntu xfce 4.8

jdewit commented 11 years ago

I tried deleting some rulesets and it's not just the "Gene" ruleset that it cannot find. After deleting this...

<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.CallTimePassByReference"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.ControlStructures.ControlSignature"/>
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
<rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.Scope.MemberVarScope"/>

It now errors out on the next ruleset cannot find specified ruleset "PEAR"

I'm going to try reinstalling phpmd again.

joonty commented 11 years ago

No need to reinstall PHPMD! I've worked it out - your issue is due to the fact that the ruleset you printed is actually a code sniffer ruleset, not a mess detector ruleset.

A mess detector ruleset looks like this:

<?xml version="1.0"?>

<ruleset name="Example mess detection"
    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">
    <description>Example mess detection ruleset</description>

    <rule ref="rulesets/codesize.xml" />
    <!--<rule ref="rulesets/codesize.xml/NPathComplexity" />-->

    <rule ref="rulesets/design.xml/ExitExpression" />
    <rule ref="rulesets/design.xml/EvalExpression" />
    <rule ref="rulesets/design.xml/GotoStatement" />
    <rule ref="rulesets/design.xml/DepthOfInheritance" />
    <rule ref="rulesets/design.xml/CouplingBetweenObjects" />

    <rule ref="rulesets/naming.xml/LongVariable" />
    <rule ref="rulesets/naming.xml/ShortMethodName" />
    <rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
    <rule ref="rulesets/naming.xml/ConstantNamingConventions" />

    <rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" />
    <!--<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" />-->
    <rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
    <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
</ruleset>

I can reproduce the error by passing a code sniffer ruleset to mess detector. Easy enough to get them confused!

jdewit commented 11 years ago

That solves it! Thanks very much for your help.

joonty commented 11 years ago

No problem!