@Override public void execute(SensorContext context) { for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguages(Xoo.KEY, Xoo2.KEY))) { File ioFile = file.file(); File measureFile = new File(ioFile.getParentFile(), ioFile.getName() + MEASURES_EXTENSION); processFileMeasures(file, measureFile, context); InputDir inputDir = context.fileSystem().inputDir(ioFile.getParentFile()); if (inputDir != null) { processFileMeasures(inputDir, new File(ioFile.getParentFile(), "folder" + MEASURES_EXTENSION), context); } } processFileMeasures(context.module(), new File(context.fileSystem().baseDir(), "module" + MEASURES_EXTENSION), context); } }
/** * Returns a java.io.File for the given path. * If path is not absolute, returns a File with project base directory as parent path. */ protected File getIOFile(String path) { File file = new File(path); if (!file.isAbsolute()) { file = new File(fileSystem.baseDir(), path); } return file; }
/** * Returns a java.io.File for the given path. * If path is not absolute, returns a File with module base directory as parent path. */ private static File getIOFile(FileSystem fileSystem, String path) { File file = new File(path); if (!file.isAbsolute()) { file = new File(fileSystem.baseDir(), path); } return file; }
@CheckForNull private static File getFileFromPath(FileSystem fs, PathResolver pathResolver, String path) { try { return pathResolver.relativeFile(fs.baseDir(), path); } catch (Exception e) { // exceptions on file not found was only occurring with SQ 5.6 LTS, not with SQ 6.4 LOGGER.info("Surefire report path: {}/{} not found.", fs.baseDir(), path); } return null; }
public static File getReportsDirectory(Settings settings, FileSystem fs, PathResolver pathResolver) { File dir = getReportsDirectoryFromProperty(settings, fs, pathResolver); if (dir == null) { dir = new File(fs.baseDir(), "target/surefire-reports"); } return dir; }
@CheckForNull private static File getFileFromPath(FileSystem fs, PathResolver pathResolver, String path) { try { return pathResolver.relativeFile(fs.baseDir(), path); } catch (Exception e) { // exceptions on file not found was only occurring with SQ 5.6 LTS, not with SQ 6.4 LOGGER.info("Surefire report path: {}/{} not found.", fs.baseDir(), path); } return null; }
public String getPylintConfigPath(FileSystem fileSystem) { String configPath = conf.getString(PylintConfiguration.PYLINT_CONFIG_KEY); if (StringUtils.isEmpty(configPath)) { return null; } File configFile = new File(configPath); if (!configFile.isAbsolute()) { File projectRoot = fileSystem.baseDir(); configFile = new File(projectRoot.getPath(), configPath); } return configFile.getAbsolutePath(); }
public static File getReportsDirectory(Settings settings, FileSystem fs, PathResolver pathResolver) { File dir = getReportsDirectoryFromProperty(settings, fs, pathResolver); if (dir == null) { dir = new File(fs.baseDir(), "target/surefire-reports"); } return dir; }
@CheckForNull private static File getReportsDirectoryFromProperty(Settings settings, FileSystem fs, PathResolver pathResolver) { String path = settings.getString(SUREFIRE_REPORTS_PATH_PROPERTY); if (path != null) { try { return pathResolver.relativeFile(fs.baseDir(), path); } catch (Exception e) { LOGGER.info("Surefire report path: "+fs.baseDir()+"/"+path +" not found."); } } return null; }
private Optional<File> getIOFile(String path, SensorContext context) { File file = new File(path); if (!file.isAbsolute()) { file = new File(context.fileSystem().baseDir(), path); } if (file.exists()) { return Optional.of(file); } else { LOG.warn("PHPUnit xml {} report not found: {}", msg, path); return Optional.empty(); } }
public Stream<Path> createStream(SensorContext context) throws IOException { final String fullPath = context.fileSystem().baseDir().getPath(); LOGGER.info(fullPath); return Files.walk(Paths.get(fullPath)) .filter(p -> !p.getParent().toString().equals(".git") && !p.getParent().toString().contains(".sonar") && !p.getParent().toString().contains(".scannerwork") && !p.getFileName().toString().startsWith(".") && !isAnExcludedPath(p, context)); }
private Optional<File> getIOFile(String path, SensorContext context) { File file = new File(path); if (!file.isAbsolute()) { file = new File(context.fileSystem().baseDir(), path); } if (file.exists()) { return Optional.of(file); } else { LOG.warn("PHPUnit xml {} report not found: {}", msg, path); return Optional.empty(); } }
public FunctionFinder(SensorContext context) { this.baseDir = context.fileSystem().baseDir().getPath(); LOGGER.info("base dir " + baseDir); paths = new ArrayList<>(); ProjectExplorer.searchByType(context, InputFile.Type.TEST).forEach(i -> paths.add(i.file().toPath())); }
private CoverageBuilder analyze(ExecutionDataStore executionDataStore) { CoverageBuilder coverageBuilder = new CoverageBuilder(); Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder); java.io.File binariesDir = new File(fileSystem.baseDir() + "/target/classes"); if (binariesDir.exists()) { analyzeAll(analyzer, binariesDir); } return coverageBuilder; }
@Override public void execute(SensorContext context) { String reportFileName = context.fileSystem().baseDir().getPath() + File.separator + reportPath(); LOGGER.info("Processing complexity report: {}",reportFileName); LizardReportParser parser = new LizardReportParser(context); parser.parseReport(new File(reportFileName)); } }
@Override public void execute(SensorContext context) { final String projectBaseDir = context.fileSystem().baseDir().getAbsolutePath(); FauxPasReportParser parser = new FauxPasReportParser(context); parseReportIn(projectBaseDir, parser); } }
public static HtmlReportFile getHtmlReport(Configuration config, FileSystem fileSystem, PathResolver pathResolver) throws FileNotFoundException { String path = config.get(DependencyCheckConstants.HTML_REPORT_PATH_PROPERTY).orElse(DependencyCheckConstants.HTML_REPORT_PATH_DEFAULT); File report = pathResolver.relativeFile(fileSystem.baseDir(), path); report = checkReport(report, ReportFormat.HTML, DependencyCheckConstants.HTML_REPORT_PATH_PROPERTY); if (report == null) { throw new FileNotFoundException("HTML-Dependency-Check report does not exist."); } return new HtmlReportFile(report); }
@Override public void execute(SensorContext context) { String reportPathPropertyKey = reportPathKey(); String reportPath = conf.get(reportPathPropertyKey).orElse(defaultReportPath()); try { List<File> reports = getReports(conf, context.fileSystem().baseDir().getPath(), reportPathPropertyKey, reportPath); processReports(context, reports); } catch (Exception e) { LOG.warn("Cannot read report '{}', the following exception occurred: {}", reportPath, e.getMessage()); analysisWarnings.addWarning(String.format("An error occurred while trying to import %s report(s): '%s'", reportType, reportPath)); } }
private void save(Collection<SourceCode> squidSourceFiles) { for (SourceCode squidSourceFile : squidSourceFiles) { SourceFile squidFile = (SourceFile) squidSourceFile; String relativePath = pathResolver.relativePath(context.fileSystem().baseDir(), new java.io.File(squidFile.getKey())); InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().hasRelativePath(relativePath)); saveMeasures(inputFile, squidFile); saveIssues(inputFile, squidFile); } }
private void save(Collection<SourceCode> squidSourceFiles) { for (SourceCode squidSourceFile : squidSourceFiles) { SourceFile squidFile = (SourceFile) squidSourceFile; String relativePath = pathResolver.relativePath(context.fileSystem().baseDir(), new File(squidFile.getKey())); InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().hasRelativePath(relativePath)); saveMeasures(inputFile, squidFile); saveIssues(inputFile, squidFile); } }