<name><![CDATA[Abstract Class Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/AbstractClassName]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^Abstract.*$|^.*Factory$</defaultValue>
</param>
<param key="ignoreModifier" type="BOOLEAN">
<configKey><![CDATA[Checker/TreeWalker/ConstantName]]></configKey>
<cardinality>MULTIPLE</cardinality>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$</defaultValue>
</param>
<param key="applyToPublic" type="BOOLEAN">
<param key="checkLastCaseGroup" type="BOOLEAN">
</param>
- <param key="reliefPattern" type="r">
+ <param key="reliefPattern" type="REGULAR_EXPRESSION">
</param>
<param key="tokens" type="s[PARAMETER_DEF,VARIABLE_DEF]">
</param>
- <param key="ignoreFormat" type="r">
+ <param key="ignoreFormat" type="REGULAR_EXPRESSION">
</param>
<param key="tokens" type="s{}">
</param>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
</param>
<param key="ignoreCase" type="BOOLEAN">
<param key="ignoredMethodNames" type="s{}">
</param>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
</param>
</rule>
<param key="excludeScope" type="s[nothing,public,protected,package,private,anoninner]">
</param>
- <param key="authorFormat" type="r">
+ <param key="authorFormat" type="REGULAR_EXPRESSION">
</param>
- <param key="versionFormat" type="r">
+ <param key="versionFormat" type="REGULAR_EXPRESSION">
</param>
<param key="allowMissingParamTags" type="BOOLEAN">
<configKey><![CDATA[Checker/TreeWalker/LineLength]]></configKey>
- <param key="ignorePattern" type="r">
+ <param key="ignorePattern" type="REGULAR_EXPRESSION">
</param>
<name><![CDATA[Local Final Variable Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/LocalFinalVariableName]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[a-z][a-zA-Z0-9]*$</defaultValue>
</param>
</rule>
<name><![CDATA[Local Variable Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/LocalVariableName]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[a-z][a-zA-Z0-9]*$</defaultValue>
</param>
<param key="tokens" type="s[VARIABLE_DEF,PARAMETER_DEF]">
<name><![CDATA[Member name]]></name>
<configKey><![CDATA[Checker/TreeWalker/MemberName]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[a-z][a-zA-Z0-9]*$</defaultValue>
</param>
<param key="applyToPublic" type="BOOLEAN">
<name><![CDATA[Method Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/MethodName]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[a-z][a-zA-Z0-9]*$</defaultValue>
</param>
<param key="allowClassName" type="BOOLEAN">
<param key="allowedDuplicates" type="INTEGER">
</param>
- <param key="ignoreStringsRegexp" type="r">
+ <param key="ignoreStringsRegexp" type="REGULAR_EXPRESSION">
</param>
<param key="ignoreOccurrenceContext" type="STRING">
<configKey><![CDATA[Checker/TreeWalker/MutableException]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
</param>
<configKey><![CDATA[Checker/TreeWalker/PackageName]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$</defaultValue>
</param>
</rule>
<name><![CDATA[Parameter Name]]></name>
<configKey><![CDATA[Checker/TreeWalker/ParameterName]]></configKey>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[a-z][a-zA-Z0-9]*$</defaultValue>
</param>
</rule>
<cardinality>MULTIPLE</cardinality>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
</param>
<param key="message" type="STRING">
<param key="max" type="INTEGER">
</param>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
</param>
</rule>
<configKey><![CDATA[Checker/TreeWalker/StaticVariableName]]></configKey>
<cardinality>MULTIPLE</cardinality>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[a-z][a-zA-Z0-9]*$</defaultValue>
</param>
<param key="applyToPublic" type="BOOLEAN">
<cardinality>MULTIPLE</cardinality>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
</param>
</rule>
<configKey><![CDATA[Checker/TreeWalker/TypeName]]></configKey>
<cardinality>MULTIPLE</cardinality>
- <param key="format" type="r">
+ <param key="format" type="REGULAR_EXPRESSION">
<defaultValue>^[A-Z][a-zA-Z0-9]*$</defaultValue>
</param>
<param key="tokens" type="s[CLASS_DEF,INTERFACE_DEF]">
<configKey><![CDATA[Checker/TreeWalker/UncommentedMain]]></configKey>
- <param key="excludedClasses" type="r">
+ <param key="excludedClasses" type="REGULAR_EXPRESSION">
</param>
<param key="protectedAllowed" type="BOOLEAN">
</param>
- <param key="publicMemberPattern" type="r">
+ <param key="publicMemberPattern" type="REGULAR_EXPRESSION">
</param>
</rule>
<param key="tag" type="STRING">
</param>
- <param key="tagFormat" type="r">
+ <param key="tagFormat" type="REGULAR_EXPRESSION">
</param>
<param key="tagSeverity" type="s[ignore,info,warning,error]">
<configKey><![CDATA[rulesets/basic.xml/AvoidUsingHardCodedIP]]></configKey>
- <param key="pattern" type="r">
+ <param key="pattern" type="REGULAR_EXPRESSION">
</param>
<rules id="1" name="rule1" description="desc" plugin_config_key="config"
plugin_rule_key="key1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="r"/>
- <rules_parameters id="2" rule_id="1" name="param2" description="[null]" param_type="r"/>
+ <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/>
+ <rules_parameters id="2" rule_id="1" name="param2" description="[null]" param_type="REGULAR_EXPRESSION"/>
<rules_profiles id="1" provided="true" name="profile1" default_profile="1" language="java" enabled="true"/>
<rules_profiles id="2" provided="true" name="profile2" default_profile="1" language="OTHER" enabled="true"/>
<rules id="1" name="rule1" description="desc" plugin_config_key="config"
plugin_rule_key="key1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="1" rule_id="1" name="param1" description="foo" param_type="r"/>
- <rules_parameters id="2" rule_id="1" name="param2" description="foo" param_type="r"/>
+ <rules_parameters id="1" rule_id="1" name="param1" description="foo" param_type="REGULAR_EXPRESSION"/>
+ <rules_parameters id="2" rule_id="1" name="param2" description="foo" param_type="REGULAR_EXPRESSION"/>
<rules_profiles id="1" provided="true" name="profile1" default_profile="1" language="java" enabled="true"/>
<rules_profiles id="2" provided="true" name="profile2" default_profile="1" language="OTHER" enabled="true"/>
plugin_rule_key="checkstyle.new2" plugin_name="PLUGIN_KEY" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
<!-- Rules parameters -->
- <rules_parameters id="1" rule_id="1" name="rule1_param1" description="rule1_desc1" param_type="r"
+ <rules_parameters id="1" rule_id="1" name="rule1_param1" description="rule1_desc1" param_type="REGULAR_EXPRESSION"
/>
- <rules_parameters id="2" rule_id="1" name="rule1_param2" description="rule1_desc2" param_type="r"
+ <rules_parameters id="2" rule_id="1" name="rule1_param2" description="rule1_desc2" param_type="REGULAR_EXPRESSION"
/>
- <rules_parameters id="3" rule_id="2" name="rule2_param1" description="rule2_desc1" param_type="r"
+ <rules_parameters id="3" rule_id="2" name="rule2_param1" description="rule2_desc1" param_type="REGULAR_EXPRESSION"
/>
</dataset>
\ No newline at end of file
<rules id="2" name="rule two" description="desc" plugin_config_key="config"
plugin_rule_key="rule_two" plugin_name="other plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="1" rule_id="1" name="rule1_param1" description="rule1_desc1" param_type="r"
+ <rules_parameters id="1" rule_id="1" name="rule1_param1" description="rule1_desc1" param_type="REGULAR_EXPRESSION"
/>
- <rules_parameters id="2" rule_id="2" name="rule2_param1" description="rule2_desc1" param_type="r"
+ <rules_parameters id="2" rule_id="2" name="rule2_param1" description="rule2_desc1" param_type="REGULAR_EXPRESSION"
/>
</dataset>
\ No newline at end of file
/**
* SonarSource license
*/
- LICENSE
+ LICENSE,
+
+ /**
+ * Regular expression
+ *
+ * @since 3.2
+ */
+ REGULAR_EXPRESSION
}
*
* @since 3.2
*/
- PASSWORD
+ PASSWORD,
+
+ /**
+ * Regular expression
+ *
+ * @since 3.2
+ */
+ REGULAR_EXPRESSION
}
module PropertiesHelper
def property_value(key, type, value, options = {})
- if type==PropertyType::TYPE_INTEGER
- text_field_tag key, value, {:size => 10}.update(options)
+ if type==PropertyType::TYPE_STRING
+ text_field_tag key, value, {:size => 25}.update(options)
+
+ elsif type==PropertyType::TYPE_TEXT
+ text_area_tag key, value, {:size => '40x6'}.update(options)
+
+ elsif type==PropertyType::TYPE_PASSWORD
+ password_field_tag key, value, {:size => 25}.update(options)
elsif type==PropertyType::TYPE_BOOLEAN
check_box_tag key, "true", value=='true', options
- elsif type==PropertyType::TYPE_FLOAT
+ elsif type==PropertyType::TYPE_INTEGER
text_field_tag key, value, {:size => 10}.update(options)
- elsif type==PropertyType::TYPE_STRING
- text_field_tag key, value, {:size => 25}.update(options)
+ elsif type==PropertyType::TYPE_FLOAT
+ text_field_tag key, value, {:size => 10}.update(options)
elsif type==PropertyType::TYPE_METRIC
select_tag key, options_grouped_by_domain(Metric.all.select{|m| m.display?}.sort_by(&:short_name), value, :include_empty => true), options
+ elsif type==PropertyType::TYPE_REGULAR_EXPRESSION
+ text_field_tag key, value, {:size => 25}.update(options)
+
elsif type==PropertyType::TYPE_FILTER
user_filters = options_key(value, ::Filter.find(:all, :conditions => ['user_id=?', current_user.id]).sort_by(&:id))
shared_filters = options_key(value, ::Filter.find(:all, :conditions => ['(user_id<>? or user_id is null) and shared=?', current_user.id, true]).sort_by(&:id))
"#{filters_combo} #{filter_link}"
- elsif type==PropertyType::TYPE_TEXT
- text_area_tag key, value, {:size => '40x6'}.update(options)
-
- elsif type==PropertyType::TYPE_PASSWORD
- password_field_tag key, value, {:size => 25}.update(options)
-
else
hidden_field_tag key, options
end
PARAM_TYPE_STRING_LIST = "s{}"
PARAM_TYPE_INTEGER_LIST = "i{}"
- PARAM_TYPE_REGEXP = "r"
# Kept for compatibility with old rule param type
def type_with_compatibility(type)
return PropertyType::TYPE_INTEGER if type == 'i'
return PropertyType::TYPE_INTEGER if type == PARAM_TYPE_INTEGER_LIST
return PropertyType::TYPE_BOOLEAN if type == 'b'
- return PropertyType::TYPE_STRING if type == PARAM_TYPE_REGEXP
+ return PropertyType::TYPE_REGULAR_EXPRESSION if type == 'r'
return PropertyType::TYPE_STRING if is_set(type)
type
end
- def readable_type(type)
- return "Set of comma delimited strings" if type == PARAM_TYPE_STRING_LIST
- return "Number" if type_with_compatibility(type) == PropertyType::TYPE_INTEGER
- return "Set of comma delimited numbers" if type == PARAM_TYPE_INTEGER_LIST
- return "Regular expression" if type == PARAM_TYPE_REGEXP
- return "Set of comma delimited values" if is_set(type)
+ def readable_type(param_type)
+ type=type_with_compatibility(param_type)
+
+ return "Set of comma delimited strings" if param_type == PARAM_TYPE_STRING_LIST
+ return "Number" if type == PropertyType::TYPE_INTEGER
+ return "Set of comma delimited numbers" if param_type == PARAM_TYPE_INTEGER_LIST
+ return "Regular expression" if type == PropertyType::TYPE_REGULAR_EXPRESSION
+ return "Set of comma delimited values" if is_set(param_type)
""
end
def param_value_input(parameter, value, options = {})
- property_value 'value', type_with_compatibility(parameter.param_type), value, {:id => parameter.id}.update(options)
+ type=type_with_compatibility(parameter.param_type)
+
+ property_value 'value', type, value, {:id => parameter.id}.update(options)
end
def is_set(type)
errors.add("#{value}", "'#{n}' must be an integer.")
end
end
- elsif param_type == RulesConfigurationHelper::PARAM_TYPE_REGEXP
- if !Api::Utils.is_regexp?(attribute)
- errors.add("#{value}", "'#{attribute}' must be a regular expression")
- end
+ elsif type == PropertyType::TYPE_REGULAR_EXPRESSION
+ errors.add("#{value}", "'#{attribute}' must be a regular expression") unless Api::Utils.is_regexp?(attribute)
elsif type == PropertyType::TYPE_INTEGER
- if !Api::Utils.is_integer?(attribute)
- errors.add("#{value}", "'#{attribute}' must be an integer.")
- end
+ errors.add("#{value}", "'#{attribute}' must be an integer.") unless Api::Utils.is_integer?(attribute)
elsif type == PropertyType::TYPE_BOOLEAN
- if !Api::Utils.is_boolean?(attribute)
- errors.add("#{value}", "'#{attribute}' must be one of : true,false")
- end
+ errors.add("#{value}", "'#{attribute}' must be one of : true,false") unless Api::Utils.is_boolean?(attribute)
end
end
end
def self.is_regexp?(s)
begin
- Regexp.new(S)
+ Regexp.new(s)
true
rescue
false
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
class PropertyType
- TYPE_INTEGER = 'INTEGER'
+ TYPE_STRING = 'STRING'
+ TYPE_TEXT = 'TEXT'
+ TYPE_PASSWORD = 'PASSWORD'
TYPE_BOOLEAN = 'BOOLEAN'
+ TYPE_INTEGER = 'INTEGER'
TYPE_FLOAT = 'FLOAT'
- TYPE_STRING = 'STRING'
+ #TYPE_SINGLE_SELECT_LIST = 'SINGLE_SELECT_LIST'
TYPE_METRIC = 'METRIC'
+ TYPE_LICENSE = 'LICENSE'
+ TYPE_REGULAR_EXPRESSION = 'REGULAR_EXPRESSION'
+
TYPE_FILTER = 'FILTER'
- TYPE_TEXT = 'TEXT'
- TYPE_PASSWORD = 'PASSWORD'
def self.text_to_value(text, type)
case type
errors.add_to_base("Unknown type for property #{key}") unless type
if text_value.empty?
errors.add_to_base("#{key} is empty") unless optional
- else
- errors.add_to_base("#{key} is not an integer") if type==PropertyType::TYPE_INTEGER && !Api::Utils.is_integer?(text_value)
- errors.add_to_base("#{key} is not a decimal number") if type==PropertyType::TYPE_FLOAT && !Api::Utils.is_number?(text_value)
- errors.add_to_base("#{key} is not a boolean") if type==PropertyType::TYPE_BOOLEAN && !(text_value=="true" || text_value=="false")
+ return
end
+
+ errors.add_to_base("#{key} is not an integer") if type==TYPE_INTEGER && !Api::Utils.is_integer?(text_value)
+ errors.add_to_base("#{key} is not a decimal number") if type==TYPE_FLOAT && !Api::Utils.is_number?(text_value)
+ errors.add_to_base("#{key} is not a boolean") if type==TYPE_BOOLEAN && !Api::Utils.is_boolean?(text_value)
+ errors.add_to_base("#{key} is not a regular expression") if type==TYPE_REGULAR_EXPRESSION && !Api::Utils.is_regexp?(text_value)
end
end
--- /dev/null
+<input type="text" name="<%= h property.getKey() -%>" value="<%= h value if value -%>" size="50" id="input_<%= h property.getKey() -%>"/>
+<%= link_to_function(image_tag('zoom.png'), "enlargeTextInput('#{property.getKey()}')", :class => 'nolink') -%>
\ No newline at end of file
<rules id="1" name="foo" description="test" plugin_config_key="checker/foo"
plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="r"/>
+ <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/>
<rules_profiles id="1" version="2" used_profile="false" provided="false" name="parent" default_profile="0" language="java" parent_name="[null]" enabled="true"/>
<rules id="1" name="foo" description="test" plugin_config_key="checker/foo"
plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="r"/>
+ <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/>
<rules_profiles id="1" version="1" used_profile="true" provided="false" name="parent" default_profile="0" language="java" parent_name="[null]" enabled="true"/>
<rules id="2" name="bar" description="test2" plugin_config_key="checker/bar"
plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="r"/>
+ <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/>
<rules_profiles id="1" version="1" used_profile="true" provided="false" name="parent" default_profile="0" language="java" parent_name="[null]" enabled="true"/>
<rules id="2" name="bar" description="test2" plugin_config_key="checker/bar"
plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="r"/>
+ <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/>
<rules_profiles id="1" version="1" used_profile="true" provided="false" name="parent" default_profile="0" language="java" parent_name="[null]" enabled="true"/>
<rules id="2" name="bar" description="test2" plugin_config_key="checker/bar"
plugin_rule_key="checkstyle.rule2" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
- <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="r"/>
- <rules_parameters id="14" rule_id="2" name="param2" description="[null]" param_type="r"/>
+ <rules_parameters id="13" rule_id="2" name="param1" description="[null]" param_type="REGULAR_EXPRESSION"/>
+ <rules_parameters id="14" rule_id="2" name="param2" description="[null]" param_type="REGULAR_EXPRESSION"/>
<rules_profiles id="1" version="1" used_profile="true" provided="false" name="parent" default_profile="0" language="java" parent_name="[null]" enabled="true"/>