当前位置: 首页>>代码示例>>Java>>正文


Java DefaultInputModule类代码示例

本文整理汇总了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.");
    }
}
 
开发者ID:porscheinformatik,项目名称:sonarqube-licensecheck,代码行数:25,代码来源:LicenseCheckSensor.java

示例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);
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:24,代码来源:XanitizerSensor.java

示例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);
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:39,代码来源:AnalysisContainer.java

示例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();
            }
        }
    }
}
 
开发者ID:porscheinformatik,项目名称:sonarqube-licensecheck,代码行数:30,代码来源:ValidateLicenses.java

示例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;
}
 
开发者ID:porscheinformatik,项目名称:sonarqube-licensecheck,代码行数:9,代码来源:ValidateLicensesTest.java

示例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.");
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:36,代码来源:XanitizerSensor.java

示例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);
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:28,代码来源:XanitizerSensor.java

示例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);
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:10,代码来源:XanitizerSensor.java


注:本文中的org.sonar.api.batch.fs.internal.DefaultInputModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。