File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
src/main/java/com/github/_1c_syntax/bsl/sonar/language Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 5454import javax .annotation .CheckForNull ;
5555import java .util .Arrays ;
5656import java .util .EnumMap ;
57+ import java .util .HashMap ;
5758import java .util .List ;
5859import java .util .Locale ;
5960import java .util .Map ;
@@ -161,11 +162,7 @@ private void setUpNewRule(NewRule newRule) {
161162 .ifPresent (newRule ::setCleanCodeAttribute );
162163
163164 // заполним влияние
164- diagnosticInfo .getTags ().forEach (tag -> {
165- var impact = IMPACTS_MAP .get (tag );
166- newRule .addDefaultImpact (impact .getLeft (), impact .getRight ());
167- }
168- );
165+ computeImpact (diagnosticInfo .getTags ()).forEach (newRule ::addDefaultImpact );
169166
170167 if (diagnosticInfo .getExtraMinForComplexity () > 0 ) {
171168 newRule .setDebtRemediationFunction (
@@ -211,6 +208,18 @@ private Language createDiagnosticLanguage() {
211208 return Language .valueOf (diagnosticLanguageCode .toUpperCase (Locale .ENGLISH ));
212209 }
213210
211+ private static Map <SoftwareQuality , Severity > computeImpact (List <DiagnosticTag > tags ) {
212+ Map <SoftwareQuality , Severity > map = new HashMap <>();
213+ tags .forEach ((DiagnosticTag tag ) -> {
214+ var impact = IMPACTS_MAP .get (tag );
215+ var value = map .get (impact .getLeft ());
216+ if (value == null || impact .getRight ().compareTo (value ) > 0 ) {
217+ map .put (impact .getLeft (), impact .getRight ());
218+ }
219+ });
220+ return map ;
221+ }
222+
214223 @ CheckForNull
215224 private static RuleParamType getRuleParamType (Class <?> type ) {
216225
You can’t perform that action at this time.
0 commit comments