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:
-
When editing EasyPmd's options, they are temporarily but
constantly saved into the active profile - the one selected
in the Profile drop-down list: if you select another
profile, its options are immediately applied to all the
controls in the dialog and you can start editing the new
profile. If you re-select the previous profile, you
will be able to edit its options again.
-
Changes to the profiles, including the active profile,
are saved to disk only if you confirm the options dialog
by pressing OK; this will also apply the new set of
options to the internal PMD scanner.
Consequently, if you cancel the dialog, no change will
be saved - not even into memory.
-
The initial profile can be deleted, if you wish: the
only constraint is the fact that at least one profile
must be present in the system - EasyPmd will just prevent
you from removing the last profile.
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.
-
Target Java version: this parameter is used by PMD's parser in order to determine the structure of source files. At the moment of this writing, the latest Java version is "1.7".
-
Source file encoding: the encoding used to read source files when scanning them with PMD.
-
Suppress marker: the marker comment used to prevent PMD checks for a specific line. Please refer to PMD's manual.
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.
- Add Jar...: shows a file dialog to let the user choose a jar file, so as to add it to PMD's classpath.
- Add custom URL...: allows the user to add a custom URL to PMD's classpath.
- Move up: moves the selected URLs up.
- Move down: moves the selected URLs down.
- Remove: removes the selected URLs from the list.
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.
- Add standard...: shows a dialog reporting PMD's default rulesets. The user can choose one of them in order to add it to the list.
- Add custom...: allows the user to add a custom ruleset to the list.
- Move up: moves the selected rulesets up.
- Move down: moves the selected rulesets down.
- Remove: removes the selected rulesets from the list.
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.
- Activate EasyPmd cache: when this checkbox is checked, EasyPmd will store the scan output into its cache, which resides both in memory and on disk.
- Clear the cache: removes every cache entry, both in memory and on disk.
This can be very useful because EasyPmd stores its cache on disk too, in the directory HOME_DIR/.EasyPmd4/cache. Should this directory grow too big, you can delete it, either manually or by clicking this button (which also empties the in-memory cache).
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:
- You can choose which paths have to be filtered (that is, included or excluded) by inserting one or more regular expressions
- 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
- To decide whether a file should be scanned, its absolute path is considered and matched against your set of regular expressions
- 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)
- 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:
- 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
- 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
-
Reset settings: restores all the settings in the dialog to their original values, but you have to confirm the dialog in order to save them.
-
Verify settings: performs a first-level check on the options in the dialog, telling if they seem correct