Uploaded image for project: 'Maven PMD Plugin'
  1. Maven PMD Plugin
  2. MPMD-161

PMD/CPD violation exclusions by class/issue

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0
    • CPD, PMD
    • None
    • Patch

    Description

      I work on a system that has a lot of legacy code with a lot of PMD/CPD violations. Introducing PMD to the build is not an easy option, since the build would always fail. So the next best thing is to exclude any existing violations and only fail if a new violation is introduced. Unfortunately, if I have thousands of violations, PMD doesn't provide a good way to do this. I'd have to add comments or annotations to all these places to ignore the violation.

      We came up with an alternative solution to this. We modified the PMD plugin to read a properties file that contains a mapping of class name to a list of excluded violations. If a particular violation is in this file, it does not cause the build to fail. Similar idea for CPD.

      An svn patch is attached (apply to 2.7.1)

      (Disclaimer: this is probably not the most elegant piece of code but it works and it was quick. Feel free to re-factor and make it more in line with the rest of the plugin code)

      Attachments

        1. pmd_exclude_trunk_v2.patch
          27 kB
          Andrey Utis
        2. pmd_exclude_trunk.patch
          9 kB
          Andrey Utis
        3. pmd2.7.1_exclusions2.patch
          18 kB
          Andrey Utis

        Issue Links

          Activity

            People

              olamy Olivier Lamy
              andrey81inmd Andrey Utis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: