private GlobalAnalysisMode createMode(String key, String value) { Map<String, String> map = new HashMap<>(); if (key != null) { map.put(key, value); } ScannerProperties props = new ScannerProperties(map); return new GlobalAnalysisMode(props); } }
@Override public void start() { reportDir = moduleHierarchy.root().getWorkDir().resolve("scanner-report"); writer = new ScannerReportWriter(reportDir.toFile()); contextPublisher.init(writer); if (!analysisMode.isIssues() && !analysisMode.isMediumTest()) { String publicUrl = server.getPublicRootUrl(); if (HttpUrl.parse(publicUrl) == null) { throw MessageException.of("Failed to parse public URL set in SonarQube server: " + publicUrl); } } }
public ScannerPluginPredicate(Configuration settings, GlobalAnalysisMode mode) { this.mode = mode; if (mode.isPreview() || mode.isIssues()) { // These default values are not supported by Settings because the class CorePlugin // is not loaded yet. whites.addAll(propertyValues(settings, CoreProperties.PREVIEW_INCLUDE_PLUGINS, CoreProperties.PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE)); blacks.addAll(propertyValues(settings, CoreProperties.PREVIEW_EXCLUDE_PLUGINS, CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE)); } if (!whites.isEmpty()) { LOG.info("Include plugins: " + COMMA_JOINER.join(whites)); } if (!blacks.isEmpty()) { LOG.info("Exclude plugins: " + COMMA_JOINER.join(blacks)); } }
@Override public boolean isIssues() { return analysisMode.isIssues(); }
@Override public boolean isPreview() { return analysisMode.isPreview(); }
@Override public boolean isPublish() { return analysisMode.isPublish(); } }
public void execute() { String taskId = null; File report = generateReportFile(); if (properties.shouldKeepReport()) { LOG.info("Analysis report generated in " + reportDir); } if (!analysisMode.isMediumTest()) { taskId = upload(report); } logSuccess(taskId); }
public GlobalAnalysisMode(ScannerProperties props) { String mode = props.property(CoreProperties.ANALYSIS_MODE); validate(mode); issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode) || CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode); mediumTestMode = "true".equals(props.property(MEDIUM_TEST_ENABLED)); if (preview) { LOG.info("Preview mode"); LOG.warn("The use of the preview mode (sonar.analysis.mode=preview) is deprecated. This mode will be dropped in the future."); } else if (issues) { LOG.info("Issues mode"); LOG.warn("The use of the issues mode (sonar.analysis.mode=issues) is deprecated. This mode will be dropped in the future."); } if (mediumTestMode) { LOG.info("Medium test mode"); } }
private void load() { String scanAllStr = analysisProps.get(KEY_SCAN_ALL); scanAllFiles = !analysisMode.isIssues() || "true".equals(scanAllStr); }
@Override public boolean apply(@Nonnull String pluginKey) { if (BUILDBREAKER_PLUGIN_KEY.equals(pluginKey) && mode.isPreview()) { LOG.info("Build Breaker plugin is no more supported in preview mode"); return false; } if (whites.isEmpty()) { return blacks.isEmpty() || !blacks.contains(pluginKey); } return whites.contains(pluginKey); }
@Override public boolean isPublish() { return analysisMode.isPublish(); } }
/** * 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) { Preconditions.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; }
public GlobalAnalysisMode(ScannerProperties props) { String mode = props.property(CoreProperties.ANALYSIS_MODE); validate(mode); issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode) || CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode); mediumTestMode = "true".equals(props.property(MEDIUM_TEST_ENABLED)); if (preview) { LOG.info("Preview mode"); LOG.warn("The use of the preview mode (sonar.analysis.mode=preview) is deprecated. This mode will be dropped in the future."); } else if (issues) { LOG.info("Issues mode"); LOG.warn("The use of the issues mode (sonar.analysis.mode=issues) is deprecated. This mode will be dropped in the future."); } if (mediumTestMode) { LOG.info("Medium test mode"); } }
private boolean isIssuesMode() { return getComponentByType(GlobalAnalysisMode.class).isIssues(); }
public ScannerPluginPredicate(Configuration settings, GlobalAnalysisMode mode) { this.mode = mode; if (mode.isPreview() || mode.isIssues()) { // These default values are not supported by Settings because the class CorePlugin // is not loaded yet. whites.addAll(propertyValues(settings, CoreProperties.PREVIEW_INCLUDE_PLUGINS, CoreProperties.PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE)); blacks.addAll(propertyValues(settings, CoreProperties.PREVIEW_EXCLUDE_PLUGINS, CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE)); } if (!whites.isEmpty()) { LOG.info("Include plugins: " + COMMA_JOINER.join(whites)); } if (!blacks.isEmpty()) { LOG.info("Exclude plugins: " + COMMA_JOINER.join(blacks)); } }
if (analysisMode.isIssues()) { getComponentByType(IssueTransition.class).execute(); getComponentByType(JSONReport.class).execute(); if (analysisMode.isMediumTest()) { getComponentByType(AnalysisObservers.class).notifyEndOfScanTask();
@Override protected void doBeforeStart() { ScannerProperties scannerProps = new ScannerProperties(scannerProperties); GlobalAnalysisMode globalMode = new GlobalAnalysisMode(scannerProps); add(scannerProps); add(globalMode); addBootstrapComponents(); }