Home Reference Source Test
public class | source

PMDReporter

Extends:

BaseReporter → PMDReporter

Constructor Summary

Public Constructor
public

constructor(inspector: Inspector, opts: object)

A PMD CPD XML reporter, which tries to fit jsinspect's output to something CI tools might expect from PMD.

Method Summary

Private Methods
private

_escape(string: string): string

Returns an escaped string for use within XML.

private

_getFile(instance: object): string

Returns an XML string containing the path to the file in which the instance is located, as well as its starting line.

private

Returns an XML string containing a <duplication> element, with <file> children indicating the instance locations, and <codefragment> to hold the lines.

private

_getTotalLines(match: Match): int

Returns the total number of lines spanned by a match.

Inherited Summary

From class BaseReporter
private

Returns the absolute path for a file.

private

Returns a string containing the path to the file in which the nodes are located, as well as the lines on which the nodes exist.

private

_getLines(instance: Object): string

Returns the lines associated with an instance.

private

Returns the relative path for a file.

private

Registers a listener to the "match" event exposed by the Inspector instance.

private

Registers a listener that prints a final summary outlining the number of matches detected, as well as the number of files analyzed.

Public Constructors

public constructor(inspector: Inspector, opts: object) source

A PMD CPD XML reporter, which tries to fit jsinspect's output to something CI tools might expect from PMD.

Override:

BaseReporter#constructor

Params:

NameTypeAttributeDescription
inspector Inspector

Instance on which to register its listeners

opts object

Options to set for the reporter

Private Methods

private _escape(string: string): string source

Returns an escaped string for use within XML.

Params:

NameTypeAttributeDescription
string string

The string to escape

Return:

string

The escaped string

private _getFile(instance: object): string source

Returns an XML string containing the path to the file in which the instance is located, as well as its starting line. Absolute paths are required for Jenkins.

Params:

NameTypeAttributeDescription
instance object

Return:

string

private _getOutput(match: Match): string source

Returns an XML string containing a <duplication> element, with <file> children indicating the instance locations, and <codefragment> to hold the lines.

Params:

NameTypeAttributeDescription
match Match

The inspector match to output

Return:

string

The formatted output

private _getTotalLines(match: Match): int source

Returns the total number of lines spanned by a match.

Params:

NameTypeAttributeDescription
match Match

Return:

int