newIssue .forRule(ruleKey) .gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)) .at(newIssue.newLocation() .on(inputFile)
@Test public void test_get_double() { Settings settings = new MapSettings(); settings.setProperty("from_double", 3.14159); settings.setProperty("from_string", "3.14159"); assertThat(settings.getDouble("from_double")).isEqualTo(3.14159, Offset.offset(0.00001)); assertThat(settings.getDouble("from_string")).isEqualTo(3.14159, Offset.offset(0.00001)); assertThat(settings.getDouble("unknown")).isNull(); }
@Test public void test_get_float() { Settings settings = new MapSettings(); settings.setProperty("from_float", 3.14159f); settings.setProperty("from_string", "3.14159"); assertThat(settings.getDouble("from_float")).isEqualTo(3.14159f, Offset.offset(0.00001)); assertThat(settings.getDouble("from_string")).isEqualTo(3.14159f, Offset.offset(0.00001)); assertThat(settings.getDouble("unknown")).isNull(); }
@Test public void testSetNullDouble() { Settings settings = new MapSettings(); settings.setProperty("foo", (Double) null); assertThat(settings.getDouble("foo")).isNull(); }
@Test public void test_get_bad_double() { Settings settings = new MapSettings(); settings.setProperty("foo", "bar"); thrown.expect(IllegalStateException.class); thrown.expectMessage("The property 'foo' is not a double value"); settings.getDouble("foo"); }
private void createIssues(InputFile file, SensorContext context, String repo) { RuleKey ruleKey = RuleKey.of(repo, RULE_KEY); String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY); for (int line = 1; line <= file.lines(); line++) { NewIssue newIssue = context.newIssue(); newIssue .forRule(ruleKey) .at(newIssue.newLocation() .on(file) .at(file.selectLine(line)) .message("This issue is generated on each line")) .overrideSeverity(severity != null ? Severity.valueOf(severity) : null); if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(5, 5))) { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } else { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } newIssue.save(); } }
newIssue .forRule(ruleKey) .gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)) .at(newIssue.newLocation() .on(inputFile)
private void createIssues(InputFile file, SensorContext context, String repo) { RuleKey ruleKey = RuleKey.of(repo, RULE_KEY); String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY); for (int line = 1; line <= file.lines(); line++) { NewIssue newIssue = context.newIssue(); newIssue .forRule(ruleKey) .at(newIssue.newLocation() .on(file) .at(file.selectLine(line)) .message("This issue is generated on each line")) .overrideSeverity(severity != null ? Severity.valueOf(severity) : null); if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(5, 5))) { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } else { newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); } newIssue.save(); } }
private void createIssues(InputFile file, SensorContext context) { RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY); String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY); for (int line = 1; line <= file.lines(); line++) { context.newIssue() .forRule(ruleKey) .onFile(file) .atLine(line) .effortToFix(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)) .overrideSeverity(severity != null ? Severity.valueOf(severity) : null) .message("This issue is generated on each line") .save(); } } }