org.sonar.api.config.PropertyDefinition Java Examples

The following examples show how to use org.sonar.api.config.PropertyDefinition. 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: PmdPlugin.java    From sonar-p3c-pmd with MIT License 6 votes vote down vote up
@Override
public List getExtensions() {
  return ImmutableList.of(
    PropertyDefinition.builder(PmdConfiguration.PROPERTY_GENERATE_XML)
      .defaultValue("false")
      .name("Generate XML Report")
      .hidden()
      .build(),

    PmdSensor.class,
    PmdConfiguration.class,
    PmdExecutor.class,
    PmdRulesDefinition.class,
    PmdUnitTestsRulesDefinition.class,
    PmdProfileExporter.class,
    PmdProfileImporter.class,
    PmdViolationRecorder.class);
}
 
Example #2
Source File: LuaPlugin.java    From sonar-lua with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void define(Context context) {
  context.addExtensions(
    Lua.class,

    LuaSquidSensor.class,
    CoberturaSensor.class,

    LuaRulesDefinition.class,
    LuaProfile.class,

    PropertyDefinition.builder(FILE_SUFFIXES_KEY)
      .defaultValue(Lua.DEFAULT_FILE_SUFFIXES)
      .name("File suffixes")
      .description("Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty.")
      .onQualifiers(Qualifiers.MODULE, Qualifiers.PROJECT)
      .build(),

    PropertyDefinition.builder(COBERTURA_REPORT_PATH)
      .name("Cobertura xml report path")
      .description("Path to the Cobertura coverage report file. The path may be either absolute or relative to the project base directory.")
      .onQualifiers(Qualifiers.MODULE, Qualifiers.PROJECT)
      .build()
  );
}
 
Example #3
Source File: AemRulesSonarPlugin.java    From AEM-Rules-for-SonarQube with Apache License 2.0 6 votes vote down vote up
private static List<PropertyDefinition> pluginProperties() {
    return List.of(
        PropertyDefinition.builder(Constants.FILE_EXTENSIONS_PROP_KEY)
            .name("File suffixes")
            .description("List of file suffixes that will be scanned.")
            .category(Htl.NAME)
            .defaultValue(Constants.FILE_EXTENSIONS_DEF_VALUE)
            .onQualifiers(Qualifiers.PROJECT)
            .multiValues(true)
            .build(),
        PropertyDefinition.builder(Constants.HTL_FILES_RELATIVE_PATHS_KEY)
            .name("HTL files relative paths")
            .description("List of relative paths that contains HTL files.")
            .category(Htl.NAME)
            .defaultValue(Constants.HTL_FILES_RELATIVE_PATHS_DEF_VALUE)
            .onQualifiers(Qualifiers.PROJECT)
            .multiValues(true)
            .build()
    );
}
 
Example #4
Source File: AnsibleSettings.java    From sonar-ansible with Apache License 2.0 6 votes vote down vote up
public static List<PropertyDefinition> getProperties() {
    return asList(
            PropertyDefinition.builder(ANSIBLE_LINT_PATH_KEY)
                    .name("Path to ansible-lint")
                    .description("Path to the ansible-lint executable. Leave it empty if the command is in the system path.")
                    .defaultValue(ANSIBLE_LINT_PATH_DEFAULT_VALUE)
                    .category("Ansible")
                    .onQualifiers(Qualifiers.PROJECT)
                    .build(),
            PropertyDefinition.builder(ANSIBLE_LINT_CONF_PATH_KEY)
                    .name("Path the an ansible-lint configuration file")
                    .description("Path (absolute or relative to project root) the an ansible-lint configuration file. Leave it empty to use the default .ansible-lint file.")
                    .defaultValue(ANSIBLE_LINT_CONF_PATH_DEFAULT_VALUE)
                    .category("Ansible")
                    .onQualifiers(Qualifiers.PROJECT)
                    .build());
}
 
