gavioto / m2e-extensions

Automatically exported from code.google.com/p/m2e-extensions
0 stars 0 forks source link

nothing happens with pmd #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Here is the steps :
1- Create a maven 2 project (using quick start archetype).
2- Enable PMD on the project. I can see errors, for example: System.out)
3- Clear pmd alerts
3- Add pmd configuration into POM. I can see in the maven console that 
m2e-extensions is loading the rules about pmd (no error).
4- Enable PMD on the project again : nothing happens. It should detect
violations.

Environnement :
- Eclipse Helios SR1 J2EE + m2eclipse 0.10

Original issue reported on code.google.com by lmichen...@gmail.com on 5 Oct 2010 at 12:55

GoogleCodeExporter commented 9 years ago
After investigating, i've seen that if you specify no include in pmd 
configuration,
you've got that line in the .pmdruleset.

<exclude-pattern>.*/home/projets/lmichenaud/workspace-android/testcheckstyle.*</
exclude-pattern>

This line is not present from my remote pmd configuration (comes from sonar).
This prevents pmd working.

I think this line should not be added or you want to keep it, you have to
add a default include to **\/*.java which is the default value of the "include" 
parameter of maven pmd plugin.

Original comment by lmichen...@gmail.com on 13 Oct 2010 at 12:12

GoogleCodeExporter commented 9 years ago
I also see the behaviour lmichenaud reports. I don't get the PMD warnings I 
should be getting, but once I clear the exclude-pattern in .pmdruleset it 
starts working.

Original comment by mike...@gmail.com on 22 Oct 2010 at 8:50

GoogleCodeExporter commented 9 years ago
Looking a bit further, in my case it seems my PMD configuration isn't being 
picked up at all and I am instead getting a default setup. I'm pointing PMD at 
my common rule file like this:

            <plugin>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    ...
                    <excludeRoots>
                        <excludeRoot>src/main/generated</excludeRoot>
                        <excludeRoot>src/test</excludeRoot>
                        <excludeRoot>src/integration-test</excludeRoot>
                    </excludeRoots>
                    <rulesets>
                        <ruleset>common/pmd-rules.xml</ruleset>
                    </rulesets>
                    ...
                </configuration>
                ...
            </plugin>

and pmd-rules.xml contains:

  <ruleset> 
    <exclude-pattern>.*/src/test/.*</exclude-pattern>
    ...
    <!-- no inclusion of AvoidDuplicateLiterals -->
  </ruleset>

The M2Eclipse log says:

  [M2E-PMD]: Eclipse PMD Configuration STARTED
  [M2E-PMD]: Successfully resolved artifact [org.apache.maven.plugins...]
  [M2E-PMD]: Successfully resolved artifact [common...]
  [M2E-PMD]: RESOLVED location <common/pmd-rules.xml> as [jar:file:.../common/pmd-rules.xml]
  [M2E-PMD]: ADDED PMD nature and builder to the eclipse project
  [M2E-PMD]: Eclipse PMD Configuration ENDED

Still, the generated .pmdruleset in the Eclipse project contains:

  <ruleset ...>
    <exclude-pattern>.*/my_project_dir.*</exclude-pattern>
    ...
    <rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>
  </ruleset>

lmichenaud: Is this the same problem you are seeing, or should I log this as a 
new ticket?

Original comment by mike...@gmail.com on 22 Oct 2010 at 9:41

GoogleCodeExporter commented 9 years ago
I think it is the same problem.

I have resolved the problems using that configuration :

<plugin>
  <artifactId>maven-pmd-plugin</artifactId>
  <version>2.5</version>
  <configuration>
  <includes>
    <include>**\/*.java</include>
  </includes>                       
  <rulesets>
    <ruleset>${pmd.ruleSet}</ruleset>
  </rulesets>
  </configuration>
</plugin>

Original comment by lmichen...@gmail.com on 22 Oct 2010 at 9:47

GoogleCodeExporter commented 9 years ago
What happens if you change something in your ruleset file (the file pointed to 
by pmd.ruleSet). Is it reflected in the generated .pmdruleset file?

Original comment by mike...@gmail.com on 22 Oct 2010 at 9:55

GoogleCodeExporter commented 9 years ago
Hey guys, 

I've just committed some fixes to the include/exclude rules for PMD/CS.  If 
you're building the plugins from source, can you update from tip and see if the 
fixes solve the issues you're experiencing?  You shouldn't need any hacks in 
your PMD/CS configs.

Original comment by mr.id...@gmail.com on 20 Dec 2010 at 5:31

GoogleCodeExporter commented 9 years ago
I have not tested but i've got a question.

Did you make your plugin compatible with m2eclipse 0.12 ?

Original comment by lmichen...@gmail.com on 21 Dec 2010 at 10:24