Re: [pmd-devel] Avoid really long methods
A source code analyzer
Brought to you by:
adangel,
juansotuyo
|
From: Allan C. <al...@gm...> - 2007-02-23 14:07:16
|
On 2/23/07, Srilakshmanan, Lakshman <
Lak...@tr...> wrote:
>
> Hi,
>
> I am getting the following error while running PMD.
>
> "Avoid really long methods"
>
>
> I have tried the following and checked the mailing list to no avail.
> <rule ref="rulesets/codesize.xml">
> <exclude name="LongMethodRule"/>
> </rule>
>
> <rule ref="rulesets/codesize.xml">
> <exclude name="ExcessiveLengthRule"/>
> </rule>
>
> <rule ref="rulesets/codesize.xml">
> <exclude name="ExcessiveMethodLength"/>
> </rule>
>
> Any assistance is greatly appreciated.
>
> Thanks
> Lakshman
Hello Lakshman,
Are you trying this with the latest version of PMD (3.9)? Are you getting
this problem with ant or with the command line? I tried the following with
the command line, and it worked for me. I ran two tests, one with all the
codesize rules to make sure the ExcessiveMethodLength rule gets fired, and
another with the exclude.
c:\pmd\bin>more include.xml
<?xml version="1.0"?>
<ruleset>
<rule ref="rulesets/codesize.xml"/>
</ruleset>
c:\pmd\bin>pmd Foo.java text include.xml
c:\pmd\bin\Foo.java:2 Avoid really long methods.
c:\pmd\bin\Foo.java:2 The method longMethod() has an NCSS line count of
149
c:\pmd\bin>more exclude.xml
<?xml version="1.0"?>
<ruleset>
<rule ref="rulesets/codesize.xml"><exclude
name="ExcessiveMethodLength"/></rule>
</ruleset>
c:\pmd\bin>pmd Foo.java text exclude.xml
c:\pmd\bin\Foo.java:2 The method longMethod() has an NCSS line count of
149
As you can see, the exclude *should* work. I haven't tried this through ant.
One possibility is that you have been changing the wrong ruleset file. I've
done this more times than I'd like to admit - try removing all rule
references, or change codesize to basic and see what happens.
Allan
|