use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.
the class RegisterQualityProfiles method renameOutdatedProfiles.
/**
* The Quality profiles created by users should be renamed when they have the same name
* as the built-in profile to be persisted.
* <p>
* When upgrading from < 6.5 , all existing profiles are considered as "custom" (created
* by users) because the concept of built-in profile is not persisted. The "Sonar way" profiles
* are renamed to "Sonar way (outdated copy) in order to avoid conflicts with the new
* built-in profile "Sonar way", which has probably different configuration.
*/
private void renameOutdatedProfiles(DbSession dbSession, BuiltInQProfile profile) {
Collection<String> uuids = dbClient.qualityProfileDao().selectUuidsOfCustomRulesProfiles(dbSession, profile.getLanguage(), profile.getName());
if (uuids.isEmpty()) {
return;
}
Profiler profiler = Profiler.createIfDebug(Loggers.get(getClass())).start();
String newName = profile.getName() + " (outdated copy)";
LOGGER.info("Rename Quality profiles [{}/{}] to [{}]", profile.getLanguage(), profile.getName(), newName);
dbClient.qualityProfileDao().renameRulesProfilesAndCommit(dbSession, uuids, newName);
profiler.stopDebug(format("%d Quality profiles renamed to [%s]", uuids.size(), newName));
}
use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.
the class BuiltInQProfileRepositoryImpl method initialize.
@Override
public void initialize() {
checkState(qProfiles == null, "initialize must be called only once");
Profiler profiler = Profiler.create(LOGGER).startInfo("Load quality profiles");
BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context();
for (BuiltInQualityProfilesDefinition definition : definitions) {
definition.define(context);
}
Map<String, Map<String, BuiltInQualityProfile>> rulesProfilesByLanguage = validateAndClean(context);
this.qProfiles = toFlatList(rulesProfilesByLanguage);
ensureAllLanguagesHaveAtLeastOneBuiltInQP();
profiler.stopDebug();
}
use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.
the class ScannerPluginInstaller method listInstalledPlugins.
/**
* Gets information about the plugins installed on server (filename, checksum)
*/
private InstalledPlugin[] listInstalledPlugins() {
Profiler profiler = Profiler.create(LOG).startInfo("Load plugins index");
GetRequest getRequest = new GetRequest(PLUGINS_WS_URL);
InstalledPlugins installedPlugins;
try (Reader reader = wsClient.call(getRequest).contentReader()) {
installedPlugins = new Gson().fromJson(reader, InstalledPlugins.class);
} catch (Exception e) {
throw new IllegalStateException("Fail to parse response of " + PLUGINS_WS_URL, e);
}
profiler.stopInfo();
return installedPlugins.plugins;
}
use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.
the class DefaultScannerWsClient method call.
/**
* If an exception is not thrown, the response needs to be closed by either calling close() directly, or closing the
* body content's stream/reader.
*
* @throws IllegalStateException if the request could not be executed due to a connectivity problem or timeout. Because networks can
* fail during an exchange, it is possible that the remote server accepted the request before the failure
* @throws MessageException if there was a problem with authentication or if a error message was parsed from the response.
* @throws HttpException if the response code is not in range [200..300). Consider using {@link #createErrorMessage(HttpException)} to create more relevant messages for the users.
*/
public WsResponse call(WsRequest request) {
checkState(!globalMode.isMediumTest(), "No WS call should be made in medium test mode");
Profiler profiler = Profiler.createIfDebug(LOG).start();
WsResponse response = target.wsConnector().call(request);
profiler.stopDebug(format("%s %d %s", request.getMethod(), response.code(), response.requestUrl()));
failIfUnauthorized(response);
return response;
}
use of org.sonar.api.utils.log.Profiler in project sonarqube by SonarSource.
the class ProjectPullRequestsProvider method provide.
@Bean("ProjectPullRequests")
public ProjectPullRequests provide(@Nullable ProjectPullRequestsLoader loader, ScannerProperties scannerProperties) {
if (loader == null) {
return new ProjectPullRequests(Collections.emptyList());
}
Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
ProjectPullRequests pullRequests = loader.load(scannerProperties.getProjectKey());
profiler.stopInfo();
return pullRequests;
}
Aggregations