de.uni_bremen.st.rcf.util
Class CloneCoverage

java.lang.Object
  extended by de.uni_bremen.st.rcf.util.CloneCoverage

public class CloneCoverage
extends Object


Constructor Summary
CloneCoverage()
           
 
Method Summary
static double calculateCloneCoverage(RCF rcf, File file)
          Calculates the clone coverage for one file.
static double estimateCloneCoverage(RCF rcf, File file)
          Estimates the clone coverage for one file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CloneCoverage

public CloneCoverage()
Method Detail

calculateCloneCoverage

public static double calculateCloneCoverage(RCF rcf,
                                            File file)
Calculates the clone coverage for one file. Method: * Open file * scan file (generate token stream, comments will be ignored) * find cloned tokens using the clones defined in the given RCF * calculate clone ratio as: number-of-cloned-tokens / number-of-tokens-in-file * For empty files 0.0 will be returned. Requirements: * the file must be present under the path specified in the RCF. * the numTokens attribute must be set for the file * File must be of a supported language

Parameters:
file - the file
Returns:
the clone ratio

estimateCloneCoverage

public static double estimateCloneCoverage(RCF rcf,
                                           File file)
Estimates the clone coverage for one file. Method: * Collect all lines that are (at least partly) part of a clone * estimate clone coverage as: number-of-lines-that-contain-cloned-code / number-of-lines-in-file Requirements: * the loc attribute must be set for the file Note: This method only provides a rough estimation of the actual clone coverage. It counts lines with only a single cloned token as cloned and does not handle comments or blank lines. If you have the source code available, you should use calculateCloneCoverage instead.

Parameters:
file - the file
Returns:
the estimated clone ratio


Copyright © 2011. All Rights Reserved.