Example #5
Source File: EastwoodPropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveEastwoodOptionsProperty() {
    PropertyDefinition eastwoodOptions = EastwoodProperties.getEastwoodOptions();
    assertThat(eastwoodOptions.key(), is("sonar.clojure.eastwood.options"));
    assertThat(eastwoodOptions.name(), is("Eastwood Options"));
    assertThat(eastwoodOptions.category(), is("SonarClojure"));
    assertThat(eastwoodOptions.subCategory(), is("Sensors"));
    assertThat(eastwoodOptions.defaultValue(), is(""));
    assertThat(eastwoodOptions.description(), is("Provide options for eastwood plugin (e.g {:continue-on-exception true})"));
}
 
Example #6
Source File: FlowRulesDefinition.java    From sonar-flow-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create properties from annotation and add to the list
 * @param propertyAnnotations
 */
private static void addRuleProperties(FlowCheckProperty[] propertyAnnotations) {
  for(FlowCheckProperty fcp:propertyAnnotations) {
    ruleProperties.add(
        PropertyDefinition.builder(fcp.key()).defaultValue(fcp.defaultValue())
          .name(fcp.name())
          .type(fcp.type())
          .category(fcp.category())
          .subCategory(fcp.subCategory())
          .description(fcp.description())
          .onQualifiers(fcp.onQualifiers())
        .build());
  }
}
 
Example #7
Source File: CheckstylePlugin.java    From sonar-checkstyle with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public List getExtensions() {
    return Arrays
            .asList(PropertyDefinition.builder(CheckstyleConstants.CHECKER_FILTERS_KEY)
                            .defaultValue(CheckstyleConstants.CHECKER_FILTERS_DEFAULT_VALUE)
                            .category(CoreProperties.CATEGORY_JAVA)
                            .subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
                            .name("Checker Filters")
                            .description(CHECKER_FILTERS_DESCRIPTION)
                            .type(PropertyType.TEXT)
                            .onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(),
                    PropertyDefinition.builder(CheckstyleConstants.TREEWALKER_FILTERS_KEY)
                            .defaultValue(CheckstyleConstants.TREEWALKER_FILTERS_DEFAULT_VALUE)
                            .category(CoreProperties.CATEGORY_JAVA)
                            .subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
                            .name("Treewalker Filters")
                            .description(TREEWALKER_FILTERS_DESCRIPTION)
                            .type(PropertyType.TEXT)
                            .onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(),
                    PropertyDefinition.builder(CheckstyleConstants.CHECKER_TAB_WIDTH)
                            .category(CoreProperties.CATEGORY_JAVA)
                            .subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
                            .name("Tab Width")
                            .description(CHECKER_TAB_WIDTH_DESCRIPTION)
                            .type(PropertyType.INTEGER)
                            .onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
                            .build(),
                    PropertyDefinition.builder(CheckstyleConfiguration.PROPERTY_GENERATE_XML)
                            .defaultValue("false").category(CoreProperties.CATEGORY_JAVA)
                            .subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
                            .name("Generate XML Report").type(PropertyType.BOOLEAN).hidden()
                            .build(),

                    CheckstyleSensor.class, CheckstyleConfiguration.class,
                    CheckstyleExecutor.class, CheckstyleAuditListener.class,
                    CheckstyleProfileExporter.class, CheckstyleProfileImporter.class,
                    CheckstyleRulesDefinition.class);
}
 
Example #8
Source File: RubyPluginTest.java    From sonar-ruby-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testDefine() {
    RubyPlugin plugin = new RubyPlugin();

    Plugin.Context context = new Plugin.Context(Version.create(1, 0));

    plugin.define(context);

    assertThat(context.getExtensions().size()).isEqualTo(18);

    assertThat(context.getExtensions().stream().filter(ext -> ext instanceof PropertyDefinition).count()).isEqualTo(7);
    assertThat(context.getExtensions().stream().filter(ext -> ext instanceof Class).count()).isEqualTo(11);
}
 
