- complete the Derby DDL file used for unit tests : sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl
*/
- public static final int LAST_VERSION = 215;
+ public static final int LAST_VERSION = 216;
public final static String TABLE_NAME = "schema_migrations";
*/
public static final RulePriority DEFAULT_PRIORITY = RulePriority.MAJOR;
- @Column(name = "name", updatable = true, nullable = false)
+ @Column(name = "name", updatable = true, nullable = true, length = 200)
private String name;
@Column(name = "plugin_rule_key", updatable = false, nullable = true, length = 200)
if (StringUtils.isEmpty(rule.getKey())) {
throw new SonarException("Node <key> is missing in <rule>");
}
- if (StringUtils.isEmpty(rule.getName())) {
- throw new SonarException("Node <name> is missing in <rule>");
- }
}
private static void processParameter(Rule rule, SMInputCursor ruleC) throws XMLStreamException {
public void shouldRemoveNewLineCharactersInNameWithSecondConstructor() {
Rule rule;
for (String example : getExamplesContainingNewLineCharacter()) {
- rule = new Rule(null, null, example, (RulesCategory) null, null);
+ rule = new Rule(null, null, example, null, null);
assertThat(rule.getName(), is("test"));
}
}
package org.sonar.api.rules;
import org.hamcrest.core.Is;
+import org.hamcrest.core.IsNull;
import org.junit.Test;
import org.sonar.api.utils.SonarException;
import org.sonar.check.Cardinality;
new XMLRuleParser().parse(new StringReader("<rules><rule><name>Foo</name></rule></rules>"));
}
- @Test(expected = SonarException.class)
- public void failIfMissingRuleName() {
- new XMLRuleParser().parse(new StringReader("<rules><rule><key>foo</key></rule></rules>"));
+ @Test
+ public void ruleNameShouldBeOptional() {
+ List<Rule> rules = new XMLRuleParser().parse(new StringReader("<rules><rule><key>foo</key></rule></rules>"));
+ assertThat(rules.get(0).getName(), nullValue());
}
@Test(expected = SonarException.class)
}
@Test
- public void utf8Encoding() {
+ public void testUtf8Encoding() {
List<Rule> rules = new XMLRuleParser().parse(getClass().getResourceAsStream("/org/sonar/api/rules/XMLRuleParserTest/utf8.xml"));
assertThat(rules.size(), is(1));
Rule rule = rules.get(0);
}
@Test
- public void supportDeprecatedFormat() {
+ public void shouldSupportDeprecatedFormat() {
// the deprecated format uses some attributes instead of nodes
List<Rule> rules = new XMLRuleParser().parse(getClass().getResourceAsStream("/org/sonar/api/rules/XMLRuleParserTest/deprecated.xml"));
assertThat(rules.size(), is(1));
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# Sonar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+#
+# Sonar 2.10
+#
+class SetNullableRuleName < ActiveRecord::Migration
+
+ def self.up
+ add_column(:rules, :temp_name, :string, :limit => 200, :null => true)
+ Rule.reset_column_information
+
+ Rule.update_all('temp_name=name')
+
+ remove_column(:rules, :name)
+ rename_column(:rules, :temp_name, :name)
+ Rule.reset_column_information
+ end
+
+end
create table RULES (
ID INTEGER not null,
- NAME VARCHAR(192) not null,
+ NAME VARCHAR(192),
PLUGIN_RULE_KEY VARCHAR(200) not null,
PLUGIN_NAME VARCHAR(255) not null,
DESCRIPTION CLOB,