private Rule(Repository repository, NewRule newRule) { this.pluginKey = newRule.pluginKey; this.repository = repository; this.repoKey = newRule.repoKey; this.key = newRule.key; this.name = newRule.name; this.htmlDescription = newRule.htmlDescription; this.markdownDescription = newRule.markdownDescription; this.internalKey = newRule.internalKey; this.severity = newRule.severity; this.template = newRule.template; this.status = newRule.status; this.debtRemediationFunction = newRule.debtRemediationFunction; this.gapDescription = newRule.gapDescription; this.scope = newRule.scope == null ? RuleScope.MAIN : newRule.scope; this.type = newRule.type == null ? RuleTagsToTypeConverter.convert(newRule.tags) : newRule.type; this.tags = ImmutableSortedSet.copyOf(Sets.difference(newRule.tags, RuleTagsToTypeConverter.RESERVED_TAGS)); this.securityStandards = ImmutableSortedSet.copyOf(newRule.securityStandards); Map<String, Param> paramsBuilder = new HashMap<>(); for (NewParam newParam : newRule.paramsByKey.values()) { paramsBuilder.put(newParam.key, new Param(newParam)); } this.params = Collections.unmodifiableMap(paramsBuilder); this.activatedByDefault = newRule.activatedByDefault; this.deprecatedRuleKeys = ImmutableSortedSet.copyOf(newRule.deprecatedRuleKeys); }
@Test public void type_is_vulnerability_if_has_tag_security() { assertThat(convert(asList("misra", "security"))).isEqualTo(RuleType.VULNERABILITY); }
private Rule(Repository repository, NewRule newRule) { this.pluginKey = newRule.pluginKey; this.repository = repository; this.repoKey = newRule.repoKey; this.key = newRule.key; this.name = newRule.name; this.htmlDescription = newRule.htmlDescription; this.markdownDescription = newRule.markdownDescription; this.internalKey = newRule.internalKey; this.severity = newRule.severity; this.template = newRule.template; this.status = newRule.status; this.debtRemediationFunction = newRule.debtRemediationFunction; this.gapDescription = newRule.gapDescription; this.scope = newRule.scope == null ? RuleScope.MAIN : newRule.scope; this.type = newRule.type == null ? RuleTagsToTypeConverter.convert(newRule.tags) : newRule.type; this.tags = ImmutableSortedSet.copyOf(Sets.difference(newRule.tags, RuleTagsToTypeConverter.RESERVED_TAGS)); this.securityStandards = ImmutableSortedSet.copyOf(newRule.securityStandards); Map<String, Param> paramsBuilder = new HashMap<>(); for (NewParam newParam : newRule.paramsByKey.values()) { paramsBuilder.put(newParam.key, new Param(newParam)); } this.params = Collections.unmodifiableMap(paramsBuilder); this.activatedByDefault = newRule.activatedByDefault; this.deprecatedRuleKeys = ImmutableSortedSet.copyOf(newRule.deprecatedRuleKeys); }