Example #9
Source File: AnsibleSettingsTest.java    From sonar-ansible with Apache License 2.0 5 votes vote down vote up
public void testGetProperties() {
    List<PropertyDefinition> defs = AnsibleSettings.getProperties();

    assertEquals(2, defs.size());
    assertEquals(AnsibleSettings.ANSIBLE_LINT_PATH_KEY, defs.get(0).key());
    assertEquals(AnsibleSettings.ANSIBLE_LINT_PATH_DEFAULT_VALUE, defs.get(0).defaultValue());
}
 
Example #10
Source File: AncientProperties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getAncientDisabled() {
    return PropertyDefinition.builder(DISABLED_PROPERTY)
            .category(MAIN_CATEGORY)
            .subCategory(SUB_CATEGORY)
            .defaultValue(valueOf(DISABLED_PROPERTY_DEFAULT))
            .name("Ancient Disabled")
            .description("Indicates the ancient sensor should be disabled")
            .build();
}
 
Example #11
Source File: PropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldGetSensorTimeout() {
    PropertyDefinition fileSuffix = getSensorsTimeout();
    assertThat(fileSuffix.key(), is("sonar.clojure.sensors.timeout"));
    assertThat(fileSuffix.name(), is("Sensors Timeout"));
    assertThat(fileSuffix.category(), is("SonarClojure"));
    assertThat(fileSuffix.defaultValue(), is("300"));
    assertThat(fileSuffix.description(),
            is("Defines the maximum timeout (per sensor, in seconds) when sensors are executing"));
}
 
Example #12
Source File: PropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldGetFileSuffixProperty() {
    PropertyDefinition fileSuffix = getFileSuffix();
    assertThat(fileSuffix.key(), is("sonar.clojure.file.suffixes"));
    assertThat(fileSuffix.name(), is("File Suffixes"));
    assertThat(fileSuffix.category(), is("SonarClojure"));
    assertThat(fileSuffix.defaultValue(), is("clj,cljs,cljc"));
    assertThat(fileSuffix.description(), is("Comma-separated list of file suffixes to analyze"));
}
 
Example #13
Source File: CloveragePropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveCloverageReportLocationProperty() {
    PropertyDefinition cloverageReportLocation = CloverageProperties.getReportLocationProperty();
    assertThat(cloverageReportLocation.key(), is("sonar.clojure.cloverage.reportPath"));
    assertThat(cloverageReportLocation.name(), is("Cloverage Report Location"));
    assertThat(cloverageReportLocation.category(), is("SonarClojure"));
    assertThat(cloverageReportLocation.subCategory(), is("Sensors"));
    assertThat(cloverageReportLocation.defaultValue(), is("target/coverage/codecov.json"));
    assertThat(cloverageReportLocation.description(), is("Indicates the location of the cloverage report file"));
}
 
Example #14
Source File: CloveragePropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveCloverageDisabledProperty() {
    PropertyDefinition cloverageDisabled = CloverageProperties.getDisabledProperty();
    assertThat(cloverageDisabled.key(), is("sonar.clojure.cloverage.disabled"));
    assertThat(cloverageDisabled.name(), is("Cloverage Disabled"));
    assertThat(cloverageDisabled.category(), is("SonarClojure"));
    assertThat(cloverageDisabled.subCategory(), is("Sensors"));
    assertThat(cloverageDisabled.defaultValue(), is("false"));
    assertThat(cloverageDisabled.description(), is("Indicates if cloverage sensor should be disabled"));
}
 
Example #15
Source File: NvdPropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveNvdReportLocationProperty() {
    PropertyDefinition nvdReportLocation = NvdProperties.getReportLocationProperty();
    assertThat(nvdReportLocation.key(), is("sonar.clojure.nvd.reportPath"));
    assertThat(nvdReportLocation.name(), is("Lein NVD Report Location"));
    assertThat(nvdReportLocation.category(), is("SonarClojure"));
    assertThat(nvdReportLocation.subCategory(), is("Sensors"));
    assertThat(nvdReportLocation.defaultValue(), is("target/nvd/dependency-check-report.json"));
    assertThat(nvdReportLocation.description(), is("Indicates the location of the Lein NVD report file"));
}
 
