use of org.eclipse.titanium.metrics.MetricData in project titan.EclipsePlug-ins by eclipse.
the class ContentProvider method getElements.
@Override
public Object[] getElements(final Object inputElement) {
if (!(inputElement instanceof MetricData)) {
throw new IllegalArgumentException();
}
data = (MetricData) inputElement;
final List<? super INode> children = new ArrayList<INode>();
for (final MetricGroup t : MetricGroup.values()) {
final RootNode n = new RootNode(t);
if (n.hasChildren(data)) {
children.add(n);
}
}
return children.toArray();
}
use of org.eclipse.titanium.metrics.MetricData in project titan.EclipsePlug-ins by eclipse.
the class ExportAllMetrics method exportInformationForProject.
@Override
protected void exportInformationForProject(final String[] args, final IProject project, final IProgressMonitor monitor) {
final MetricData data = MetricData.measure(project);
final RiskLevel r = RiskLevel.NO;
final String fn = args[0] + project.getName() + ".xls";
final File file = new File(fn);
final XLSExporter xlsWriter = new XLSExporter(data);
xlsWriter.setFile(file);
xlsWriter.write(r);
}
use of org.eclipse.titanium.metrics.MetricData in project titan.EclipsePlug-ins by eclipse.
the class RiskFactorCalculator method measure.
/**
* Calculate the quality of a project.
* <p>
* The code smells are not counted by this method, but rather supplied as
* parameter. The keys of the map are the enum names of markers (thus,
* {@link TaskType#getMarkerObject()} and {@link CodeSmellType#getMarkerObject()}). Exactly the
* code smells enumerated in {@link #USED_MARKERS} are taken in account:
* other keys are ignored; upon missing ones an exception is thrown.
*
* @throws IllegalArgumentException
* when a key is missing from <code>smellCount</code>
*
* @param project
* the project to measure
* @param smellCount
* the number of occurrences for the code smells
*
* @return the quality assignment of the project
*/
// TODO: it worth reconsidering to refactor, i.e. the smell counting as a
// separate method of this class
public int measure(final IProject project, final Map<String, Integer> smellCount) {
final MetricData data = MetricData.measure(project);
final Number n = data.getStatistics(ModuleMetric.LINES_OF_CODE).get(StatColumn.TOTAL);
final int loc = n.intValue();
int riskFactor = 0;
int relativeOccurrene;
for (final ProblemType marker : USED_MARKERS) {
final Integer count = smellCount.get(marker.toString());
if (count == null) {
throw new IllegalArgumentException("The supplied map has no entry for " + marker.toString() + ". Collate the parameters and the 'usedMarkers' field.");
}
if (count.intValue() == 0) {
relativeOccurrene = 0;
} else {
int actualS = loc / count;
int baseS = marker.getBaseLine();
if (actualS == 0) {
relativeOccurrene = 0;
} else if (actualS > baseS) {
relativeOccurrene = 1;
} else if (actualS > baseS / 2) {
relativeOccurrene = 2;
} else if (actualS > baseS / 8) {
relativeOccurrene = 3;
} else {
relativeOccurrene = 4;
}
}
riskFactor += relativeOccurrene * marker.getImpact();
}
return riskFactor;
}
Aggregations