From 949f14d88a7d7a53c6c3e650648c50bd987399f4 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 7 Apr 2014 09:44:28 +0200 Subject: [PATCH] Add some comments --- sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java | 7 +++++-- .../src/test/java/org/sonar/core/rule/RuleDaoTest.java | 2 +- .../java/org/sonar/server/debt/DebtModelOperations.java | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java index fe04585aa3a..3b5677fc9b9 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java @@ -80,8 +80,11 @@ public class RuleDao implements BatchComponent, ServerComponent { } } - public List selectBySubCharacteristicId(Integer characteristicOrSubCharacteristicId, SqlSession session) { - return getMapper(session).selectBySubCharacteristicId(characteristicOrSubCharacteristicId); + /** + * Return all rules (even the REMOVED ones) linked on to a sub characteristic + */ + public List selectBySubCharacteristicId(Integer subCharacteristicId, SqlSession session) { + return getMapper(session).selectBySubCharacteristicId(subCharacteristicId); } @CheckForNull diff --git a/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java b/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java index 0a51195d85c..6386962c054 100644 --- a/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java @@ -148,7 +148,7 @@ public class RuleDaoTest extends AbstractDaoTestCase { public void select_by_sub_characteristic_id(){ setupData("select_by_sub_characteristic_id"); - // Rules from sub characteristic + // Rules from sub characteristic (even REMOVED ones are returned) List ruleDtos = dao.selectBySubCharacteristicId(3); assertThat(ruleDtos).hasSize(3); assertThat(idsFromRuleDtos(ruleDtos)).containsExactly(2, 4, 5); diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java index 78e21c36aeb..7c3934c8a47 100644 --- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java +++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java @@ -221,6 +221,7 @@ public class DebtModelOperations implements ServerComponent { } private void disableSubCharacteristic(CharacteristicDto subCharacteristic, Date updateDate, SqlSession session) { + // Disable debt on all rules (even REMOVED ones, in order to have no issue if they are reactivated) linked to the sub characteristic disableRulesDebt(ruleDao.selectBySubCharacteristicId(subCharacteristic.getId(), session), subCharacteristic.getId(), updateDate, session); disableCharacteristic(subCharacteristic, updateDate, session); } -- 2.39.5