Esempio n. 1
0
 private static Map<String, String> typeMapWithDeprecatedValues() {
   Map<String, String> map = Maps.newHashMap();
   map.put("i", PropertyType.INTEGER.name());
   map.put("s", PropertyType.STRING.name());
   map.put("b", PropertyType.BOOLEAN.name());
   map.put("r", PropertyType.REGULAR_EXPRESSION.name());
   map.put("s{}", "s{}");
   map.put("i{}", "i{}");
   for (PropertyType propertyType : PropertyType.values()) {
     map.put(propertyType.name(), propertyType.name());
   }
   return map;
 }
Esempio n. 2
0
 private void addRuleProperty(Rule rule, Field field) {
   org.sonar.check.RuleProperty propertyAnnotation =
       field.getAnnotation(org.sonar.check.RuleProperty.class);
   if (propertyAnnotation != null) {
     String fieldKey = StringUtils.defaultIfEmpty(propertyAnnotation.key(), field.getName());
     RuleParam param = rule.createParameter(fieldKey);
     param.setDescription(propertyAnnotation.description());
     param.setDefaultValue(propertyAnnotation.defaultValue());
     if (!StringUtils.isBlank(propertyAnnotation.type())) {
       try {
         param.setType(PropertyType.valueOf(propertyAnnotation.type().trim()).name());
       } catch (IllegalArgumentException e) {
         throw new SonarException("Invalid property type [" + propertyAnnotation.type() + "]", e);
       }
     } else {
       param.setType(guessType(field.getType()).name());
     }
   }
 }