本文整理汇总了Java中org.sonarqube.ws.WsMeasures.Measure类的典型用法代码示例。如果您正苦于以下问题:Java Measure类的具体用法?Java Measure怎么用?Java Measure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Measure类属于org.sonarqube.ws.WsMeasures包,在下文中一共展示了Measure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: should_succeed_with_self_contained_jre_despite_rubbish_java_home
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@Test
public void should_succeed_with_self_contained_jre_despite_rubbish_java_home() throws IOException, InterruptedException {
String projectKey = "java:basedir-with-source";
orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
orchestrator.getServer().provisionProject(projectKey, "Basedir with source");
orchestrator.getServer().associateProjectToQualityProfile(projectKey, "java", "sonar-way");
File projectDir = new File("projects/basedir-with-source");
SonarScanner build = newScanner(projectDir, "sonar.projectKey", projectKey)
.setEnvironmentVariable("JAVA_HOME", "nonexistent")
.useNative();
orchestrator.executeBuild(build, true);
Map<String, Measure> projectMeasures = getMeasures(projectKey, "files", "ncloc");
assertThat(parseInt(projectMeasures.get("files").getValue())).isEqualTo(1);
assertThat(parseInt(projectMeasures.get("ncloc").getValue())).isGreaterThan(1);
}
示例2: MeasureHolder
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
/**
* Constructs a MeasureHolder from a Measure object.
*
* @param measure used to retrieve the metric name for which the MeasureHolder is built
*/
@SuppressWarnings("unchecked")
public MeasureHolder(final Measure measure) {
final Metric<Serializable> metric = CoreMetrics.getMetric(measure.getMetric());
this.metricName = metric.getName()
.replace(" (%)", "")
.toLowerCase();
String tempValue = null;
if (!measure.hasValue()) {
if (measure.hasPeriods()) {
final PeriodsValue periods = measure.getPeriods();
final PeriodValue periodValue = periods.getPeriodsValue(0);
tempValue = periodValue.getValue();
}
} else {
tempValue = measure.getValue();
}
this.value = tempValue == null ? NA : tempValue + (metric.isPercentageType() ? "%" : "");
}
示例3: getMeasures
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@CheckForNull
static Map<String, Measure> getMeasures(String componentKey, String... metricKeys) {
return newWsClient().measures().component(new ComponentWsRequest()
.setComponentKey(componentKey)
.setMetricKeys(asList(metricKeys)))
.getComponent().getMeasuresList()
.stream()
.collect(Collectors.toMap(Measure::getMetric, Function.identity()));
}
示例4: scan_java_sources
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
/**
* No bytecode, only sources
*/
@Test
public void scan_java_sources() {
orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
orchestrator.getServer().provisionProject("java:sample", "Java Sample, with comma");
orchestrator.getServer().associateProjectToQualityProfile("java:sample", "java", "sonar-way");
SonarScanner build = newScanner(new File("projects/java-sample"))
.setProperty("sonar.verbose", "true");
// SONARPLUGINS-3061
// Add a trailing slash
build.setProperty("sonar.host.url", orchestrator.getServer().getUrl() + "/");
orchestrator.executeBuild(build);
Component project = getComponent("java:sample");
assertThat(project.getName()).isEqualTo("Java Sample, with comma");
assertThat(project.getDescription()).isEqualTo("This is a Java sample");
Map<String, Measure> projectMeasures = getMeasures("java:sample", "files", "ncloc", "classes", "violations");
// SONARPLUGINS-2399
assertThat(parseInt(projectMeasures.get("files").getValue())).isEqualTo(2);
assertThat(parseInt(projectMeasures.get("classes").getValue())).isEqualTo(2);
assertThat(parseInt(projectMeasures.get("ncloc").getValue())).isGreaterThan(10);
assertThat(parseInt(projectMeasures.get("violations").getValue())).isGreaterThan(0);
Component file = getComponent("java:sample:src/basic/Hello.java");
assertThat(file.getName()).isEqualTo("Hello.java");
Map<String, Measure> fileMeasures = getMeasures("java:sample:src/basic/Hello.java", "files", "ncloc", "classes", "violations");
assertThat(parseInt(fileMeasures.get("ncloc").getValue())).isEqualTo(7);
assertThat(parseInt(fileMeasures.get("violations").getValue())).isGreaterThan(0);
}
示例5: scan_java_sources_and_bytecode
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@Test
public void scan_java_sources_and_bytecode() {
orchestrator.getServer().restoreProfile(ResourceLocation.create("/requires-bytecode-profile.xml"));
orchestrator.getServer().provisionProject("java:bytecode", "Java Bytecode Sample");
orchestrator.getServer().associateProjectToQualityProfile("java:bytecode", "java", "requires-bytecode");
SonarScanner build = newScanner(new File("projects/java-bytecode"));
orchestrator.executeBuild(build);
Component project = getComponent("java:bytecode");
assertThat(project.getName()).isEqualTo("Java Bytecode Sample");
Map<String, Measure> projectMeasures = getMeasures("java:bytecode", "violations");
// the squid rules enabled in sonar-way-profile do not exist in SQ 3.0
assertThat(parseInt(projectMeasures.get("violations").getValue())).isGreaterThan(0);
assertThat(getMeasureAsInteger("java:bytecode:src/HasFindbugsViolation.java", "violations")).isGreaterThan(0);
// findbugs is executed on bytecode
List<Issue> issues = orchestrator.getServer().wsClient().issueClient().find(IssueQuery.create().componentRoots("java:bytecode").rules("squid:S1147")).list();
assertThat(issues).hasSize(1);
assertThat(issues.get(0).ruleKey()).isEqualTo("squid:S1147");
// Squid performs analysis of dependencies
issues = orchestrator.getServer().wsClient().issueClient().find(IssueQuery.create().componentRoots("java:bytecode").rules("squid:CallToDeprecatedMethod")).list();
assertThat(issues).hasSize(1);
assertThat(issues.get(0).ruleKey()).isEqualTo("squid:CallToDeprecatedMethod");
}
示例6: basedir_contains_java_sources
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@Test
public void basedir_contains_java_sources() {
orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
orchestrator.getServer().provisionProject("java:basedir-with-source", "Basedir with source");
orchestrator.getServer().associateProjectToQualityProfile("java:basedir-with-source", "java", "sonar-way");
SonarScanner build = newScanner(new File("projects/basedir-with-source"));
orchestrator.executeBuild(build);
Map<String, Measure> projectMeasures = getMeasures("java:basedir-with-source", "files", "ncloc");
assertThat(parseInt(projectMeasures.get("files").getValue())).isEqualTo(1);
assertThat(parseInt(projectMeasures.get("ncloc").getValue())).isGreaterThan(1);
}
示例7: should_support_simple_project_keys
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
/**
* Replace the maven format groupId:artifactId by a single key
*/
@Test
public void should_support_simple_project_keys() {
orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
orchestrator.getServer().provisionProject("SAMPLE", "Java Sample, with comma");
orchestrator.getServer().associateProjectToQualityProfile("SAMPLE", "java", "sonar-way");
SonarScanner build = newScanner(new File("projects/java-sample"))
.setProjectKey("SAMPLE");
orchestrator.executeBuild(build);
Map<String, Measure> projectMeasures = getMeasures("SAMPLE", "files", "ncloc");
assertThat(parseInt(projectMeasures.get("files").getValue())).isEqualTo(2);
assertThat(parseInt(projectMeasures.get("ncloc").getValue())).isGreaterThan(1);
}
示例8: run_from_external_location
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@Test
public void run_from_external_location() throws IOException {
File tempDir = temp.newFolder();
SonarScanner build = newScanner(tempDir)
.setProperty("sonar.projectBaseDir", new File("projects/java-sample").getAbsolutePath())
.addArguments("-e");
orchestrator.executeBuild(build);
assertThat(getComponent("java:sample").getDescription()).isEqualTo("This is a Java sample");
Map<String, Measure> projectMeasures = getMeasures("java:sample", "files", "ncloc", "classes", "violations");
assertThat(projectMeasures.values().stream().filter(measure -> measure.getValue() != null).collect(Collectors.toList())).hasSize(4);
}
示例9: getMeasureAsInt
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
private Integer getMeasureAsInt(String componentKey, String metricKey) {
Measure measure = getMeasure(componentKey, metricKey);
return (measure == null) ? null : Integer.parseInt(measure.getValue());
}
示例10: getMeasureAsInteger
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@CheckForNull
static Integer getMeasureAsInteger(String componentKey, String metricKey) {
Measure measure = getMeasure(componentKey, metricKey);
return (measure == null) ? null : Integer.parseInt(measure.getValue());
}
示例11: getMeasureAsDouble
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@CheckForNull
static Double getMeasureAsDouble(String componentKey, String metricKey) {
Measure measure = getMeasure(componentKey, metricKey);
return (measure == null) ? null : Double.parseDouble(measure.getValue());
}
示例12: getFileMeasure
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
private Measure getFileMeasure(String metricKey) {
return getMeasure(FILE_TOKEN_PARSER, metricKey.trim());
}
示例13: getMeasureAsInt
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@CheckForNull
static Integer getMeasureAsInt(Orchestrator orchestrator, String componentKey, String metricKey) {
Measure measure = getMeasure(orchestrator, componentKey, metricKey);
return (measure == null) ? null : Integer.parseInt(measure.getValue());
}
示例14: getMeasureAsDouble
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
@CheckForNull
static Double getMeasureAsDouble(Orchestrator orchestrator, String componentKey, String metricKey) {
Measure measure = getMeasure(orchestrator, componentKey, metricKey);
return (measure == null) ? null : Double.parseDouble(measure.getValue());
}
示例15: getProjectMeasure
import org.sonarqube.ws.WsMeasures.Measure; //导入依赖的package包/类
private Measure getProjectMeasure(String metricKey) {
return getMeasure(orchestrator, PROJECT, metricKey);
}