Example #16
Source File: NvdPropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveNvdDisabledProperty() {
    PropertyDefinition nvdDisabled = NvdProperties.getDisabledProperty();
    assertThat(nvdDisabled.key(), is("sonar.clojure.nvd.disabled"));
    assertThat(nvdDisabled.name(), is("Lein NVD Disabled"));
    assertThat(nvdDisabled.category(), is("SonarClojure"));
    assertThat(nvdDisabled.subCategory(), is("Sensors"));
    assertThat(nvdDisabled.defaultValue(), is("false"));
    assertThat(nvdDisabled.description(), is("Indicates if lein-nvd sensor should be disabled"));
}
 
Example #17
Source File: KibitPropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveKibitDisabledProperty() {
    PropertyDefinition kibitDisabled = KibitProperties.getDisabledProperty();
    assertThat(kibitDisabled.key(), is("sonar.clojure.kibit.disabled"));
    assertThat(kibitDisabled.name(), is("Kibit Disabled"));
    assertThat(kibitDisabled.category(), is("SonarClojure"));
    assertThat(kibitDisabled.subCategory(), is("Sensors"));
    assertThat(kibitDisabled.defaultValue(), is("false"));
    assertThat(kibitDisabled.description(), is("Indicates if kibit sensor should be disabled"));
}
 
Example #18
Source File: AncientPropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveAncientDisabledProperty() {
    PropertyDefinition ancientDisabled = AncientProperties.getAncientDisabled();
    assertThat(ancientDisabled.key(), is("sonar.clojure.ancient.disabled"));
    assertThat(ancientDisabled.name(), is("Ancient Disabled"));
    assertThat(ancientDisabled.category(), is("SonarClojure"));
    assertThat(ancientDisabled.subCategory(), is("Sensors"));
    assertThat(ancientDisabled.defaultValue(), is("false"));
    assertThat(ancientDisabled.description(), is("Indicates the ancient sensor should be disabled"));
}
 
Example #19
Source File: EastwoodPropertiesTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void shouldHaveEastwoodDisabledProperty() {
    PropertyDefinition eastwoodDisabled = EastwoodProperties.getDisabledProperty();
    assertThat(eastwoodDisabled.key(), is("sonar.clojure.eastwood.disabled"));
    assertThat(eastwoodDisabled.name(), is("Eastwood Disabled"));
    assertThat(eastwoodDisabled.category(), is("SonarClojure"));
    assertThat(eastwoodDisabled.subCategory(), is("Sensors"));
    assertThat(eastwoodDisabled.defaultValue(), is("false"));
    assertThat(eastwoodDisabled.description(), is("Indicates if eastwood sensor should be disabled"));
}
 
Example #20
Source File: EsqlPluginTest.java    From sonar-esql-plugin with Apache License 2.0 5 votes vote down vote up
private List<PropertyDefinition> properties() {
  List<PropertyDefinition> propertiesList = new ArrayList<>();
  List extensions = setupContext(SonarRuntimeImpl.forSonarQube(Version.create(7, 9), SonarQubeSide.SERVER, SonarEdition.COMMUNITY)).getExtensions();

  for (Object extension : extensions) {
    if (extension instanceof PropertyDefinition) {
      propertiesList.add((PropertyDefinition) extension);
    }
  }

  return propertiesList;
}
 
Example #21
Source File: KibitProperties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getDisabledProperty() {
    return PropertyDefinition.builder(DISABLED_PROPERTY)
            .category(MAIN_CATEGORY)
            .subCategory(SUB_CATEGORY)
            .defaultValue(valueOf(DISABLED_PROPERTY_DEFAULT))
            .name("Kibit Disabled")
            .description("Indicates if kibit sensor should be disabled")
            .build();
}
 
