/** * Get the current AppVersion. */ @Override public AppVersion getCurrentAppVersion() { return new AppVersion(getSequenceNumber()).setReleaseName(getReleaseName()).setTimestamp(getTimestamp()) .setNumClasses(getProjectStats().getNumClasses()).setCodeSize(getProjectStats().getCodeSize()); }
/** This is how dump() was implemented up to and including version 0.9.5. */ public void dumpOriginal(PrintStream out) { out.println("seq\tversion\ttime\tclasses\tNCSS\tadded\tnewCode\tfixed\tremoved\tretained\tdead\tactive"); for (int i = 0; i < versionList.length; ++i) { Version version = versionList[i]; AppVersion appVersion = sequenceToAppVersionMap.get(version.getSequence()); out.print(i); out.print('\t'); out.print(appVersion != null ? appVersion.getReleaseName() : ""); out.print('\t'); if (formatDates) { out.print("\"" + (appVersion != null ? dateFormat.format(new Date(appVersion.getTimestamp())) : "") + "\""); } else { out.print(appVersion != null ? appVersion.getTimestamp() / 1000 : 0L); } out.print('\t'); if (appVersion != null) { out.print(appVersion.getNumClasses()); out.print('\t'); out.print(appVersion.getCodeSize()); } else { out.print("\t0\t0"); } for (int j = 0; j < TUPLE_SIZE; ++j) { out.print('\t'); out.print(version.get(j)); } out.println(); } }
@Override public SortedBugCollection createEmptyCollectionWithMetadata() { SortedBugCollection dup = new SortedBugCollection(projectStats.clone(), comparator, project); dup.projectStats.clearBugCounts(); dup.errorList.addAll(this.errorList); dup.missingClassSet.addAll(this.missingClassSet); dup.summaryHTML = this.summaryHTML; dup.classFeatureSetMap.putAll(this.classFeatureSetMap); dup.sequence = this.sequence; dup.analysisVersion = this.analysisVersion; dup.analysisTimestamp = this.analysisTimestamp; dup.timestamp = this.timestamp; dup.releaseName = this.releaseName; for (AppVersion appVersion : appVersionList) { dup.appVersionList.add((AppVersion) appVersion.clone()); } return dup; }
public static long getVersionNum(BugCollection collection, String val, boolean roundToLaterVersion) { if (val == null) { return -1; } Map<String, AppVersion> versions = new HashMap<>(); SortedMap<Long, AppVersion> timeStamps = new TreeMap<>(); for (Iterator<AppVersion> i = collection.appVersionIterator(); i.hasNext();) { AppVersion v = i.next(); versions.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); } // add current version to the maps AppVersion v = collection.getCurrentAppVersion(); versions.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); return getVersionNum(versions, timeStamps, val, roundToLaterVersion, v.getSequenceNumber()); }
for (Iterator<AppVersion> i = origCollection.appVersionIterator(); i.hasNext();) { AppVersion appVersion = i.next(); resultCollection.addAppVersion((AppVersion) appVersion.clone()); AppVersion origCollectionVersionClone = new AppVersion(lastSequence); origCollectionVersionClone.setTimestamp(origCollectionVersion.getTimestamp()); origCollectionVersionClone.setReleaseName(origCollectionVersion.getReleaseName()); origCollectionVersionClone.setNumClasses(origCollection.getProjectStats().getNumClasses()); origCollectionVersionClone.setCodeSize(origCollection.getProjectStats().getCodeSize());
out.print("\" "); out.print("version=\""); out.print(appVersion != null ? appVersion.getReleaseName() : ""); out.print("\" "); out.print("time=\""); if (formatDates) { out.print((appVersion != null ? new Date(appVersion.getTimestamp()).toString() : "")); } else { out.print(appVersion != null ? appVersion.getTimestamp() : 0L);
@Before public void setUp() throws Exception { versionNames = new HashMap<>(); timeStamps = new TreeMap<>(); Set<AppVersion> versions = new HashSet<>(); SimpleDateFormat format = new SimpleDateFormat("MMMMM dd, yyyy", Locale.ENGLISH); versions.add(new AppVersion(0, format.parse("June 1, 2005"), "v1.0")); versions.add(new AppVersion(1, format.parse("June 10, 2005"), "v1.1")); versions.add(new AppVersion(2, format.parse("June 20, 2005"), "v2.0")); for (AppVersion v : versions) { versionNames.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); } }
static private long getAppropriateSeq(SortedMap<Long, AppVersion> timeStamps, long when, boolean roundToLaterVersion) { if (roundToLaterVersion) { SortedMap<Long, AppVersion> geq = timeStamps.tailMap(when); if (geq.isEmpty()) { return Long.MAX_VALUE; } return geq.get(geq.firstKey()).getSequenceNumber(); } else { SortedMap<Long, AppVersion> leq = timeStamps.headMap(when); if (leq.isEmpty()) { return Long.MIN_VALUE; } return leq.get(leq.lastKey()).getSequenceNumber(); } }
printRow("kind", "name", "density/KNCSS", "bugs", "NCSS"); double projectDensity = density(stats.getTotalBugs(), stats.getCodeSize()); printRow("project", origCollection.getCurrentAppVersion().getReleaseName(), projectDensity, stats.getTotalBugs(), stats.getCodeSize()); for (PackageStats p : stats.getPackageStats()) {
public long getFirstSeenFromVersion(BugInstance b) { long firstVersion = b.getFirstVersion(); AppVersion v = getBugCollection().getAppVersionFromSequenceNumber(firstVersion); if (v == null) { return getBugCollection().getTimestamp(); } return v.getTimestamp(); }
for (Iterator<AppVersion> i = origCollection.appVersionIterator(); i.hasNext();) { AppVersion appVersion = i.next(); resultCollection.addAppVersion((AppVersion) appVersion.clone()); AppVersion origCollectionVersionClone = new AppVersion(lastSequence); origCollectionVersionClone.setTimestamp(origCollectionVersion.getTimestamp()); origCollectionVersionClone.setReleaseName(origCollectionVersion.getReleaseName()); origCollectionVersionClone.setNumClasses(origCollection.getProjectStats().getNumClasses()); origCollectionVersionClone.setCodeSize(origCollection.getProjectStats().getCodeSize());
commandLine.lastVersion, true); if (last < origCollection.getSequenceNumber()) { String name = origCollection.getAppVersionFromSequenceNumber(last).getReleaseName(); long timestamp = origCollection.getAppVersionFromSequenceNumber(last).getTimestamp(); origCollection.setReleaseName(name); origCollection.setTimestamp(timestamp);
versions.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); versions.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); commandLine.trimToVersionAsString, true, v.getSequenceNumber()); if (trimToVersion < origCollection.getSequenceNumber()) { String name = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getReleaseName(); long timestamp = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getTimestamp(); resultCollection.setReleaseName(name); resultCollection.setTimestamp(timestamp);
@Override public AppVersion getAppVersionFromSequenceNumber(long target) { for (AppVersion av : appVersionList) { if (av.getSequenceNumber() == target) { return av; } } if (target == this.getSequenceNumber()) { return this.getCurrentAppVersion(); } return null; }
printRow("kind", "name", "density/KNCSS", "bugs", "NCSS"); double projectDensity = density(stats.getTotalBugs(), stats.getCodeSize()); printRow("project", origCollection.getCurrentAppVersion().getReleaseName(), projectDensity, stats.getTotalBugs(), stats.getCodeSize()); for (PackageStats p : stats.getPackageStats()) {
public long getLocalFirstSeen(BugInstance b) { long firstVersion = b.getFirstVersion(); AppVersion v = getBugCollection().getAppVersionFromSequenceNumber(firstVersion); if (v == null) { return getBugCollection().getTimestamp(); } long firstSeen = v.getTimestamp(); if (b.hasXmlProps()) { XmlProps props = b.getXmlProps(); Date propsFirstSeen = props.getFirstSeen(); if (propsFirstSeen != null && firstSeen > propsFirstSeen.getTime()) { firstSeen = propsFirstSeen.getTime(); } } return firstSeen; }
out.print(appVersion.getReleaseName()); out.print('\t'); if (formatDates) { out.print("\"" + new Date(appVersion.getTimestamp()) + "\""); } else { out.print(appVersion.getTimestamp()); out.print(appVersion.getNumClasses()); out.print('\t'); out.print(appVersion.getCodeSize()); out.print('\t'); out.print(origCollection.getErrors().size());
String codeSize = getOptionalAttribute(attributes, "codeSize"); String numClasses = getOptionalAttribute(attributes, "numClasses"); AppVersion appVersion = new AppVersion(Long.parseLong(sequence)); if (timestamp != null) { appVersion.setTimestamp(Long.parseLong(timestamp)); appVersion.setReleaseName(releaseName); appVersion.setCodeSize(Integer.parseInt(codeSize)); appVersion.setNumClasses(Integer.parseInt(numClasses));
@Override public String formatValue(String value) { int seqNum = Integer.parseInt(value); BugCollection bugCollection = MainFrame.getInstance().getBugCollection(); if (bugCollection == null) { return "--"; } AppVersion appVersion = bugCollection.getAppVersionFromSequenceNumber(seqNum); if (appVersion != null) { String timestamp = new Timestamp(appVersion.getTimestamp()).toString(); return appVersion.getReleaseName() + " (" + timestamp.substring(0, timestamp.indexOf(' ')) + ")"; } else { return "#" + seqNum; } }
public static long getVersionNum(BugCollection collection, String val, boolean roundToLaterVersion) { if (val == null) { return -1; } Map<String, AppVersion> versions = new HashMap<String, AppVersion>(); SortedMap<Long, AppVersion> timeStamps = new TreeMap<Long, AppVersion>(); for (Iterator<AppVersion> i = collection.appVersionIterator(); i.hasNext();) { AppVersion v = i.next(); versions.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); } // add current version to the maps AppVersion v = collection.getCurrentAppVersion(); versions.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); return getVersionNum(versions, timeStamps, val, roundToLaterVersion, v.getSequenceNumber()); }