Java Code Examples for org.sonar.api.server.rule.RulesDefinition#Param
The following examples show how to use
org.sonar.api.server.rule.RulesDefinition#Param .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomScssRulesDefinitionTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 7 votes |
@Test public void test() { MyCustomScssRulesDefinition rulesDefinition = new MyCustomScssRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY); assertThat(repository.name()).isEqualTo(REPOSITORY_NAME); assertThat(repository.language()).isEqualTo("scss"); assertThat(repository.rules()).hasSize(1); RulesDefinition.Rule customRule = repository.rule(RULE_KEY); assertThat(customRule).isNotNull(); assertThat(customRule.key()).isEqualTo(RULE_KEY); assertThat(customRule.name()).isEqualTo(RULE_NAME); RulesDefinition.Param param = repository.rules().get(0).params().get(0); assertThat(param.key()).isEqualTo("customParam"); assertThat(param.description()).isEqualTo("Custom parameter"); assertThat(param.defaultValue()).isEqualTo("Default value"); }
Example 2
Source File: CustomLessRulesDefinitionTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void test() { MyCustomLessRulesDefinition rulesDefinition = new MyCustomLessRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY); assertThat(repository.name()).isEqualTo(REPOSITORY_NAME); assertThat(repository.language()).isEqualTo("less"); assertThat(repository.rules()).hasSize(1); RulesDefinition.Rule customRule = repository.rule(RULE_KEY); assertThat(customRule).isNotNull(); assertThat(customRule.key()).isEqualTo(RULE_KEY); assertThat(customRule.name()).isEqualTo(RULE_NAME); RulesDefinition.Param param = repository.rules().get(0).params().get(0); assertThat(param.key()).isEqualTo("customParam"); assertThat(param.description()).isEqualTo("Custom parameter"); assertThat(param.defaultValue()).isEqualTo("Default value"); }
Example 3
Source File: CustomCssRulesDefinitionTest.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void test() { MyCustomCssRulesDefinition rulesDefinition = new MyCustomCssRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY); assertThat(repository.name()).isEqualTo(REPOSITORY_NAME); assertThat(repository.language()).isEqualTo("css"); assertThat(repository.rules()).hasSize(1); RulesDefinition.Rule customRule = repository.rule(RULE_KEY); assertThat(customRule).isNotNull(); assertThat(customRule.key()).isEqualTo(RULE_KEY); assertThat(customRule.name()).isEqualTo(RULE_NAME); RulesDefinition.Param param = repository.rules().get(0).params().get(0); assertThat(param.key()).isEqualTo("customParam"); assertThat(param.description()).isEqualTo("Custom parameter"); assertThat(param.defaultValue()).isEqualTo("Default value"); }
Example 4
Source File: CustomGherkinRulesDefinitionTest.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void test() { MyCustomGherkinRulesDefinition rulesDefinition = new MyCustomGherkinRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY); assertThat(repository.name()).isEqualTo(REPOSITORY_NAME); assertThat(repository.language()).isEqualTo("gherkin"); assertThat(repository.rules()).hasSize(1); RulesDefinition.Rule customRule = repository.rule(RULE_KEY); assertThat(customRule).isNotNull(); assertThat(customRule.key()).isEqualTo(RULE_KEY); assertThat(customRule.name()).isEqualTo(RULE_NAME); RulesDefinition.Param param = repository.rules().get(0).params().get(0); assertThat(param.key()).isEqualTo("customParam"); assertThat(param.description()).isEqualTo("Custom parameter"); assertThat(param.defaultValue()).isEqualTo("Default value"); }
Example 5
Source File: LuaRulesDefinitionTest.java From sonar-lua with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void test() { LuaRulesDefinition rulesDefinition = new LuaRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository("lua"); assertThat(repository.name()).isEqualTo("SonarQube"); assertThat(repository.language()).isEqualTo("lua"); assertThat(repository.rules()).hasSize(CheckList.getChecks().size()); for (RulesDefinition.Rule rule : repository.rules()) { for (RulesDefinition.Param param : rule.params()) { assertThat(param.description()).as("description for " + param.key() + " of " + rule.key()).isNotEmpty(); } } }
Example 6
Source File: CheckstyleRulesDefinitionTest.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void test() { final CheckstyleRulesDefinition definition = new CheckstyleRulesDefinition(); final RulesDefinition.Context context = new RulesDefinition.Context(); definition.define(context); final RulesDefinition.Repository repository = context .repository(CheckstyleConstants.REPOSITORY_KEY); assertThat(repository.name()).isEqualTo(CheckstyleConstants.REPOSITORY_NAME); assertThat(repository.language()).isEqualTo("java"); final List<RulesDefinition.Rule> rules = repository.rules(); assertThat(rules).hasSize(174); for (RulesDefinition.Rule rule : rules) { assertThat(rule.key()).isNotNull(); assertThat(rule.internalKey()).isNotNull(); assertThat(rule.name()).isNotNull(); assertThat(rule.htmlDescription()).isNotNull(); assertThat(rule.severity()).isNotNull(); for (RulesDefinition.Param param : rule.params()) { assertThat(param.name()).isNotNull(); assertThat(param.description()).overridingErrorMessage( "Description is not set for parameter '" + param.name() + "' of rule '" + rule.key()).isNotNull(); } if (NO_SQALE.contains(rule.key())) { assertThat(rule.debtRemediationFunction()).overridingErrorMessage( "Sqale remediation function is set for rule '" + rule.key()).isNull(); } else { assertThat(rule.debtRemediationFunction()).overridingErrorMessage( "Sqale remediation function is not set for rule '" + rule.key()) .isNotNull(); } } }
Example 7
Source File: RulesLoaderTest.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
@Test public void shouldLoadRuleWithProperty() { givenRulesLoaded(List.of(RuleWithRuleProperty.class)); RepositoryImpl repository = (RepositoryImpl) context.repository(JavaCheckClasses.REPOSITORY_KEY); RulesDefinition.Rule rule = repository.rule(RULE_KEY); RulesDefinition.Param param = rule.param(RULE_PROPERTY_KEY); Assert.assertThat(param.description(), is(RULE_PROPERTY_DESCRIPTION)); Assert.assertThat(param.defaultValue(), is(RULES_PROPERTY_DEFAULT_VALUE)); Assert.assertThat(param.type().type(), is(RULES_PROPERTY_TYPE)); }
Example 8
Source File: RulesLoaderTest.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
@Test public void shouldLoadRuleWithPropertyWithoutAttributes() { givenRulesLoaded(List.of(RuleWithRulePropertyWithoutAttributes.class)); RepositoryImpl repository = (RepositoryImpl) context.repository(JavaCheckClasses.REPOSITORY_KEY); RulesDefinition.Rule rule = repository.rule(RULE_KEY); RulesDefinition.Param param = rule.param("testProperty"); Assert.assertThat(param.description(), is(nullValue())); Assert.assertThat(param.defaultValue(), is(nullValue())); Assert.assertThat(param.type().type(), is("STRING")); }