summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/java/org
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 18:55:58 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 18:56:08 +0200
commit074f5c655822a466819c899ed9c90aef4ba1d2b4 (patch)
tree7575e1479719347f8768388df0653b4609f5ecef /sonar-server/src/main/java/org
parentc6c7ec6ddc217d0c7577bcfcecdbf9d85dd86fd3 (diff)
downloadsonarqube-074f5c655822a466819c899ed9c90aef4ba1d2b4.tar.gz
sonarqube-074f5c655822a466819c899ed9c90aef4ba1d2b4.zip
Fix some quality flaws
Diffstat (limited to 'sonar-server/src/main/java/org')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java24
2 files changed, 16 insertions, 12 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java
index bff09fd3f9d..621d92fc15b 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java
@@ -82,10 +82,9 @@ public class MassUpdater {
public <S> void execute(InputLoader<S> inputLoader, InputConverter<S> converter, @Nullable PeriodicUpdater periodicUpdater) {
long count = 0;
- Connection readConnection = null;
+ Connection readConnection = null, writeConnection = null;
Statement stmt = null;
ResultSet rs = null;
- Connection writeConnection = null;
PreparedStatement writeStatement = null;
try {
readConnection = db.getDataSource().getConnection();
@@ -136,7 +135,6 @@ public class MassUpdater {
DbUtils.closeQuietly(writeStatement);
DbUtils.closeQuietly(writeConnection);
DbUtils.closeQuietly(readConnection, stmt, rs);
-
LOGGER.info("{} rows have been updated", count);
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
index 6c53e8b856e..394001c452a 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
@@ -95,7 +95,8 @@ public class RuleActivator implements ServerComponent {
ActiveRuleChange change;
boolean stopPropagation = false;
- if (context.activeRule() == null) {
+ ActiveRuleDto activeRule = context.activeRule();
+ if (activeRule == null) {
if (activation.isReset()) {
// ignore reset when rule is not activated
return changes;
@@ -108,12 +109,12 @@ public class RuleActivator implements ServerComponent {
}
} else {
// already activated
- if (activation.isCascade() && context.activeRule().doesOverride()) {
+ if (activation.isCascade() && activeRule.doesOverride()) {
// propagating to descendants, but child profile already overrides rule -> stop propagation
return changes;
}
change = ActiveRuleChange.createFor(ActiveRuleChange.Type.UPDATED, context.activeRuleKey());
- if (activation.isCascade() && context.activeRule().getInheritance() == null) {
+ if (activation.isCascade() && activeRule.getInheritance() == null) {
// activate on child, then on parent -> mark child as overriding parent
change.setInheritance(ActiveRule.Inheritance.OVERRIDES);
change.setSeverity(context.currentSeverity());
@@ -265,9 +266,13 @@ public class RuleActivator implements ServerComponent {
ActiveRuleDto activeRule;
ActiveRuleDao dao = db.activeRuleDao();
activeRule = context.activeRule();
- activeRule.setSeverity(change.getSeverity());
- if (change.getInheritance() != null) {
- activeRule.setInheritance(change.getInheritance().name());
+ String severity = change.getSeverity();
+ if (severity != null) {
+ activeRule.setSeverity(severity);
+ }
+ ActiveRule.Inheritance inheritance = change.getInheritance();
+ if (inheritance != null) {
+ activeRule.setInheritance(inheritance.name());
}
dao.update(dbSession, activeRule);
@@ -456,7 +461,7 @@ public class RuleActivator implements ServerComponent {
// unset if parent is defined, else nothing to do
removeParent(dbSession, profile);
- } else if (profile.getParentKee() == null || !profile.getParentKee().equals(parentKey)) {
+ } else if (profile.getParentKee() == null || !parentKey.equals(profile.getParentKee())) {
QualityProfileDto parentProfile = db.qualityProfileDao().getNonNullByKey(dbSession, parentKey);
if (isDescendant(dbSession, profile, parentProfile)) {
throw new BadRequestException(String.format("Descendant profile '%s' can not be selected as parent of '%s'", parentKey, profileKey));
@@ -502,8 +507,9 @@ public class RuleActivator implements ServerComponent {
if (childProfile.getName().equals(currentParent.getName())) {
return true;
}
- if (currentParent.getParentKee() != null) {
- currentParent = db.qualityProfileDao().getByKey(dbSession, currentParent.getParentKee());
+ String parentKey = currentParent.getParentKee();
+ if (parentKey != null) {
+ currentParent = db.qualityProfileDao().getByKey(dbSession, parentKey);
} else {
currentParent = null;
}