Search in sources :

Example 1 with Project

use of org.sonar.api.resources.Project in project sonarqube by SonarSource.

the class ComponentKeysTest method create_effective_key.

@Test
public void create_effective_key() {
    Project project = new Project(ProjectDefinition.create().setKey("my_project"));
    assertThat(ComponentKeys.createEffectiveKey("my_project", project)).isEqualTo("my_project");
    Directory dir = Directory.create("src/org/foo");
    assertThat(ComponentKeys.createEffectiveKey("my_project", dir)).isEqualTo("my_project:src/org/foo");
    InputFile file = mock(InputFile.class);
    when(file.relativePath()).thenReturn("foo/Bar.php");
    assertThat(ComponentKeys.createEffectiveKey("my_project", file)).isEqualTo("my_project:foo/Bar.php");
}
Also used : Project(org.sonar.api.resources.Project) Directory(org.sonar.api.resources.Directory) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 2 with Project

use of org.sonar.api.resources.Project in project sonarqube by SonarSource.

the class InitializerTest method shouldBeExecutedByDefault.

@Test
public void shouldBeExecutedByDefault() {
    Project project = mock(Project.class);
    assertThat(new FakeInitializer().shouldExecuteOnProject(project)).isTrue();
}
Also used : Project(org.sonar.api.resources.Project) Test(org.junit.Test)

Example 3 with Project

use of org.sonar.api.resources.Project in project sonarqube by SonarSource.

the class PostJobsExecutor method execute.

private void execute(SensorContext context, Collection<PostJob> postJobs) {
    logPostJobs(postJobs);
    Project project = new Project(module.definition());
    for (PostJob postJob : postJobs) {
        LOG.info("Executing post-job {}", ScannerUtils.describe(postJob));
        eventBus.fireEvent(new PostJobExecutionEvent(postJob, true));
        postJob.executeOn(project, context);
        eventBus.fireEvent(new PostJobExecutionEvent(postJob, false));
    }
}
Also used : Project(org.sonar.api.resources.Project) PostJob(org.sonar.api.batch.PostJob)

Example 4 with Project

use of org.sonar.api.resources.Project in project sonarqube by SonarSource.

the class ModuleScanContainer method addCoreComponents.

private void addCoreComponents() {
    add(module.definition(), // still injected by some plugins
    new Project(module.definition()), module, ModuleSettings.class);
    if (getComponentByType(AnalysisMode.class).isIssues()) {
        add(IssuesPhaseExecutor.class, IssuesReports.class);
    } else {
        add(PublishPhaseExecutor.class);
    }
    add(EventBus.class, RuleFinderCompatibility.class, PostJobsExecutor.class, SensorsExecutor.class, InitializersExecutor.class, // file system
    ModuleInputComponentStore.class, FileExclusions.class, ExclusionFilters.class, new MetadataGeneratorProvider(), FileMetadata.class, StatusDetectionFactory.class, LanguageDetection.class, FileIndexer.class, InputFileBuilder.class, FileSystemLogger.class, DefaultModuleFileSystem.class, ModuleFileSystemInitializer.class, QProfileVerifier.class, SensorOptimizer.class, PostJobOptimizer.class, DefaultPostJobContext.class, DefaultSensorStorage.class, DeprecatedSensorContext.class, ScannerExtensionDictionnary.class, IssueFilters.class, CoverageExclusions.class, SensorStrategy.class, // rules
    new RulesProfileProvider(), CheckFactory.class, // issues
    IssuableFactory.class, ModuleIssues.class, org.sonar.api.issue.NoSonarFilter.class, // issue exclusions
    IssueInclusionPatternInitializer.class, IssueExclusionPatternInitializer.class, IssueExclusionsRegexpScanner.class, IssueExclusionsLoader.class, EnforceIssuesFilter.class, IgnoreIssuesFilter.class, // Perspectives
    ScannerPerspectives.class, HighlightableBuilder.class, SymbolizableBuilder.class, DefaultFileLinesContextFactory.class);
}
Also used : Project(org.sonar.api.resources.Project) MetadataGeneratorProvider(org.sonar.scanner.scan.filesystem.MetadataGeneratorProvider) AnalysisMode(org.sonar.api.batch.AnalysisMode) RulesProfileProvider(org.sonar.scanner.rule.RulesProfileProvider)

Example 5 with Project

use of org.sonar.api.resources.Project in project sonarqube by SonarSource.

the class SensorsExecutor method executeSensor.

private void executeSensor(SensorContext context, Sensor sensor) {
    eventBus.fireEvent(new SensorExecutionEvent(sensor, true));
    sensor.analyse(new Project(module.definition()), context);
    eventBus.fireEvent(new SensorExecutionEvent(sensor, false));
}
Also used : Project(org.sonar.api.resources.Project)

Aggregations

Project (org.sonar.api.resources.Project)13 Test (org.junit.Test)7 CheckProject (org.sonar.api.batch.CheckProject)3 PostJob (org.sonar.api.batch.PostJob)3 List (java.util.List)2 BuildBreaker (org.sonar.api.batch.BuildBreaker)2 SensorContext (org.sonar.api.batch.SensorContext)2 Properties (java.util.Properties)1 Before (org.junit.Before)1 BatchExtension (org.sonar.api.BatchExtension)1 CoreProperties (org.sonar.api.CoreProperties)1 AnalysisMode (org.sonar.api.batch.AnalysisMode)1 Initializer (org.sonar.api.batch.Initializer)1 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)1 InputFile (org.sonar.api.batch.fs.InputFile)1 InputComponentTree (org.sonar.api.batch.fs.internal.InputComponentTree)1 RulesProfile (org.sonar.api.profiles.RulesProfile)1 Directory (org.sonar.api.resources.Directory)1 RuleFinder (org.sonar.api.rules.RuleFinder)1 Profiler (org.sonar.api.utils.log.Profiler)1