Example #22
Source File: CloverageProperties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getDisabledProperty() {
    return PropertyDefinition.builder(DISABLED_PROPERTY)
            .category(MAIN_CATEGORY)
            .subCategory(SUB_CATEGORY)
            .defaultValue("false")
            .name("Cloverage Disabled")
            .description("Indicates if cloverage sensor should be disabled")
            .build();
}
 
Example #23
Source File: CloverageProperties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getReportLocationProperty() {
    return PropertyDefinition.builder(REPORT_LOCATION_PROPERTY)
            .category(MAIN_CATEGORY)
            .subCategory(SUB_CATEGORY)
            .defaultValue(REPORT_LOCATION_DEFAULT)
            .name("Cloverage Report Location")
            .description("Indicates the location of the cloverage report file")
            .build();
}
 
Example #24
Source File: NvdProperties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getDisabledProperty() {
    return PropertyDefinition.builder(DISABLED_PROPERTY)
            .category(MAIN_CATEGORY)
            .subCategory(SUB_CATEGORY)
            .defaultValue(valueOf(DISABLED_PROPERTY_DEFAULT))
            .name("Lein NVD Disabled")
            .description("Indicates if lein-nvd sensor should be disabled")
            .build();
}
 
Example #25
Source File: NvdProperties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getReportLocationProperty() {
    return PropertyDefinition.builder(REPORT_LOCATION_PROPERTY)
            .category(MAIN_CATEGORY)
            .subCategory(SUB_CATEGORY)
            .defaultValue(REPORT_LOCATION_DEFAULT)
            .name("Lein NVD Report Location")
            .description("Indicates the location of the Lein NVD report file")
            .build();
}
 
Example #26
Source File: ClojurePluginTest.java    From sonar-clojure with MIT License 5 votes vote down vote up
@Test
public void testFileSuffixesPropertyIsInExtensions() {
    List<PropertyDefinition> propertyDefinitions = (List<PropertyDefinition>) context.getExtensions().get(0);
    PropertyDefinition suffixProperty = propertyDefinitions.get(0);
    assertThat(suffixProperty.key(), is("sonar.clojure.file.suffixes"));

}
 
Example #27
Source File: Properties.java    From sonar-clojure with MIT License 5 votes vote down vote up
public static List<PropertyDefinition> getAllProperties() {
    return Stream
            .of(getGeneralProperties(),
                EastwoodProperties.getProperties(),
                CloverageProperties.getProperties(),
                AncientProperties.getProperties(),
                KibitProperties.getProperties(),
                NvdProperties.getProperties())
            .flatMap(Collection::stream)
            .collect(Collectors.toList());
}
 
Example #28
Source File: EsqlPluginTest.java    From sonar-esql-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void should_have_Esql_as_category_for_properties() throws Exception {

  List<PropertyDefinition> properties = properties();

  assertThat(properties).isNotEmpty();

  for (PropertyDefinition propertyDefinition : properties) {
    assertThat(propertyDefinition.category()).isEqualTo("Esql");
  }
}
 
Example #29
Source File: Properties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getFileSuffix() {
    return PropertyDefinition.builder(FILE_SUFFIXES_PROPERTY)
            .defaultValue(FILE_SUFFIXES_PROPERTY_DEFAULT)
            .category(MAIN_CATEGORY)
            .name("File Suffixes")
            .description("Comma-separated list of file suffixes to analyze")
            .build();
}
 
Example #30
Source File: Properties.java    From sonar-clojure with MIT License 5 votes vote down vote up
static PropertyDefinition getSensorsTimeout() {
    return PropertyDefinition.builder(SENSORS_TIMEOUT_PROPERTY)
            .defaultValue(SENSORS_TIMEOUT_PROPERTY_DEFAULT)
            .category(MAIN_CATEGORY)
            .name("Sensors Timeout")
            .description("Defines the maximum timeout (per sensor, in seconds) when sensors are executing")
            .build();
}