Detect Class (detectClass)

<detectClass> Element

The detectClass rule is used to find certain class files.

Table 1. <detectClass> Element Attributes
Attribute Name Type Required Description
names String Yes, unless extends or implements attribute is specified.

Fully qualified class name. If providing multiple, use a comma separated list. Flags both definitions and uses of the specified classes, unless extends or implements is also specified.

extends String No

Fully qualified class name. If providing multiple, use a comma separated list. If specified, only declarations of clases that extend these classes will be flagged, not usages, regardless of the value specified for skipScanForUsage.

implements String No

Fully qualified class name. If providing multiple, use a comma separated list. If specified, only declarations of clases that implement these interfaces will be flagged, not usages, regardless of the value specified for skipScanForUsage.

useAppProvidedLibraries Boolean No

Indicates whether or not to check for the application providing the classes itself. If it is provided, then the rule will not flag. Defaults to false.

skipScanForUsage Boolean No

Indicates whether or not to check for usage of the classes. Use this when you want to check for an implementation provided by the application. Defaults to false.

classNamePattern Regex No

The class file including its path.

flagOnce Boolean No

Indicates whether to flag once per archive. Defaults to false.

flagOncePerFile Boolean No

Indicates whether to flag once per file. Defaults to false.

hideResult Boolean No

Indicates whether results flagged by this rule should be hidden in the report. This attribute only hides results when used with rules under the <and> or <or> tags. Defaults to false.

Child Elements (Zero or more)

<missingMethod> Element - optional, can be multiple

Table 2. <missingMethod> Element Attributes
Attribute Name Type Required Description
name String Yes

The method name of the method to flag if missing.


            

<implementsMethod> Element - optional, can be multiple

Table 3. <implementsMethod> Element Attributes
Attribute Name Type Required Description
name String Yes

The method name to flag if implemented.

arguments String No

Fully qualified class names and primitives. If multiple, use a comma separated list. The empty string is used to math methods with no parameters. If not specified, matches all method signatures.

accessFlag Enumeration No

If specified, only flag methods that match the criteria of this access flag. Supported values:

  • public
  • non-public

For example, to detect a javax.transaction.UserTransaction class, specify:


<detectClass names="javax.transaction.UserTransaction"/>