本文整理汇总了Java中org.sonar.api.batch.fs.internal.DefaultInputModule类的典型用法代码示例。如果您正苦于以下问题:Java DefaultInputModule类的具体用法?Java DefaultInputModule怎么用?Java DefaultInputModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultInputModule类属于org.sonar.api.batch.fs.internal包,在下文中一共展示了DefaultInputModule类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
@Override
public void execute(SensorContext context)
{
if (settings.getBoolean(LicenseCheckPropertyKeys.ACTIVATION_KEY))
{
Set<Dependency> dependencies = new TreeSet<>();
for (Scanner scanner : scanners)
{
dependencies.addAll(scanner.scan(fs.baseDir()));
}
ProjectDefinition project = ((DefaultInputModule) context.module()).definition().getParent();
Set<Dependency> validatedDependencies = validateLicenses.validateLicenses(dependencies, context);
Set<License> usedLicenses = validateLicenses.getUsedLicenses(validatedDependencies, project);
saveDependencies(context, validatedDependencies);
saveLicenses(context, usedLicenses);
}
else
{
LOGGER.info("Scanner is set to inactive. No scan possible.");
}
}
示例2: incrementMetrics
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
private void incrementMetrics(final XMLReportFinding xanFinding,
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
final DefaultInputModule project, final InputFile inputFile) {
final Severity severity = SensorUtil.mkSeverity(xanFinding);
final List<Metric<Serializable>> metrics = mkMetrics(xanFinding.getProblemType());
for (final Metric<Serializable> metric : metrics) {
incrementValueForFileAndProject(metric, inputFile, project, metricValuesAccu);
}
final String matchCode = xanFinding.getMatchCode();
if ("NOT".equals(matchCode)) {
incrementValueForFileAndProject(XanitizerMetrics.getMetricForNewXanFindings(),
inputFile, project, metricValuesAccu);
}
final Metric<Serializable> metricForSeverity = XanitizerMetrics
.getMetricForSeverity(severity);
if (metricForSeverity != null) {
incrementValueForFileAndProject(metricForSeverity, inputFile, project,
metricValuesAccu);
}
}
示例3: addCoreComponents
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
private void addCoreComponents() {
add(
new DefaultInputModule("sonarlint"),
NoOpFileLinesContextFactory.class,
// temp
new AnalysisTempFolderProvider(),
// file system
PathResolver.class,
// lang
Languages.class,
DefaultLanguagesRepository.class,
AnalysisSettings.class,
PhaseExecutor.class,
// file system
InputPathCache.class,
InputFileBuilder.class,
FileMetadata.class,
LanguageDetection.class,
FileIndexer.class,
SonarLintFileSystem.class,
SensorOptimizer.class,
DefaultSensorContext.class,
DefaultSensorStorage.class,
ScannerExtensionDictionnary.class,
// rules
CheckFactory.class,
// issues
org.sonar.api.issue.NoSonarFilter.class);
}
示例4: checkForLicenses
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
private void checkForLicenses(SensorContext context, Dependency dependency)
{
DefaultInputModule module = (DefaultInputModule) context.module();
for (License license : licenseService.getLicenses(module.definition().getParent()))
{
if (license.getIdentifier().equals(dependency.getLicense()))
{
if ("false".equals(license.getStatus()))
{
LOGGER.info("Dependency "
+ dependency.getName()
+ " uses a not allowed licooense "
+ dependency.getLicense());
NewIssue issue = context
.newIssue()
.forRule(RuleKey.of(LicenseCheckMetrics.LICENSE_CHECK_KEY,
LicenseCheckMetrics.LICENSE_CHECK_NOT_ALLOWED_LICENSE_KEY))
.at(new DefaultIssueLocation()
.on(context.module())
.message("Dependency "
+ dependency.getName()
+ " uses a not allowed license "
+ dependency.getLicense()));
issue.save();
}
}
}
}
示例5: createContext
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
private SensorContext createContext()
{
SensorContext context = mock(SensorContext.class);
DefaultInputModule inputModule = mock(DefaultInputModule.class);
when(inputModule.definition()).thenReturn(projectDefinition);
when(context.module()).thenReturn(inputModule);
return context;
}
示例6: execute
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
@Override
public void execute(SensorContext sensorContext) {
if (!shouldExecute()) {
return;
}
final DefaultInputModule project = (DefaultInputModule) sensorContext.module();
LOG.info("Reading Xanitizer findings from '" + reportFile + "' for project '"
+ project.getName() + "'");
final XMLReportParser parser = new XMLReportParser();
final XMLReportContent content;
try {
content = parser.parse(reportFile);
} catch (final Exception ex) {
LOG.error("Exception caught while parsing Xanitizer XML report file '" + reportFile
+ "'.", ex);
return;
}
final long analysisEndDate = content.getAnalysisEndDate();
if (analysisEndDate == -1) {
LOG.warn(
"No Xanitizer analysis results found - Check if Xanitizer analysis has been executed!");
return;
}
final String analysisDatePresentation = SensorUtil
.convertToDateWithTimeString(new Date(analysisEndDate));
LOG.info("Processing Xanitizer analysis results of " + analysisDatePresentation);
LOG.debug("Create issues for " + content.getXMLReportFindings().size()
+ " Xanitizer findings.");
createIssuesAndMeasures(project, sensorContext, content);
LOG.info("Created " + alreadyCreatedIssues.size() + " issues.");
}
示例7: generateIssueForFinding
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
private void generateIssueForFinding(final XMLReportFinding xanFinding,
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
final DefaultInputModule project, final SensorContext sensorContext) {
if (!activeXanRuleNames.contains(xanFinding.getProblemType().name())) {
LOG.debug(SKIP_FINDING_MESSAGE + xanFinding.getFindingID()
+ ": Rule for corresponding problem type is disabled.");
return;
}
final InputFile inputFile = mkInputFileOrNull(xanFinding.getLocation(), sensorContext);
if (inputFile == null) {
/*
* Do not generate issues without code location
*/
LOG.debug(SKIP_FINDING_MESSAGE + xanFinding.getFindingID()
+ ": Corresponding file could not be found in project.");
return;
}
final boolean issueCreated = createNewIssue(inputFile, xanFinding, sensorContext);
if (issueCreated) {
incrementMetrics(xanFinding, metricValuesAccu, project, inputFile);
}
}
示例8: initializeMetrics
import org.sonar.api.batch.fs.internal.DefaultInputModule; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void initializeMetrics(
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
final DefaultInputModule project) {
for (Metric<Serializable> metric : new XanitizerMetrics().getMetrics()) {
initializeMetric(metricValuesAccu, project, metric);
}
}