/** * Find files that match the given patterns * * @param currentSolution * The VS solution being analyzed by sonar * @param currentProject * The VS project being analyzed * @param patterns * A list of paths or ant style patterns delimited by a comma or a semi-comma * @return The files found on the filesystem */ public static Collection<File> findFiles(VisualStudioSolution currentSolution, VisualStudioProject currentProject, String patterns) { String[] patternArray = StringUtils.split(patterns, ",;"); return findFiles(currentSolution, currentProject, patternArray); }
/** * Find files that match the given patterns * * @param currentSolution * The VS solution being analyzed by sonar * @param defaultWorkDir * A working directory * @param patternArray * A list of paths or ant style patterns * @return The files found on the filesystem */ @SuppressWarnings("unchecked") public static Collection<File> findFiles(VisualStudioSolution currentSolution, File defaultWorkDir, String... patternArray) { if (patternArray == null || patternArray.length == 0) { return Collections.EMPTY_LIST; } Set<File> result = new HashSet<File>(); for (String pattern : patternArray) { findFilesFromPattern(currentSolution, defaultWorkDir, result, pattern); } logResults(result, patternArray); return result; }
private static void listFiles(Collection<File> files, File directory, IOFileFilter filter) { if (!directory.exists() || directory.isFile()) { return; } File[] found = directory.listFiles((FileFilter) filter); if (found != null) { files.addAll(Arrays.asList(found)); } File[] subDirectories = directory.listFiles((FileFilter) DirectoryFileFilter.INSTANCE); for (File subDirectory : subDirectories) { listFiles(files, subDirectory, filter); } }
/** * Find files that match the given patterns * * @param currentSolution * The VS solution being analyzed by sonar * @param currentProject * The VS project being analyzed * @param patternArray * A list of paths or ant style patterns * @return The files found on the filesystem */ public static Collection<File> findFiles(VisualStudioSolution currentSolution, VisualStudioProject currentProject, String... patternArray) { String[] patternArrayProcessed; if (patternArray == null || patternArray.length == 0) { patternArrayProcessed = null; } else { patternArrayProcessed = new String[patternArray.length]; for (int i = 0; i < patternArray.length; i++) { patternArrayProcessed[i] = process(patternArray[i], currentProject); } } return findFiles(currentSolution, currentProject.getDirectory(), patternArrayProcessed); }
private static void findFilesFromPattern(VisualStudioSolution currentSolution, File defaultWorkDir, Set<File> result, String pattern) { String currentPattern = convertSlash(pattern); File workDir = defaultWorkDir; if (StringUtils.startsWith(pattern, SOLUTION_DIR_KEY)) { String prefix = StringUtils.substringBefore(currentPattern, "*"); if (StringUtils.contains(prefix, '/')) { workDir = browse(workDir, prefix); currentPattern = "*" + StringUtils.substringAfter(currentPattern, "*"); listFiles(result, workDir, externalFilter); } else { File file = browse(workDir, currentPattern); if (file.exists()) { result.add(browse(workDir, currentPattern));
Collection<File> assemblyDependencyDirectoriesFiles = FileFinder.findDirectories(solution, vsProject, assemblyDependencyDirectories); validate(assemblyToScanFiles);
/** * Find directories that match the given patterns * * @param currentSolution * The VS solution being analyzed by sonar * @param currentProject * The VS project being analyzed * @param patternArray * A list of paths or ant style patterns * @return The directories found on the filesystem */ public static Collection<File> findDirectories(VisualStudioSolution currentSolution, VisualStudioProject currentProject, String... patternArray) { Collection<File> files = findFiles(currentSolution, currentProject, patternArray); Collection<File> directories = new ArrayList<File>(); for (File file : files) { if (file.isDirectory()) { directories.add(file); } } return directories; }
/** * Find files that match the given patterns * * @param currentSolution * The VS solution being analyzed by sonar * @param defaultWorkPath * A working path that may be relative to solution root directory * @param patternArray * A list of paths or ant style patterns * @return The files found on the filesystem */ public static Collection<File> findFiles(VisualStudioSolution currentSolution, String defaultWorkPath, String... patternArray) { return findFiles(currentSolution, new File(currentSolution.getSolutionDir(), defaultWorkPath), patternArray); }
protected Collection<File> findAssembliesToScan() { Collection<File> assemblyFiles; if (assembliesToScan.length == 0) { LOG.debug("No assembly specified: will look into 'csproj' files to find which should be analyzed."); assemblyFiles = vsProject.getGeneratedAssemblies(buildConfiguration, buildPlatform); if (assemblyFiles == null || assemblyFiles.isEmpty()) { LOG.warn("No assembly found using csproj file {} with build configuration {} and platform {}", new Object[] {vsProject.getProjectFile(), buildConfiguration, buildPlatform}); } } else { // Some assemblies have been specified: let's analyze them assemblyFiles = FileFinder.findFiles(solution, vsProject, assembliesToScan); if (assemblyFiles.isEmpty()) { LOG.warn("No assembly found using patterns " + StringUtils.join(assembliesToScan, ',')); LOG.warn("Fallback to 'csproj' files to find which should be analyzed."); assemblyFiles = vsProject.getGeneratedAssemblies(buildConfiguration, buildPlatform); } } return assemblyFiles; }
protected Collection<java.io.File> findFiles(Project project, String... queries) { VisualStudioSolution vsSolution = microsoftWindowsEnvironment.getCurrentSolution(); VisualStudioProject vsProject = getVSProject(project); return FileFinder.findFiles(vsSolution, vsProject, queries); }
if (dotSettingsFilePath != null && !StringUtils.isEmpty(dotSettingsFilePath)) { Collection<File> settingsFiles = FileFinder.findFiles(solution, vsProject, dotSettingsFilePath); if (settingsFiles.size() > 1) { throw new SonarException("More than one file matched the pattern for the ReSharper dotSettings file path");
reportFiles = FileFinder.findFiles(vsSolution, vsProject, reportPath); LOG.info("Reusing FxCop reports: " + Joiner.on(" ").join(reportFiles)); } else {
reportFiles = FileFinder.findFiles(vsSolution, vsProject, reportPath); LOG.info("Reusing Gendarme report: " + Joiner.on(" ").join(reportFiles)); } else {