@Test public void get_boolean() { Settings settings = new MapSettings(definitions); assertThat(settings.getBoolean("boolean")).isTrue(); assertThat(settings.getBoolean("falseboolean")).isFalse(); assertThat(settings.getBoolean("unknown")).isFalse(); assertThat(settings.getBoolean("hello")).isFalse(); }
@Test public void ignore_case_of_boolean_values() { Settings settings = new MapSettings(); settings.setProperty("foo", "true"); settings.setProperty("bar", "TRUE"); // labels in UI settings.setProperty("baz", "True"); assertThat(settings.getBoolean("foo")).isTrue(); assertThat(settings.getBoolean("bar")).isTrue(); assertThat(settings.getBoolean("baz")).isTrue(); }
@Test public void set_property_boolean() { Settings settings = new MapSettings(); settings.setProperty("foo", true); settings.setProperty("bar", false); assertThat(settings.getBoolean("foo")).isTrue(); assertThat(settings.getBoolean("bar")).isFalse(); assertThat(settings.getString("foo")).isEqualTo("true"); assertThat(settings.getString("bar")).isEqualTo("false"); }
@Test public void set_property_int() { Settings settings = new MapSettings(); settings.setProperty("foo", 123); assertThat(settings.getInt("foo")).isEqualTo(123); assertThat(settings.getString("foo")).isEqualTo("123"); assertThat(settings.getBoolean("foo")).isFalse(); }
@Override public void build(Context context) { if (!settings.getBoolean("sonar.xoo.enableProjectBuilder")) { return; } ProjectDefinition root = context.projectReactor().getRoot(); root.resetSources(); ProjectDefinition module = ProjectDefinition.create() .setKey(root.getKey() + ":module1") .setName("Module 1"); module.setBaseDir(new File(root.getBaseDir(), "module1")); module.setWorkDir(new File(root.getWorkDir(), "module1")); module.setSources("src"); root.addSubProject(module); }
@VisibleForTesting boolean isSkipped(String language) { String key = "sonar.cpd." + language + ".skip"; if (settings.hasKey(key)) { return settings.getBoolean(key); } return settings.getBoolean(CoreProperties.CPD_SKIP_PROPERTY); }
public File getTargetXMLReport() { if (conf.getBoolean(PROPERTY_GENERATE_XML)) { return new File(fileSystem.getSonarWorkingDirectory(), "checkstyle-result.xml"); } return null; }
private List<File> getBytecodeFiles() { if (settings.getBoolean(CoreProperties.DESIGN_SKIP_DESIGN_PROPERTY)) { return Collections.emptyList(); } return javaClasspath.getElements(); }
public static boolean isCrossProjectDuplicationEnabled(Settings settings) { return settings.getBoolean(CoreProperties.CPD_CROSS_PROJECT) // No cross project duplication for branches && StringUtils.isBlank(settings.getString(CoreProperties.PROJECT_BRANCH_PROPERTY)); }
public static PurgeConfiguration newDefaultPurgeConfiguration(Settings settings, IdUuidPair idUuidPair, Collection<String> disabledComponentUuids) { String[] scopes = new String[] {Scopes.FILE}; if (settings.getBoolean(PurgeConstants.PROPERTY_CLEAN_DIRECTORY)) { scopes = new String[] {Scopes.DIRECTORY, Scopes.FILE}; } return new PurgeConfiguration(idUuidPair, scopes, settings.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES), System2.INSTANCE, disabledComponentUuids); }
@Override public void execute() { if (settings.getBoolean(HTML_REPORT_ENABLED_KEY)) { IssuesReport report = builder.buildReport(); print(report); } }
@Override public void execute() { if (settings.getBoolean(HTML_REPORT_ENABLED_KEY)) { IssuesReport report = builder.buildReport(); print(report); } }
@Override public void execute(SensorContext context) { if (context.settings().getBoolean(HelloWorldProperties.HELLO_KEY)) { // print log only if property is set to true Loggers.get(getClass()).info("Hello World!"); } }
private JavaConfiguration createConfiguration() { boolean analyzePropertyAccessors = settings.getBoolean(JavaPlugin.SQUID_ANALYSE_ACCESSORS_PROPERTY); Charset charset = fs.encoding(); JavaConfiguration conf = new JavaConfiguration(charset); conf.setSeparateAccessorsFromMethods(analyzePropertyAccessors); return conf; }
private void preventAutomaticProjectCreationIfNeeded(ProjectReactor reactor) { if (resourceDao != null && settings.getBoolean(CoreProperties.CORE_PREVENT_AUTOMATIC_PROJECT_CREATION)) { String projectKey = reactor.getRoot().getKeyWithBranch(); if (resourceDao.findByKey(projectKey) == null) { throw new SonarException(String.format("Unable to scan non-existing project \"%s\"", projectKey)); } } }
@Override public void execute() { if (settings.getBoolean(CONSOLE_REPORT_ENABLED_KEY)) { Report r = new Report(); r.setNoFile(!inputPathCache.allFiles().iterator().hasNext()); for (TrackedIssue issue : issueCache.all()) { r.process(issue); } printReport(r); } }
@Override public void execute() { if (settings.getBoolean(CONSOLE_REPORT_ENABLED_KEY)) { Report r = new Report(); r.setNoFile(!inputPathCache.allFiles().iterator().hasNext()); for (DefaultIssue issue : issueCache.all()) { r.process(issue); } printReport(r); } }
public Saver<DuplicationReport> create(PluginContext pluginContext) throws CreateException { // if duplication skipped => provide no op saver to do nothing if(pluginContext.getSettings().getBoolean(((DuplicationConstants) pluginContext.getConstants()).getSkipDuplicationKey())) { LOG.debug("Saving duplications skipped"); return new NoOpSaver<DuplicationReport>(); } else { return new DuplicationSaver(pluginContext); } }
@Override public void execute(SensorContext context) { if (!context.settings().getBoolean(GoProperties.HIGHLIGHTING_KEY)) { LOGGER.info("highlighting disabled"); return; } final List<InputFile> listFiles = ProjectExplorer.searchFileWithTypeMainOrTest(context); listFiles.forEach(i -> new Colorizer(context).colorize(i)); }
public void save(SensorContext context, Project project, SonarComponents sonarComponents, ResourceMapping resourceMapping, NoSonarFilter noSonarFilter, RulesProfile rulesProfile) { boolean skipPackageDesignAnalysis = settings.getBoolean(CoreProperties.DESIGN_SKIP_PACKAGE_DESIGN_PROPERTY); //Design if (!skipPackageDesignAnalysis && squid.isBytecodeScanned()) { DesignBridge designBridge = new DesignBridge(context, squid.getGraph(), resourceMapping, sonarComponents.getResourcePerspectives()); designBridge.saveDesign(project); } //Report Issues ChecksBridge checksBridge = new ChecksBridge(sonarComponents, rulesProfile); reportIssues(resourceMapping, noSonarFilter, checksBridge, project); }