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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCounters(int lineNumber, int covered, int missed) Add the coverage counters for the specified line.voidaddIndirectCoverageChange(int line, int hitsDelta) Adds an indirect coverage change for a specific line.voidaddModifiedLines(int... lines) Marks the specified lines as being modified.voidaddMutation(Mutation mutation) Adds a mutation to the method.voidcomputeDelta(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.booleanfindOrCreateClassNode(String className) Searches for the specified class node.Returns the lines with code coverage that also have been modified.int[]intgetCoveredOfLine(int line) Returns the number of covered items for the specified line.org.apache.commons.lang3.math.FractionReturns 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.intgetMissedOfLine(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.booleanhasCoverageForLine(int line) Returns whether this file has a coverage result for the specified line.booleanReturns whether this file has lines with code coverage that also have been modified.booleanReturns whether this file has a delta result for the specified metric.inthashCode()booleanReturns whether the coverage of this node is affected indirectly by the tests in the change set.booleanhasModifiedLine(int line) Returns whether this file has been modified at the specified line.booleanReturns whether this file has been modified in the active change set.booleanReturns whether this node matches the specified metric and name.booleanReturns whether this node matches the specified metric and name.voidsetRelativePath(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 newFileNodewith the given name.- Parameters:
name- the human-readable name of the noderelativePath- the relative path of the file
-
FileNode
Creates a newFileNodewith 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:NodeCreates a copy of this instance that has no children and no parent yet. Node properties from the parent classNodemust not be copied. All other immutable properties need to be copied one by one. -
matches
Description copied from class:NodeReturns whether this node matches the specified metric and name. -
matches
Description copied from class:NodeReturns 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:
hasModifiedLinesin classNode- Returns:
trueif this file has been modified in the active change set,falseotherwise
-
hasModifiedLine
public boolean hasModifiedLine(int line) Returns whether this file has been modified at the specified line.- Parameters:
line- the line to check- Returns:
trueif this file has been modified at the specified line,falseotherwise
-
addModifiedLines
public void addModifiedLines(int... lines) Marks the specified lines as being modified.- Parameters:
lines- the modified code lines
-
filterTreeByModifiedLines
- Overrides:
filterTreeByModifiedLinesin classNode
-
filterTreeByModifiedFiles
- Overrides:
filterTreeByModifiedFilesin classNode
-
filterTreeByIndirectChanges
- Overrides:
filterTreeByIndirectChangesin 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:
trueif this file has a coverage result for the specified line,falseotherwise
-
getFiles
Description copied from class:NodeReturns 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:
trueif 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:
truehas delta results are available,falseotherwise
-
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:
trueif this file has lines with code coverage that also have been modified,falseotherwise.
-
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()
-