/** * Imports php file contains in the source and tests folders. * * @param project * the project * @param context * the context * @throws IOException * Signals that an I/O exception has occurred. */ protected void doAnalyse(Project project, SensorContext context) throws IOException { // Importing source files ProjectFileSystem fileSystem = project.getFileSystem(); Charset sourceCharset = fileSystem.getSourceCharset(); List<File> sourceDirs = fileSystem.getSourceDirs(); List<File> sourceFiles = fileSystem.getSourceFiles(PHP); parseDirs(context, sourceFiles, sourceDirs, false, sourceCharset); for (File directory : sourceDirs) { LOG.info(directory.getName()); } // Importing tests files List<File> testDirs = fileSystem.getTestDirs(); List<File> testFiles = fileSystem.getTestFiles(PHP); parseDirs(context, testFiles, testDirs, true, sourceCharset); // Display source dirs and tests directories if info level is enabled. for (File directory : testDirs) { LOG.info(directory.getName()); } }
protected void analyse(ProjectFileSystem fileSystem, SensorContext context) { parseDirs(context, InputFileUtils.toFiles(fileSystem.mainFiles(ObjectiveC.KEY)), fileSystem.getSourceDirs(), false, fileSystem.getSourceCharset()); }
public File getTargetXMLReport() { if (settings.getBoolean(PROPERTY_GENERATE_XML)) { return projectFileSystem.resolvePath(PMD_RESULT_XML); } return null; }
private Resource findResourceFor(IRuleViolation violation) { List<File> allSources = ImmutableList.copyOf(Iterables.concat(projectFileSystem.getSourceDirs(), projectFileSystem.getTestDirs())); return JavaFile.fromAbsolutePath(violation.getFilename(), allSources, true); }
@Override public boolean shouldExecuteOnProject(Project project) { boolean hasLangFiles = !fs.mainFiles(language).isEmpty() || !fs.testFiles(language).isEmpty(); if (hasLangFiles) { checkFactory = AnnotationCheckFactory.create(qProfile, DefaultCommonRulesRepository.keyForLanguage(language), CommonRulesConstants.CLASSES); activeChecks = checkFactory.getChecks(); } return !activeChecks.isEmpty(); }
public ObjectiveCCpdMapping(ObjectiveC language, ProjectFileSystem fs) { this.language = language; this.charset = fs.getSourceCharset(); }
public List<File> getSourceFiles() { return InputFileUtils.toFiles(fileSystem.mainFiles(CheckstyleConstants.JAVA_KEY)); }
public File getTargetXMLReport() { if (conf.getBoolean(PROPERTY_GENERATE_XML)) { return new File(fileSystem.getSonarWorkingDirectory(), "checkstyle-result.xml"); } return null; }
/** * Gets the source directories. * * @return the source directories */ public List<File> getSourceDirectories() { return getProject().getFileSystem().getSourceDirs(); }
/** * Gets the project test source directories. * * @return List<File> A list of all test source folders */ public List<File> getTestDirectories() { return getProject().getFileSystem().getTestDirs(); }
/** * Gets the report directory for a given project. * * @param pom * the project definition * @return the report directory */ public File getReportsDirectory(Project project) { return project.getFileSystem().getBuildDir(); }
private void saveMeasuresForFile(final CoverageMeasuresBuilder measureBuilder, final String filePath) { LoggerFactory.getLogger(getClass()).debug("Saving measures for {}", filePath); final org.sonar.api.resources.File objcfile = org.sonar.api.resources.File.fromIOFile(new File(project.getFileSystem().getBasedir(), filePath), project); if (fileExists(context, objcfile)) { LoggerFactory.getLogger(getClass()).debug( "File {} was found in the project.", filePath); saveMeasures(measureBuilder, objcfile); } }
/** * @param result * @return phpunit configuration option followed by the generated phpunit.xml launcher file. Or the test directory if only one. */ private String getTestDirectoryOrFiles() { List<File> testDirs = project.getFileSystem().getTestDirs(); String directoryOrFiles = null; if (testDirs.size() == 1) { directoryOrFiles = testDirs.get(0).toString(); } else { // in case of multiple source directories, phpunit.xml file is generated and passed to phpunit. LOG.warn("Phpunit does not support multiple source directories for the moment."); LOG.warn("Group your tests folder under the same directory or use phpunit.xml file"); List<File> testFiles = project.getFileSystem().getTestFiles(PHP); LOG.info("Generating phpunit.xml file containing all your test files..."); File phpunitXml = createPhpunitConfigurationFile(testFiles); LOG.warn(phpunitXml + " file generated."); directoryOrFiles = PHPUNIT_CONFIGURATION_OPTION + phpunitXml.toString(); } return directoryOrFiles; }
/** * @see org.sonar.api.batch.Sensor#analyse(org.sonar.api.resources.Project, org.sonar.api.batch.SensorContext) */ public void analyse(Project project, SensorContext context) { ProjectFileSystem fileSystem = project.getFileSystem(); List<File> sourceFiles = fileSystem.getSourceFiles(PHP); List<File> directories = fileSystem.getSourceDirs(); for (File file : sourceFiles) { PhpFile phpFile = PhpFile.getInstance(project).fromIOFile(file, directories, false); if (phpFile != null) { Source source = analyseSourceCode(file); if (source != null) { filter.addResource(phpFile, source.getNoSonarTagLines()); double measure = source.getMeasure(Metric.COMMENTED_OUT_CODE_LINES); context.saveMeasure(phpFile, CoreMetrics.COMMENTED_OUT_CODE_LINES, measure); } } } }
public JavaScriptCpdMapping(JavaScript language, ProjectFileSystem fs) { this.language = language; this.charset = fs.getSourceCharset(); }
public boolean shouldExecuteOnProject(Project project) { return (!project.getFileSystem().mainFiles(Java.KEY).isEmpty() && !profile.getActiveRulesByRepository(PmdConstants.REPOSITORY_KEY).isEmpty()) || (!project.getFileSystem().testFiles(Java.KEY).isEmpty() && !profile.getActiveRulesByRepository(PmdConstants.TEST_REPOSITORY_KEY).isEmpty()); }
dirs = getProject().getFileSystem().getTestDirs(); } else { dirs = getProject().getFileSystem().getSourceDirs();
public List<File> getSourceFiles() { return InputFileUtils.toFiles(fileSystem.mainFiles(Java.KEY)); }
public File getTargetXMLReport() { if (conf.getBoolean(PROPERTY_GENERATE_XML)) { return new File(fileSystem.getSonarWorkingDirectory(), "checkstyle-result.xml"); } return null; }
/** * Gets the project source folders. * * @return List<File> the source folders */ public List<File> getSourceDir() { return getProject().getFileSystem().getSourceDirs(); }