Search in sources :

Example 46 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class RegisterPermissionTemplates method start.

@Override
public void start() {
    Profiler profiler = Profiler.create(Loggers.get(getClass())).startInfo("Register permission templates");
    try (DbSession dbSession = dbClient.openSession(false)) {
        Optional<String> defaultProjectTemplate = dbClient.internalPropertiesDao().selectByKey(dbSession, DEFAULT_PROJECT_TEMPLATE);
        if (!defaultProjectTemplate.isPresent()) {
            PermissionTemplateDto defaultTemplate = getOrInsertDefaultTemplate(dbSession);
            dbClient.internalPropertiesDao().save(dbSession, DEFAULT_PROJECT_TEMPLATE, defaultTemplate.getUuid());
            dbSession.commit();
        }
    }
    profiler.stopDebug();
}
Also used : DbSession(org.sonar.db.DbSession) PermissionTemplateDto(org.sonar.db.permission.template.PermissionTemplateDto) Profiler(org.sonar.api.utils.log.Profiler)

Example 47 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class MetricsRepositoryProvider method provide.

@Bean("MetricsRepository")
public MetricsRepository provide(MetricsRepositoryLoader loader) {
    Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
    MetricsRepository metricsRepository = loader.load();
    profiler.stopInfo();
    return metricsRepository;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) Bean(org.springframework.context.annotation.Bean)

Example 48 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class ReferenceBranchSupplier method get.

@CheckForNull
public String get() {
    // branches will be empty in CE
    if (branchConfiguration.isPullRequest() || branches.isEmpty()) {
        return null;
    }
    Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG_WS);
    String branchName = branchConfiguration.branchName() != null ? branchConfiguration.branchName() : branches.defaultBranchName();
    NewCodePeriods.ShowWSResponse newCode = newCodePeriodLoader.load(project.key(), branchName);
    profiler.stopInfo();
    if (newCode.getType() != NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH) {
        return null;
    }
    String referenceBranchName = newCode.getValue();
    if (branchName.equals(referenceBranchName)) {
        LOG.warn("New Code reference branch is set to the branch being analyzed. Skipping the computation of New Code");
        return null;
    }
    return referenceBranchName;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) NewCodePeriods(org.sonarqube.ws.NewCodePeriods) CheckForNull(javax.annotation.CheckForNull)

Example 49 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class ProjectRepositoriesSupplier method get.

public ProjectRepositories get() {
    if (project == null) {
        Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
        project = loader.load(scannerProperties.getProjectKey(), branchConfig.referenceBranchName());
        profiler.stopInfo();
    }
    return project;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler)

Example 50 with Profiler

use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.

the class QualityProfilesProvider method provide.

@Bean("QualityProfiles")
public QualityProfiles provide(QualityProfileLoader loader, ScannerProperties props) {
    Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
    QualityProfiles profiles = new QualityProfiles(loader.load(props.getProjectKey()));
    profiler.stopInfo();
    return profiles;
}
Also used : QualityProfiles(org.sonar.scanner.rule.QualityProfiles) Profiler(org.sonar.api.utils.log.Profiler) Bean(org.springframework.context.annotation.Bean)

Aggregations

Profiler (org.sonar.api.utils.log.Profiler)56 Bean (org.springframework.context.annotation.Bean)7 HashMap (java.util.HashMap)6 IOException (java.io.IOException)5 DbSession (org.sonar.db.DbSession)5 GetRequest (org.sonarqube.ws.client.GetRequest)5 File (java.io.File)3 Reader (java.io.Reader)3 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)3 InputStream (java.io.InputStream)2 Path (java.nio.file.Path)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 CheckForNull (javax.annotation.CheckForNull)2 OptInCaching (org.picocontainer.behaviors.OptInCaching)2 ReflectionLifecycleStrategy (org.picocontainer.lifecycle.ReflectionLifecycleStrategy)2 NullComponentMonitor (org.picocontainer.monitors.NullComponentMonitor)2 InputFile (org.sonar.api.batch.fs.InputFile)2 NewRule (org.sonar.api.batch.rule.internal.NewRule)2 RulesBuilder (org.sonar.api.batch.rule.internal.RulesBuilder)2