if (pastViolation!=null) {\r
model.setCreatedAt(pastViolation.getCreatedAt());\r
model.setPermanentId(pastViolation.getPermanentId());\r
-\r
+ model.setSwitchedOff(pastViolation.isSwitchedOff());\r
} else {\r
// avoid plugins setting date\r
model.setCreatedAt(snapshot.getCreatedAt());\r
// the following fields can have been changed\r
violation.setMessage(model.getMessage());// the message can be changed in the class RuleFailure (truncate + trim)\r
violation.setCreatedAt(model.getCreatedAt());\r
+ violation.setSwitchedOff(model.isSwitchedOff());\r
}\r
\r
public void commit() {\r
-/*
- * Sonar, open source software quality management 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
- */
-package org.sonar.batch.index;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.database.model.RuleFailureModel;
-import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.api.rules.Violation;
-import org.sonar.core.components.DefaultRuleFinder;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ViolationPersisterTest extends AbstractDbUnitTestCase {
-
- private ViolationPersister violationPersister;
- private Rule rule1 = Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck", "Check Header");
- private Rule rule2 = Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck", "Equals Avoid Null");
- private JavaFile javaFile = new JavaFile("org.foo.Bar");
- Project project = new Project("project");
-
- @Before
- public void before() {
- setupData("shared");
- Snapshot snapshot = getSession().getSingleResult(Snapshot.class, "id", 1000);
- ResourcePersister resourcePersister = mock(ResourcePersister.class);
- when(resourcePersister.saveResource((Project) anyObject(), eq(javaFile))).thenReturn(snapshot);
- when(resourcePersister.getSnapshot(javaFile)).thenReturn(snapshot);
- violationPersister = new ViolationPersister(getSession(), resourcePersister, new DefaultRuleFinder(getSessionFactory()));
- }
-
- @Test
- public void shouldSaveViolations() {
- Violation violation1a = Violation.create(rule1, javaFile)
- .setSeverity(RulePriority.CRITICAL).setLineId(20).setCost(55.6)
- .setMessage("the message");
- Violation violation1b = Violation.create(rule1, javaFile)
- .setSeverity(RulePriority.CRITICAL).setLineId(50).setCost(80.0);
- Violation violation2 = Violation.create(rule2, javaFile)
- .setSeverity(RulePriority.MINOR);
-
- violationPersister.saveViolation(project, violation1a);
- violationPersister.saveViolation(project, violation1b);
- violationPersister.saveViolation(project, violation2);
-
- checkTables("shouldInsertViolations", "rule_failures");
- }
-
- @Test
- public void shouldCopyPermanentIdFromPastViolation() {
- RuleFailureModel pastViolation = getSession().getSingleResult(RuleFailureModel.class, "id", 1);
-
- Violation violation = Violation.create(rule1, javaFile).setSeverity(RulePriority.MAJOR).setMessage("new message");
- violationPersister.saveViolation(project, violation, pastViolation, "line_checksum");
-
- checkTables("shouldCopyPermanentIdFromPastViolation", "rule_failures");
- }
-}
+/*\r
+ * Sonar, open source software quality management tool.\r
+ * Copyright (C) 2008-2011 SonarSource\r
+ * mailto:contact AT sonarsource DOT com\r
+ *\r
+ * Sonar is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 3 of the License, or (at your option) any later version.\r
+ *\r
+ * Sonar is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with Sonar; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
+ */\r
+package org.sonar.batch.index;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.sonar.api.database.model.RuleFailureModel;\r
+import org.sonar.api.database.model.Snapshot;\r
+import org.sonar.api.resources.JavaFile;\r
+import org.sonar.api.resources.Project;\r
+import org.sonar.api.rules.Rule;\r
+import org.sonar.api.rules.RulePriority;\r
+import org.sonar.api.rules.Violation;\r
+import org.sonar.core.components.DefaultRuleFinder;\r
+import org.sonar.jpa.test.AbstractDbUnitTestCase;\r
+\r
+import static org.mockito.Matchers.anyObject;\r
+import static org.mockito.Matchers.eq;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.when;\r
+\r
+public class ViolationPersisterTest extends AbstractDbUnitTestCase {\r
+\r
+ private ViolationPersister violationPersister;\r
+ private Rule rule1 = Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck", "Check Header");\r
+ private Rule rule2 = Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck", "Equals Avoid Null");\r
+ private JavaFile javaFile = new JavaFile("org.foo.Bar");\r
+ Project project = new Project("project");\r
+\r
+ @Before\r
+ public void before() {\r
+ setupData("shared");\r
+ Snapshot snapshot = getSession().getSingleResult(Snapshot.class, "id", 1000);\r
+ ResourcePersister resourcePersister = mock(ResourcePersister.class);\r
+ when(resourcePersister.saveResource((Project) anyObject(), eq(javaFile))).thenReturn(snapshot);\r
+ when(resourcePersister.getSnapshot(javaFile)).thenReturn(snapshot);\r
+ violationPersister = new ViolationPersister(getSession(), resourcePersister, new DefaultRuleFinder(getSessionFactory()));\r
+ }\r
+\r
+ @Test\r
+ public void shouldSaveViolations() {\r
+ Violation violation1a = Violation.create(rule1, javaFile)\r
+ .setSeverity(RulePriority.CRITICAL).setLineId(20).setCost(55.6)\r
+ .setMessage("the message");\r
+ Violation violation1b = Violation.create(rule1, javaFile)\r
+ .setSeverity(RulePriority.CRITICAL).setLineId(50).setCost(80.0);\r
+ Violation violation2 = Violation.create(rule2, javaFile)\r
+ .setSeverity(RulePriority.MINOR);\r
+\r
+ violationPersister.saveViolation(project, violation1a);\r
+ violationPersister.saveViolation(project, violation1b);\r
+ violationPersister.saveViolation(project, violation2);\r
+\r
+ checkTables("shouldInsertViolations", "rule_failures");\r
+ }\r
+\r
+ @Test\r
+ public void shouldCopyPermanentIdFromPastViolation() {\r
+ RuleFailureModel pastViolation = getSession().getSingleResult(RuleFailureModel.class, "id", 1);\r
+\r
+ Violation violation = Violation.create(rule1, javaFile).setSeverity(RulePriority.MAJOR).setMessage("new message");\r
+ violationPersister.saveViolation(project, violation, pastViolation, "line_checksum");\r
+\r
+ checkTables("shouldCopyPermanentIdFromPastViolation", "rule_failures");\r
+ }\r
+\r
+ @Test\r
+ public void shouldCopySwitchedOffFromPastViolation() {\r
+ RuleFailureModel pastViolation1 = getSession().getSingleResult(RuleFailureModel.class, "id", 1);\r
+ Violation violation1 = Violation.create(rule1, javaFile).setSeverity(RulePriority.MAJOR).setMessage("new message");\r
+ violationPersister.saveViolation(project, violation1, pastViolation1, "line_checksum");\r
+\r
+ RuleFailureModel pastViolation2 = getSession().getSingleResult(RuleFailureModel.class, "id", 2);\r
+ Violation violation2 = Violation.create(rule1, javaFile).setSeverity(RulePriority.MAJOR).setMessage("new message");\r
+ violationPersister.saveViolation(project, violation2, pastViolation2, "line_checksum");\r
+\r
+ checkTables("shouldCopySwitchedOffFromPastViolation", "rule_failures");\r
+ }\r
+}\r
-<dataset>
-
- <rules_categories id="1" name="Efficiency" description="[null]"/>
- <rules_categories id="6" name="Usability" description="[null]"/>
-
- <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"
- plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
- cardinality="SINGLE" parent_id="[null]"/>
-
- <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"
- plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
- cardinality="SINGLE" parent_id="[null]"/>
-
- <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
- name="Bar" long_name="org.foo.Bar" description="[null]"
- enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>
-
- <snapshots period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"
- scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""
- status="U" islast="false" depth="3" />
-
- <rule_failures switched_off="[null]" permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
- <rule_failures switched_off="[null]" permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
-</dataset>
+<dataset>\r
+\r
+ <rules_categories id="1" name="Efficiency" description="[null]"/>\r
+ <rules_categories id="6" name="Usability" description="[null]"/>\r
+\r
+ <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"\r
+ plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"\r
+ plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"\r
+ name="Bar" long_name="org.foo.Bar" description="[null]"\r
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>\r
+\r
+ <snapshots period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"\r
+ scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""\r
+ status="U" islast="false" depth="3" />\r
+\r
+ <rule_failures switched_off="false" permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+ <rule_failures switched_off="true" permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+</dataset>\r
-<dataset>
-
- <rules_categories id="1" name="Efficiency" description="[null]"/>
- <rules_categories id="6" name="Usability" description="[null]"/>
-
- <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"
- plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
- cardinality="SINGLE" parent_id="[null]"/>
-
- <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"
- plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
- cardinality="SINGLE" parent_id="[null]"/>
-
- <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
- name="Bar" long_name="org.foo.Bar" description="[null]"
- enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>
-
- <snapshots period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"
- scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""
- status="U" islast="false" depth="3" />
-
- <rule_failures switched_off="[null]" permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
- <rule_failures switched_off="[null]" permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
-
- <rule_failures switched_off="false" permanent_id="1" ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="2" MESSAGE="new message" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="line_checksum"/>
-</dataset>
+<dataset>\r
+\r
+ <rules_categories id="1" name="Efficiency" description="[null]"/>\r
+ <rules_categories id="6" name="Usability" description="[null]"/>\r
+\r
+ <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"\r
+ plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"\r
+ plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"\r
+ name="Bar" long_name="org.foo.Bar" description="[null]"\r
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>\r
+\r
+ <snapshots period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"\r
+ scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""\r
+ status="U" islast="false" depth="3" />\r
+\r
+ <rule_failures switched_off="false" permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+ <rule_failures switched_off="true" permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+\r
+ <rule_failures switched_off="false" permanent_id="1" ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="2" MESSAGE="new message" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="line_checksum"/>\r
+</dataset>\r
--- /dev/null
+<dataset>\r
+\r
+ <rules_categories id="1" name="Efficiency" description="[null]"/>\r
+ <rules_categories id="6" name="Usability" description="[null]"/>\r
+\r
+ <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"\r
+ plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"\r
+ plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"\r
+ name="Bar" long_name="org.foo.Bar" description="[null]"\r
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>\r
+\r
+ <snapshots period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"\r
+ scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""\r
+ status="U" islast="false" depth="3" />\r
+\r
+ <rule_failures switched_off="false" permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+ <rule_failures switched_off="true" permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+\r
+ <rule_failures switched_off="false" permanent_id="1" ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="2" MESSAGE="new message" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="line_checksum"/>\r
+ <rule_failures switched_off="true" permanent_id="2" ID="4" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="2" MESSAGE="new message" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="line_checksum"/>\r
+</dataset>\r
-<dataset>
- <rules_categories id="1" name="Efficiency" description="[null]"/>
- <rules_categories id="6" name="Usability" description="[null]"/>
-
- <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"
- plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
- cardinality="SINGLE" parent_id="[null]"/>
-
- <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"
- plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"
- cardinality="SINGLE" parent_id="[null]"/>
-
- <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
- name="Bar" long_name="org.foo.Bar" description="[null]"
- enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>
-
- <snapshots period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"
- scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""
- status="U" islast="false" depth="3" />
-
- <rule_failures switched_off="[null]" permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
- <rule_failures switched_off="[null]" permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
- <rule_failures switched_off="false" permanent_id="3" ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="the message" LINE="20" COST="55.6" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
- <rule_failures switched_off="false" permanent_id="4" ID="4" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="[null]" LINE="50" COST="80" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
- <rule_failures switched_off="false" permanent_id="5" ID="5" SNAPSHOT_ID="1000" RULE_ID="31" FAILURE_LEVEL="1" MESSAGE="[null]" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>
+<dataset>\r
+ <rules_categories id="1" name="Efficiency" description="[null]"/>\r
+ <rules_categories id="6" name="Usability" description="[null]"/>\r
+\r
+ <rules id="30" name="Check Header" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"\r
+ plugin_config_key="Checker/Treewalker/HeaderCheck" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <rules id="31" name="Equals Avoid Null" plugin_rule_key="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"\r
+ plugin_config_key="Checker/TreeWalker/EqualsAvoidNull" plugin_name="checkstyle" description="[null]" priority="4" enabled="true"\r
+ cardinality="SINGLE" parent_id="[null]"/>\r
+\r
+ <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"\r
+ name="Bar" long_name="org.foo.Bar" description="[null]"\r
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>\r
+\r
+ <snapshots period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"\r
+ scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path=""\r
+ status="U" islast="false" depth="3" />\r
+\r
+ <rule_failures switched_off="false" permanent_id="1" ID="1" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+ <rule_failures switched_off="true" permanent_id="2" ID="2" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="old message" LINE="10" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+ <rule_failures switched_off="false" permanent_id="3" ID="3" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="the message" LINE="20" COST="55.6" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+ <rule_failures switched_off="false" permanent_id="4" ID="4" SNAPSHOT_ID="1000" RULE_ID="30" FAILURE_LEVEL="3" MESSAGE="[null]" LINE="50" COST="80" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
+ <rule_failures switched_off="false" permanent_id="5" ID="5" SNAPSHOT_ID="1000" RULE_ID="31" FAILURE_LEVEL="1" MESSAGE="[null]" LINE="[null]" COST="[null]" created_at="2008-11-01 13:58:00.00" checksum="[null]"/>\r
</dataset>
\ No newline at end of file
-/*
- * Sonar, open source software quality management 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
- */
-package org.sonar.api.rules;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.sonar.api.resources.Resource;
-
-import java.util.Date;
-
-/**
- * A class that represents a violation. A violation happens when a resource does not respect a defined rule.
- */
-public class Violation {
-
- private Resource resource;
- private Rule rule;
- private String message;
- private RulePriority severity;
- private Integer lineId;
- private Double cost;
- private Date createdAt;
-
- /**
- * Creates of a violation from a rule. Will need to define the resource later on
- *
- * @deprecated since 2.3. Use the factory method create()
- */
- @Deprecated
- public Violation(Rule rule) {
- this.rule = rule;
- }
-
- /**
- * Creates a fully qualified violation
- *
- * @param rule the rule that has been violated
- * @param resource the resource the violation should be attached to
- * @deprecated since 2.3. Use the factory method create()
- */
- @Deprecated
- public Violation(Rule rule, Resource resource) {
- this.resource = resource;
- this.rule = rule;
- }
-
- public Resource getResource() {
- return resource;
- }
-
- /**
- * Sets the resource the violation applies to
- *
- * @return the current object
- */
- public Violation setResource(Resource resource) {
- this.resource = resource;
- return this;
- }
-
- public Rule getRule() {
- return rule;
- }
-
- /**
- * Sets the rule violated
- *
- * @return the current object
- */
- public Violation setRule(Rule rule) {
- this.rule = rule;
- return this;
- }
-
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the violation message
- *
- * @return the current object
- */
- public Violation setMessage(String message) {
- this.message = message;
- return this;
- }
-
- /**
- * @see #setLineId(Integer)
- */
- public Integer getLineId() {
- return lineId;
- }
-
- /**
- * Sets the violation line. Note that numbering starts from 1.
- *
- * @return the current object
- */
- public Violation setLineId(Integer lineId) {
- this.lineId = lineId;
- return this;
- }
-
- /**
- * @since 2.5
- */
- public RulePriority getSeverity() {
- return severity;
- }
-
- /**
- * For internal use only.
- *
- * @since 2.5
- */
- public Violation setSeverity(RulePriority severity) {
- this.severity = severity;
- return this;
- }
-
- /**
- * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public RulePriority getPriority() {
- return severity;
- }
-
- /**
- * For internal use only
- *
- * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public Violation setPriority(RulePriority priority) {
- this.severity = priority;
- return this;
- }
-
- /**
- * @see #setCost(Double)
- * @since 2.4
- */
- public Double getCost() {
- return cost;
- }
-
- /**
- * The cost to fix a violation can't be precisely computed without this information. Let's take the following example : a rule forbids to
- * have methods whose complexity is greater than 10. Without this field "cost", the same violation is created with a method whose
- * complexity is 15 and a method whose complexity is 100. If the cost to fix one point of complexity is 0.05h, then 15mn is necessary to
- * fix the method whose complexity is 15, and 3h5mn is required to fix the method whose complexity is 100.
- *
- * @since 2.4
- */
- public Violation setCost(Double d) {
- this.cost = d;
- return this;
- }
-
- /**
- * @since 2.5
- */
- public Date getCreatedAt() {
- return createdAt;
- }
-
- /**
- * For internal use only
- *
- * @since 2.5
- */
- public Violation setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Violation)) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- Violation other = (Violation) obj;
- return new EqualsBuilder()
- .append(rule, other.getRule())
- .append(resource, other.getResource())
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37)
- .append(getRule())
- .append(getResource())
- .toHashCode();
- }
-
- @Override
- public String toString() {
- return ReflectionToStringBuilder.toString(this);
- }
-
- public static Violation create(ActiveRule activeRule, Resource resource) {
- return new Violation(activeRule.getRule()).setResource(resource);
- }
-
- public static Violation create(Rule rule, Resource resource) {
- return new Violation(rule).setResource(resource);
- }
-
-}
+/*\r
+ * Sonar, open source software quality management tool.\r
+ * Copyright (C) 2008-2011 SonarSource\r
+ * mailto:contact AT sonarsource DOT com\r
+ *\r
+ * Sonar is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 3 of the License, or (at your option) any later version.\r
+ *\r
+ * Sonar is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with Sonar; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02\r
+ */\r
+package org.sonar.api.rules;\r
+\r
+import org.apache.commons.lang.builder.EqualsBuilder;\r
+import org.apache.commons.lang.builder.HashCodeBuilder;\r
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;\r
+import org.sonar.api.resources.Resource;\r
+\r
+import java.util.Date;\r
+\r
+/**\r
+ * A class that represents a violation. A violation happens when a resource does not respect a defined rule.\r
+ */\r
+public class Violation {\r
+\r
+ private Resource resource;\r
+ private Rule rule;\r
+ private String message;\r
+ private RulePriority severity;\r
+ private Integer lineId;\r
+ private Double cost;\r
+ private Date createdAt;\r
+ private boolean switchedOff;\r
+\r
+ /**\r
+ * Creates of a violation from a rule. Will need to define the resource later on\r
+ * \r
+ * @deprecated since 2.3. Use the factory method create()\r
+ */\r
+ @Deprecated\r
+ public Violation(Rule rule) {\r
+ this.rule = rule;\r
+ }\r
+\r
+ /**\r
+ * Creates a fully qualified violation\r
+ * \r
+ * @param rule\r
+ * the rule that has been violated\r
+ * @param resource\r
+ * the resource the violation should be attached to\r
+ * @deprecated since 2.3. Use the factory method create()\r
+ */\r
+ @Deprecated\r
+ public Violation(Rule rule, Resource resource) {\r
+ this.resource = resource;\r
+ this.rule = rule;\r
+ }\r
+\r
+ public Resource getResource() {\r
+ return resource;\r
+ }\r
+\r
+ /**\r
+ * Sets the resource the violation applies to\r
+ * \r
+ * @return the current object\r
+ */\r
+ public Violation setResource(Resource resource) {\r
+ this.resource = resource;\r
+ return this;\r
+ }\r
+\r
+ public Rule getRule() {\r
+ return rule;\r
+ }\r
+\r
+ /**\r
+ * Sets the rule violated\r
+ * \r
+ * @return the current object\r
+ */\r
+ public Violation setRule(Rule rule) {\r
+ this.rule = rule;\r
+ return this;\r
+ }\r
+\r
+ public String getMessage() {\r
+ return message;\r
+ }\r
+\r
+ /**\r
+ * Sets the violation message\r
+ * \r
+ * @return the current object\r
+ */\r
+ public Violation setMessage(String message) {\r
+ this.message = message;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * @see #setLineId(Integer)\r
+ */\r
+ public Integer getLineId() {\r
+ return lineId;\r
+ }\r
+\r
+ /**\r
+ * Sets the violation line. Note that numbering starts from 1.\r
+ * \r
+ * @return the current object\r
+ */\r
+ public Violation setLineId(Integer lineId) {\r
+ this.lineId = lineId;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * @since 2.5\r
+ */\r
+ public RulePriority getSeverity() {\r
+ return severity;\r
+ }\r
+\r
+ /**\r
+ * For internal use only.\r
+ * \r
+ * @since 2.5\r
+ */\r
+ public Violation setSeverity(RulePriority severity) {\r
+ this.severity = severity;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829\r
+ */\r
+ @Deprecated\r
+ public RulePriority getPriority() {\r
+ return severity;\r
+ }\r
+\r
+ /**\r
+ * For internal use only\r
+ * \r
+ * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829\r
+ */\r
+ @Deprecated\r
+ public Violation setPriority(RulePriority priority) {\r
+ this.severity = priority;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * @see #setCost(Double)\r
+ * @since 2.4\r
+ */\r
+ public Double getCost() {\r
+ return cost;\r
+ }\r
+\r
+ /**\r
+ * The cost to fix a violation can't be precisely computed without this information. Let's take the following example : a rule forbids to\r
+ * have methods whose complexity is greater than 10. Without this field "cost", the same violation is created with a method whose\r
+ * complexity is 15 and a method whose complexity is 100. If the cost to fix one point of complexity is 0.05h, then 15mn is necessary to\r
+ * fix the method whose complexity is 15, and 3h5mn is required to fix the method whose complexity is 100.\r
+ * \r
+ * @since 2.4\r
+ */\r
+ public Violation setCost(Double d) {\r
+ this.cost = d;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * @since 2.5\r
+ */\r
+ public Date getCreatedAt() {\r
+ return createdAt;\r
+ }\r
+\r
+ /**\r
+ * For internal use only\r
+ * \r
+ * @since 2.5\r
+ */\r
+ public Violation setCreatedAt(Date createdAt) {\r
+ this.createdAt = createdAt;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Switches off the current violation. This is a kind of "mute", which means the violation exists but won't be counted as an active\r
+ * violation (and thus, won't be counted in the total number of violations).\r
+ * \r
+ * @since 2.8\r
+ * @param switchedOff\r
+ * if true, the violation is considered OFF\r
+ */\r
+ public void setSwitchedOff(boolean switchedOff) {\r
+ this.switchedOff = switchedOff;\r
+ }\r
+\r
+ /**\r
+ * Tells wether this violation is ON or OFF.\r
+ * \r
+ * @since 2.8\r
+ * @return true if the violation has been switched off\r
+ */\r
+ public boolean isSwitchedOff() {\r
+ return switchedOff;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if ( !(obj instanceof Violation)) {\r
+ return false;\r
+ }\r
+ if (this == obj) {\r
+ return true;\r
+ }\r
+ Violation other = (Violation) obj;\r
+ return new EqualsBuilder().append(rule, other.getRule()).append(resource, other.getResource()).isEquals();\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return new HashCodeBuilder(17, 37).append(getRule()).append(getResource()).toHashCode();\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return ReflectionToStringBuilder.toString(this);\r
+ }\r
+\r
+ public static Violation create(ActiveRule activeRule, Resource resource) {\r
+ return new Violation(activeRule.getRule()).setResource(resource);\r
+ }\r
+\r
+ public static Violation create(Rule rule, Resource resource) {\r
+ return new Violation(rule).setResource(resource);\r
+ }\r
+\r
+}\r