diff options
author | Pierre <pierre.guillot@sonarsource.com> | 2020-12-08 13:01:37 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-12-09 20:07:21 +0000 |
commit | 2ac64829407349d696108c9d09c70d7ea2ad266a (patch) | |
tree | 8ac9725c0d669fa1187935726960c613b6352e15 /server/sonar-webserver-auth/src | |
parent | fc6b79aaba37e38c01a5cac7d061b401a17947f8 (diff) | |
download | sonarqube-2ac64829407349d696108c9d09c70d7ea2ad266a.tar.gz sonarqube-2ac64829407349d696108c9d09c70d7ea2ad266a.zip |
remove use of Stream.peek()
Diffstat (limited to 'server/sonar-webserver-auth/src')
-rw-r--r-- | server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java index 8c3b290b79e..5b368c40f91 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java @@ -20,6 +20,7 @@ package org.sonar.server.qualityprofile; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import java.util.Collections; @@ -156,15 +157,14 @@ public class BuiltInQProfileInsertImpl implements BuiltInQProfileInsert { Map<String, String> valuesByParamKey = activeRule.getParams() .stream() .collect(MoreCollectors.uniqueIndex(BuiltInQualityProfilesDefinition.OverriddenParam::key, BuiltInQualityProfilesDefinition.OverriddenParam::overriddenValue)); - return ruleRepository.getRuleParams(activeRule.getRuleKey()) + List<ActiveRuleParamDto> rules = ruleRepository.getRuleParams(activeRule.getRuleKey()) .stream() - .map(param -> { - String activeRuleValue = valuesByParamKey.get(param.getName()); - return createParamDto(param, activeRuleValue == null ? param.getDefaultValue() : activeRuleValue); - }) + .map(param -> createParamDto(param, Optional.ofNullable(valuesByParamKey.get(param.getName())).orElse(param.getDefaultValue()))) .filter(Objects::nonNull) - .peek(paramDto -> dbClient.activeRuleDao().insertParam(session, activeRuleDto, paramDto)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); + + rules.forEach(paramDto -> dbClient.activeRuleDao().insertParam(session, activeRuleDto, paramDto)); + return rules; } @CheckForNull |