EasyPmd options

Profiles

Starting from version 4, EasyPmd includes Profiles: a profile is simply a named configuration for EasyPmd - you can therefore change the values of any set of options simply by selecting another profile.

EasyPmd comes with a default profile: by duplicating it, you can create new profiles, having different values for any options, as needed.

Using profiles is quite straightforward, but a few notes are due:

General options

This group of options determines how PMD should read your source files, in particular what the code structure is (determined by the Java version), which encoding should be used and what lines should be ignored.

Additional classpath options

The additional classpath tells PMD where to look for additional, that is custom, rulesets. If you just want to use the standard rulesets provided by PMD, you can leave this list empty.

Rulesets options

A ruleset defines a set of rules which have to be considered by PMD during a scan.

You can use PMD's standard rulesets, or you can define your own ones, as well as your own rules; for further information on creating your custom rulesets, please refer to the related article on my website.

Cache options

EasyPmd can provide an internal cache, which stores all the scan results; as long as your source files are unchanged, EasyPmd will look for the cache content instead of executing PMD again. EasyPmd's cache is persisted on disk, which means that it will be used even after you restart NetBeans.

In addition to this, it's important to notice that the cache is not entirely reloaded in memory when you start NetBeans: EasyPmd loads cache items in memory only when they are required by the scanning engine. For example, if you set the scanning context - in the Action Items window of NetBeans - to show tasks only for the current file, the scan results will be loaded from the on-disk cache into the in-memory cache only for the files that you open.

WARNING: please, remember that the cache is entirely cleared whenever you change any option and confirm the Options dialog.

Reporting options

These options simply affect how EasyPmd reports the results of the scans performed by PMD.

Path filtering

EasyPmd supports path filtering, which means that you can make EasyPmd scan only some files in your project, and you can at the same time exclude other files. There are some important concepts that should be kept in mind when setting path filters for EasyPmd:
  1. You can choose which paths have to be filtered (that is, included or excluded) by inserting one or more regular expressions
  2. Regular expressions are, by default, case sensitive, therefore on all operating systems, including Windows, a regular expression will match a file only if the path components have the correct case. Of course, you can create a case-insensitive regular expression, either manually or by using the related feature provided by EasyPmd
  3. To decide whether a file should be scanned, its absolute path is considered and matched against your set of regular expressions
  4. Always use "/" to separate path components: it will be automatically replaced by the regex-compatible form of the separator used by your system, if possible (in particular, it should work on Windows, Linux and Unix-like systems)
  5. If you need some examples, consider adding some predefined regular expressions

Scanning algorithm

EasyPmd observes the following rules when determining if PMD should scan a file:
  1. If the absolute path matches at least one of the regular expressions in the list of included patterns, or if this list is empty, consider the next step, otherwise the file is not scanned
  2. Then, if the absolute path does not match any pattern in the excluded patterns list, or if this list is empty, scan the file

Predefined regular expressions

Regular expressions are not always easy to write, and they might easily become tedious and error-prone if you have to write them frequently to cope with common cases - for example, filtering by file extension.

Therefore, EasyPmd provides some predefined regular expressions, which will be automatically generated by EasyPmd according to some information you will be asked for (e.g: the file extension). Predefined regular expressions are available for both included and excluded paths, and can be added by clicking on one of the Add predefined... buttons in the Path filtering panel.

Commands