本文整理汇总了Java中org.sonar.api.measures.Measure类的典型用法代码示例。如果您正苦于以下问题:Java Measure类的具体用法?Java Measure怎么用?Java Measure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Measure类属于org.sonar.api.measures包,在下文中一共展示了Measure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMeasures
import org.sonar.api.measures.Measure; //导入依赖的package包/类
public Collection<Measure> createMeasures() {
Collection<Measure> measures = new ArrayList<Measure>();
if (getLinesToCover() > 0) {
measures.add(new Measure(CtcMetrics.CTC_LINES_TO_COVER, (double) getLinesToCover()));
measures.add(new Measure(CtcMetrics.CTC_UNCOVERED_LINES, (double) (getLinesToCover() - getCoveredLines())));
measures.add(new Measure(CtcMetrics.CTC_COVERAGE_LINE_HITS_DATA).setData(KeyValueFormat.format(hitsByLine)).setPersistenceMode(PersistenceMode.DATABASE));
}
if (getStatements() > 0) {
measures.add(new Measure(CtcMetrics.CTC_STATEMENTS_TO_COVER, (double) getStatements()));
measures.add(new Measure(CtcMetrics.CTC_UNCOVERED_STATEMENTS, (double) (getStatements() - getCoveredStatements())));
}
if (getConditions() > 0) {
measures.add(new Measure(CtcMetrics.CTC_CONDITIONS_TO_COVER, (double) getConditions()));
measures.add(new Measure(CtcMetrics.CTC_UNCOVERED_CONDITIONS, (double) (getConditions() - getCoveredConditions())));
measures.add(createConditionsByLine());
measures.add(createCoveredConditionsByLine());
}
return measures;
}
示例2: decorate
import org.sonar.api.measures.Measure; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void decorate(Resource resource, DecoratorContext context) {
if (resource.getScope().equals(Scopes.FILE)) {
Map lineHits = new HashMap<Integer, Integer>();
context.saveMeasure(CoreMetrics.LINES_TO_COVER, context.getMeasure(CoreMetrics.LINES).getValue());
context.saveMeasure(CoreMetrics.UNCOVERED_LINES, 0.0);
for (int i = 1; i <= context.getMeasure(CoreMetrics.LINES).getIntValue(); i++) {
lineHits.put(i, 1);
}
context.saveMeasure(new Measure(CoreMetrics.COVERAGE_LINE_HITS_DATA).setData(KeyValueFormat.format(lineHits)).setPersistenceMode(PersistenceMode.DATABASE));
}
for (Metric[] entry : CONV) {
applyAndSaveMeasure(entry, context, resource);
}
}
示例3: saveMeasures
import org.sonar.api.measures.Measure; //导入依赖的package包/类
@VisibleForTesting
void saveMeasures(DecoratorContext context) {
LOGGER.info("Saving metrics for: {} project.", projectKey);
Toxicity toxicity = DebtsFilter.getInstance().getToxicity();
context.saveMeasure(new Measure(ToxicityChartMetrics.TOXICITY_STATUS,
getToxicityAsXml(toxicity)));
context.saveMeasure(new Measure(
ToxicityChartMetrics.TOXICITY_AVERAGE_VALUE, toxicity
.getAverageCost()));
for (DebtType debt : DebtType.values()) {
context.saveMeasure(new Measure(ToxicityChartMetrics
.getMetricByDebtType(debt), toxicity.getTotalCostByDebt(
debt).doubleValue()));
}
LOGGER.info("Metrics saved successfully.");
}
示例4: setUp
import org.sonar.api.measures.Measure; //导入依赖的package包/类
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
project = new Project("test");
session = mock(DatabaseSession.class);
settings = mock(Settings.class);
scoreDecorator = new PointsDecorator(session, project, settings);
mockContext = mock(DecoratorContext.class);
mockContext2 = mock(DecoratorContext.class);
ncloc = mock(Measure.class);
classes = mock(Measure.class);
rulesCompliance = mock(Measure.class);
api = mock(Measure.class);
coverage = mock(Measure.class);
tangle = mock(Measure.class);
resource = mock(Resource.class);
when(resource.getQualifier()).thenReturn(
"NOT_" + Qualifiers.UNIT_TEST_FILE);
utsResource = mock(Resource.class);
when(utsResource.getQualifier()).thenReturn(Qualifiers.UNIT_TEST_FILE);
}
示例5: saveMetrics
import org.sonar.api.measures.Measure; //导入依赖的package包/类
private void saveMetrics(org.sonar.api.resources.File sonarFile, SensorContext context, SourceCode sourceCode) {
for (Issue issue : sourceCode.getIssues()) {
logger.finer("Saving issue: " + issue);
Issuable issuable = perspectives.as(Issuable.class, sonarFile);
if (issuable != null) {
org.sonar.api.issue.Issue sIssue = issuable.newIssueBuilder()
.ruleKey(issue.rule())
.line(issue.line())
.message(issue.message())
.build();
issuable.addIssue(sIssue);
}
}
for (Measure measure : sourceCode.getMeasures()) {
logger.finer("Saving measure: " + measure);
context.saveMeasure(sourceCode.getResource(), measure);
}
for (Dependency dependency : sourceCode.getDependencies()) {
logger.finer("Saving dependency: " + dependency);
context.saveDependency(dependency);
}
}
示例6: decorateResource
import org.sonar.api.measures.Measure; //导入依赖的package包/类
private void decorateResource(DecoratorContext context) {
for (final Alert alert : profile.getAlerts()) {
Measure measure = context.getMeasure(alert.getMetric());
if (measure == null) {
return;
}
Metric.Level level = AlertUtils.getLevel(alert, measure);
if (level == Metric.Level.OK) {
return;
}
LOG.debug("Alert raised on file {}: {} with level {}", context.getResource(), alert.getMetric().getName(), level);
measure.setAlertStatus(level);
measure.setAlertText(getText(alert, level));
context.saveMeasure(measure);
}
}
示例7: fetchMeasure
import org.sonar.api.measures.Measure; //导入依赖的package包/类
private Integer fetchMeasure(SensorContext context, Resource resource, Metric<Integer> metric) {
Measure<Integer> measure = context.getMeasure(resource, metric);
if (measure != null) {
return measure.value();
}
LOGGER.warn("Could not retrieve measure of {} for {}", metric.getKey(), resource);
return null;
}
示例8: mockCurrentCoverage
import org.sonar.api.measures.Measure; //导入依赖的package包/类
private static void mockCurrentCoverage(
SensorContext context, Resource resource,
int linesToCover, int uncoveredLines
) {
double coverage = CoverageUtils.calculateCoverage(linesToCover, uncoveredLines);
when(context.getMeasure(eq(resource), eq(CoreMetrics.LINES_TO_COVER)))
.thenReturn(new Measure<>(CoreMetrics.LINES_TO_COVER, (double) linesToCover));
when(context.getMeasure(eq(resource), eq(CoreMetrics.UNCOVERED_LINES)))
.thenReturn(new Measure<>(CoreMetrics.UNCOVERED_LINES, (double) uncoveredLines));
when(context.getMeasure(eq(resource), eq(CoreMetrics.LINE_COVERAGE)))
.thenReturn(new Measure<>(CoreMetrics.LINE_COVERAGE, coverage));
}
示例9: filter
import org.sonar.api.measures.Measure; //导入依赖的package包/类
@Override
public Collection<Measure> filter(Collection<Measure> aCollection) {
Collection<Measure> theResult = new HashSet<>();
for (Measure theMeasure : aCollection) {
if (!(theMeasure instanceof RuleMeasure)) {
theResult.add(theMeasure);
}
}
return theResult;
}
示例10: saveMetrics
import org.sonar.api.measures.Measure; //导入依赖的package包/类
private void saveMetrics(SensorContext sensorContext, WebSourceCode sourceCode) {
saveComplexityDistribution(sensorContext, sourceCode);
List<Measure> measures = sourceCode.getMeasures();
for (Measure measure : measures) {
sensorContext.saveMeasure(sourceCode.getResource(), measure);
}
List<Violation> violations = sourceCode.getViolations();
for (Violation violation : violations) {
sensorContext.saveViolation(violation);
}
}
示例11: decorate
import org.sonar.api.measures.Measure; //导入依赖的package包/类
public void decorate(Resource resource, DecoratorContext context) {
if (ResourceUtils.isEntity(resource)) {
Measure complexity = context.getMeasure(CoreMetrics.COMPLEXITY);
double value = complexity.getValue().doubleValue();
if (value > this.threshold) {
context.saveMeasure(OnedMetrics.DANGEROUS_COMPLEXITY, Double.valueOf(value));
context.saveMeasure(OnedMetrics.DANGEROUS_FILE_COMPLEXITY, Double.valueOf(value));
}
}
}
示例12: decorate
import org.sonar.api.measures.Measure; //导入依赖的package包/类
public void decorate(Resource resource, DecoratorContext context) {
if (ResourceUtils.isEntity(resource)) {
Measure complexity = context.getMeasure(CoreMetrics.COMPLEXITY);
double value = complexity.getValue().doubleValue();
if (value > this.threshold) {
context.saveMeasure(OnedMetrics.DANGEROUS_FILES, Double.valueOf(1.0D));
}
}
}
示例13: analyse
import org.sonar.api.measures.Measure; //导入依赖的package包/类
public void analyse(Project project, SensorContext sensorContext) {
String baseDirectory = fileSystem.baseDir().toString();
LOG.info("Clojure project detected, running sonar-clojure");
if (fileFinder) {
LOG.info("●▬▬▬▬▬▬▬▬▬● Running file finder ●▬▬▬▬▬▬▬▬▬●");
buildFileProperties(baseDirectory);
}
if (eastwoodLint) {
LOG.info("●▬▬▬▬▬▬▬▬▬● Running Eastwood ●▬▬▬▬▬▬▬▬▬●");
buildEastwoodLintProperties(baseDirectory);
}
if (kibitLint) {
LOG.info("●▬▬▬▬▬▬▬▬▬● Running Kibit ●▬▬▬▬▬▬▬▬▬●");
buildKibitLintProperties(baseDirectory);
}
LOG.info("●▬▬▬▬▬▬▬▬▬● Saving measures ●▬▬▬▬▬▬▬▬▬●");
sensorContext.saveMeasure(new Measure(InspectClojureMetrics.ISSUES_COUNT, (double) totalIssues));
sensorContext.saveMeasure(new Measure(InspectClojureMetrics.ISSUES_LINE, fileLine.buildData()));
sensorContext.saveMeasure(new Measure(InspectClojureMetrics.ISSUES_ERROR, fileError.buildData()));
sensorContext.saveMeasure(new Measure(InspectClojureMetrics.ISSUES_FILE, filePath.buildData()));
sensorContext.saveMeasure(new Measure(InspectClojureMetrics.FILES, files.buildData()));
}
示例14: decorate
import org.sonar.api.measures.Measure; //导入依赖的package包/类
@Override
public void decorate(Resource resource, DecoratorContext context) {
String href = hrefMap.get(resource.getPath());
if (href == null) {
href = "index.html";
}
LOG.trace("Mapping orig report {} --> {}", resource, href);
@SuppressWarnings("rawtypes")
Measure path = new Measure(CtcMetrics.CTC_ORIG_REPORT_NAME);
path.setData(href);
context.saveMeasure(path);
}
示例15: CtcMeasure
import org.sonar.api.measures.Measure; //导入依赖的package包/类
private CtcMeasure(final File source, final Collection<Measure> collection) {
this.source = source;
this.ctcMeasures = collection;
if (source != null && !source.exists()) {
LOG.error("File {} does not exist!", source);
}
if (source != null) {
LOG.trace("AbsoluteFilePath of {} : {}", source, source.getAbsolutePath());
} else {
LOG.trace("PROJECTMEASURE");
}
}