private static boolean isSonarLint(SensorContext context) { return context.runtime().getProduct() == SonarProduct.SONARLINT; }
private boolean isSonarLintContext() { return sensorContext.runtime().getProduct() == SonarProduct.SONARLINT; }
private static boolean isSonarLint(SensorContext context) { return context.runtime().getProduct() == SonarProduct.SONARLINT; } }
public boolean isSonarLintContext() { return context.runtime().getProduct() == SonarProduct.SONARLINT; }
private static boolean inSonarQube(SensorContext context) { return context.runtime().getProduct() != SonarProduct.SONARLINT; }
private static boolean inSonarQube(SensorContext context) { return context.runtime().getProduct() != SonarProduct.SONARLINT; }
public boolean isSonarLintContext() { return context.runtime().getProduct() == SonarProduct.SONARLINT; }
private boolean isSonarLintContext() { return sensorContext.runtime().getProduct() == SonarProduct.SONARLINT; }
private static boolean isSonarLint(SensorContext context) { return context.runtime().getProduct() == SonarProduct.SONARLINT; }
@Override public void execute(SensorContext context) { if (context.runtime().getProduct() == SonarProduct.SONARLINT) return; computeBaseMetrics(context); }
private void executeAnalytics(SensorContext context) { if (!settings.useAnalytics()) return; StringBuilder data = new StringBuilder(String.format( // NOSONAR Influx requires LF "proparse,product=%1$s,sid=%2$s files=%3$d,failures=%4$d,parseTime=%5$d,maxParseTime=%6$d,version=\"%7$s\",ncloc=%8$d\n", context.runtime().getProduct().toString().toLowerCase(), OpenEdgeProjectHelper.getServerId(context), numFiles, numFailures, parseTime, maxParseTime, context.runtime().getApiVersion().toString(), ncLocs)); for (Entry<String, Long> entry : ruleTime.entrySet()) { data.append(String.format("rule,product=%1$s,sid=%2$s,rulename=%3$s ruleTime=%4$d\n", // NOSONAR context.runtime().getProduct().toString().toLowerCase(), OpenEdgeProjectHelper.getServerId(context), entry.getKey(), entry.getValue())); } try { final URL url = new URL("http://sonar-analytics.rssw.eu/write?db=sonar"); HttpURLConnection connx = (HttpURLConnection) url.openConnection(); connx.setRequestMethod("POST"); connx.setConnectTimeout(2000); connx.setDoOutput(true); DataOutputStream wr = new DataOutputStream(connx.getOutputStream()); wr.writeBytes(data.toString()); wr.flush(); wr.close(); connx.getResponseCode(); } catch (IOException uncaught) { LOG.debug("Unable to send analytics: {}", uncaught.getMessage()); } }
@Override public void execute(SensorContext context) { List<InputFile> inputFiles = new ArrayList<>(); fileSystem.inputFiles(mainFilesPredicate).forEach(inputFiles::add); if (inputFiles.isEmpty()) { return; } boolean isSonarLintContext = context.runtime().getProduct() == SonarProduct.SONARLINT; ProgressReport progressReport = new ProgressReport("Report about progress of XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile, isSonarLintContext); progressReport.nextFile(); } } finally { if (!cancelled) { progressReport.stop(); } else { progressReport.cancel(); } } }
/** * Create PageScanner with Visitors. */ private HtmlAstScanner setupScanner(SensorContext context) { List<DefaultNodeVisitor> visitors = new ArrayList<>(); if (context.runtime().getProduct() != SonarProduct.SONARLINT) { visitors.add(new HtmlTokensVisitor(context)); } visitors.add(new PageCountLines()); visitors.add(new ComplexityVisitor()); visitors.add(new NoSonarScanner(noSonarFilter)); HtmlAstScanner scanner = new HtmlAstScanner(visitors); for (Object check : checks.all()) { ((AbstractPageCheck) check).setRuleKey(checks.ruleKey(check)); scanner.addVisitor((AbstractPageCheck) check); } return scanner; }
public void initializeLicense(SensorContext context) { String permId = (context.runtime().getProduct() == SonarProduct.SONARLINT ? "sonarlint-" : "") + OpenEdgeProjectHelper.getServerId(context); for (License entry : licenseRegistrar.getLicenses()) { if (permId.equals(entry.getPermanentId())) { LOG.info("Repository '{}' associated with {} license permanent ID '{}' - Customer '{}' - Expiration date {}", entry.getRepositoryName(), entry.getType().toString(), entry.getPermanentId(), entry.getCustomerName(), LocalDateTime.ofEpochSecond(entry.getExpirationDate() / 1000, 0, ZoneOffset.UTC).format( DateTimeFormatter.ISO_LOCAL_DATE_TIME)); } } }
public void initializeChecks(SensorContext context) { if (initialized) return; String permId = (context.runtime().getProduct() == SonarProduct.SONARLINT ? "sonarlint-" : "") + OpenEdgeProjectHelper.getServerId(context); // Proparse and XREF rules for (ActiveRule rule : context.activeRules().findByLanguage(Constants.LANGUAGE_KEY)) { OpenEdgeCheck<?> lint = initializeCheck(context, rule, permId); if ((lint != null) && (lint.getCheckType() == CheckType.PROPARSE)) { ppChecksMap.put(rule, (OpenEdgeProparseCheck) lint); } } // DB rules for (ActiveRule rule : context.activeRules().findByLanguage(Constants.DB_LANGUAGE_KEY)) { OpenEdgeCheck<?> lint = initializeCheck(context, rule, permId); if ((lint != null) && (lint.getCheckType() == CheckType.DUMP_FILE)) { dfChecksMap.put(rule, (OpenEdgeDumpFileCheck) lint); } } initialized = true; }
@Override public void execute(SensorContext context) { if (context.runtime().getProduct() == SonarProduct.SONARLINT) return; for (InputFile file : context.fileSystem().inputFiles( context.fileSystem().predicates().hasLanguage(Constants.DB_LANGUAGE_KEY))) { LOG.debug("DF syntax highlight on {}", file); try { highlightFile(context, file); } catch (RuntimeException | IOException caught) { LOG.error("Unable to lex file " + file, caught); } } }
@Override public void execute(SensorContext context) { if (context.runtime().getProduct() == SonarProduct.SONARLINT) return; RefactorSession session = settings.getProparseSession(); for (InputFile file : context.fileSystem().inputFiles( context.fileSystem().predicates().hasLanguage(Constants.LANGUAGE_KEY))) { LOG.debug("Syntax highlight on {}", file); try { highlightFile(context, session, file); } catch (UncheckedIOException | ProparseRuntimeException caught) { if (caught.getCause() instanceof XCodedFileException) { LOG.error("Unable to highlight xcode'd file '{}", file); } else { LOG.error("Unable to lex file '{}'", file, caught); } } } }
} else { TextRange range = targetFile.selectLine(lineNumber); if (IS_WINDOWS && (getContext().runtime().getProduct() == SonarProduct.SONARLINT) && (range.end().lineOffset() > 1)) { location.at(targetFile.newRange(lineNumber, 0, lineNumber, range.end().lineOffset() - 1)); } else {
} else { TextRange range = targetFile.selectLine(lineNumber); if (IS_WINDOWS && (getContext().runtime().getProduct() == SonarProduct.SONARLINT) && (range.end().lineOffset() > 1)) { location.at(targetFile.newRange(lineNumber, 0, lineNumber, range.end().lineOffset() - 1)); } else {
@Override public void execute(SensorContext context) { if (context.runtime().getProduct() == SonarProduct.SONARLINT) return;