Class FileNode
java.lang.Object
com.parasoft.findings.jenkins.coverage.model.Node
com.parasoft.findings.jenkins.coverage.model.FileNode
- All Implemented Interfaces:
Serializable
A
Node
for a specific file. It stores the actual file name along with the coverage information.- Author:
- Ullrich Hafner
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCounters
(int lineNumber, int covered, int missed) Add the coverage counters for the specified line.void
addIndirectCoverageChange
(int line, int hitsDelta) Adds an indirect coverage change for a specific line.void
addModifiedLines
(int... lines) Marks the specified lines as being modified.void
addMutation
(Mutation mutation) Adds a mutation to the method.void
computeDelta
(FileNode referenceFile) Computes the delta of all values between this file and the given reference file.copy()
Creates a copy of this instance that has no children and no parent yet.createClassNode
(String className) Create a new class node with the given name and add it to the list of children.boolean
findOrCreateClassNode
(String className) Searches for the specified class node.Returns the lines with code coverage that also have been modified.int[]
int
getCoveredOfLine
(int line) Returns the number of covered items for the specified line.org.apache.commons.lang3.math.Fraction
Returns the delta for the specified metric.getFiles()
Returns the file names that are contained within the subtree of this node.int[]
Returns the lines that have no line coverage.int
getMissedOfLine
(int line) Returns the number of missed items for the specified line.Returns the lines that contain mutations.Returns the lines that have a branch coverage less than 100%.Returns the relative path of the file.Returns the lines that contain survived mutations.boolean
hasCoverageForLine
(int line) Returns whether this file has a coverage result for the specified line.boolean
Returns whether this file has lines with code coverage that also have been modified.boolean
Returns whether this file has a delta result for the specified metric.int
hashCode()
boolean
Returns whether the coverage of this node is affected indirectly by the tests in the change set.boolean
hasModifiedLine
(int line) Returns whether this file has been modified at the specified line.boolean
Returns whether this file has been modified in the active change set.boolean
Returns whether this node matches the specified metric and name.boolean
Returns whether this node matches the specified metric and name.void
setRelativePath
(edu.hm.hafner.util.TreeString relativePath) Sets the relative path of the file.Methods inherited from class com.parasoft.findings.jenkins.coverage.model.Node
addAllChildren, addAllValues, addChild, addValue, aggregateValues, computeDelta, containsMetric, copyNode, copyTree, copyTree, filterByIndirectChanges, filterByModifiedFiles, filterByModifiedLines, find, findByHashCode, findClass, findFile, findMethod, findPackage, getAll, getAllFileNodes, getAllMethodNodes, getChildren, getMetric, getMetrics, getName, getParasoftToolName, getParent, getParentName, getSourceFolders, getTypedValue, getValue, getValueMetrics, getValues, hasChildren, hasParent, isEmpty, isRoot, merge, merge, removeChild, replaceValue, setParasoftToolName, toString
-
Constructor Details
-
FileNode
Creates a newFileNode
with the given name.- Parameters:
name
- the human-readable name of the noderelativePath
- the relative path of the file
-
FileNode
Creates a newFileNode
with the given name.- Parameters:
name
- the human-readable name of the noderelativePath
- the relative path of the file
-
-
Method Details
-
copy
Description copied from class:Node
Creates a copy of this instance that has no children and no parent yet. Node properties from the parent classNode
must not be copied. All other immutable properties need to be copied one by one. -
matches
Description copied from class:Node
Returns whether this node matches the specified metric and name. -
matches
Description copied from class:Node
Returns whether this node matches the specified metric and name. -
getModifiedLines
-
hasModifiedLines
public boolean hasModifiedLines()Returns whether this file has been modified in the active change set.- Overrides:
hasModifiedLines
in classNode
- Returns:
true
if this file has been modified in the active change set,false
otherwise
-
hasModifiedLine
public boolean hasModifiedLine(int line) Returns whether this file has been modified at the specified line.- Parameters:
line
- the line to check- Returns:
true
if this file has been modified at the specified line,false
otherwise
-
addModifiedLines
public void addModifiedLines(int... lines) Marks the specified lines as being modified.- Parameters:
lines
- the modified code lines
-
filterTreeByModifiedLines
- Overrides:
filterTreeByModifiedLines
in classNode
-
filterTreeByModifiedFiles
- Overrides:
filterTreeByModifiedFiles
in classNode
-
filterTreeByIndirectChanges
- Overrides:
filterTreeByIndirectChanges
in classNode
-
addIndirectCoverageChange
public void addIndirectCoverageChange(int line, int hitsDelta) Adds an indirect coverage change for a specific line.- Parameters:
line
- The line with the coverage changehitsDelta
- The delta of the coverage hits before and after the code changes
-
getIndirectCoverageChanges
-
getLinesWithCoverage
-
hasCoverageForLine
public boolean hasCoverageForLine(int line) Returns whether this file has a coverage result for the specified line.- Parameters:
line
- the line to check- Returns:
true
if this file has a coverage result for the specified line,false
otherwise
-
getFiles
Description copied from class:Node
Returns the file names that are contained within the subtree of this node. -
hasIndirectCoverageChanges
public boolean hasIndirectCoverageChanges()Returns whether the coverage of this node is affected indirectly by the tests in the change set.- Returns:
true
if this node is affected indirectly by the tests.
-
computeDelta
Computes the delta of all values between this file and the given reference file. Values that are not present in both files are ignored.- Parameters:
referenceFile
- the file to compare with this file
-
getDelta
Returns the delta for the specified metric. If no delta is available for the specified metric, then 0 is returned.- Parameters:
metric
- the metric to get the delta for- Returns:
- the delta for the specified metric
-
hasDelta
Returns whether this file has a delta result for the specified metric.- Parameters:
metric
- the metric to check- Returns:
true
has delta results are available,false
otherwise
-
getCoveredAndModifiedLines
Returns the lines with code coverage that also have been modified.- Returns:
- the lines with code coverage that also have been modified
-
hasCoveredAndModifiedLines
public boolean hasCoveredAndModifiedLines()Returns whether this file has lines with code coverage that also have been modified.- Returns:
true
if this file has lines with code coverage that also have been modified,false
otherwise.
-
addCounters
public void addCounters(int lineNumber, int covered, int missed) Add the coverage counters for the specified line.- Parameters:
lineNumber
- the line number to add the counters forcovered
- the number of covered itemsmissed
- the number of missed items
-
getCoveredCounters
public int[] getCoveredCounters() -
getMissedCounters
public int[] getMissedCounters() -
getCoveredOfLine
public int getCoveredOfLine(int line) Returns the number of covered items for the specified line.- Parameters:
line
- the line to check- Returns:
- the number of covered items for the specified line
-
getMissedOfLine
public int getMissedOfLine(int line) Returns the number of missed items for the specified line.- Parameters:
line
- the line to check- Returns:
- the number of missed items for the specified line
-
getMissedLines
Returns the lines that have no line coverage. Note that lines that have no branch coverage are not included as these are reported separately ingetPartiallyCoveredLines()
.- Returns:
- the lines that have no line coverage
-
getSurvivedMutationsPerLine
Returns the lines that contain survived mutations. The returned map contains the line number as the key and a list of survived mutations as value.- Returns:
- the lines that have no line coverage
-
getMutationsPerLine
Returns the lines that contain mutations. The returned map contains the line number as the key and a list of mutations as value.- Returns:
- the lines that have no line coverage
-
getPartiallyCoveredLines
Returns the lines that have a branch coverage less than 100%. The returned map contains the line number as the key and the number of missed branches as value.- Returns:
- the mapping of not fully covered lines to the number of missed branches
-
getCounters
-
addMutation
Adds a mutation to the method.- Parameters:
mutation
- the mutation to add
-
getMutations
-
createClassNode
Create a new class node with the given name and add it to the list of children.- Parameters:
className
- the class name- Returns:
- the created and linked class node
-
findOrCreateClassNode
Searches for the specified class node. If the class node is not found then a new class node will be created and linked to this file node.- Parameters:
className
- the class name- Returns:
- the created and linked class node
- See Also:
-
getRelativePath
Returns the relative path of the file. If no relative path is set then the name of this node is returned.- Returns:
- the relative path of the file
-
setRelativePath
public void setRelativePath(edu.hm.hafner.util.TreeString relativePath) Sets the relative path of the file.- Parameters:
relativePath
- the relative path
-
equals
-
hashCode
public int hashCode()
-