|
1 | 1 | package io.jenkins.plugins.analysis.core.model; // NOPMD
|
2 | 2 |
|
| 3 | +import org.apache.commons.lang3.StringUtils; |
| 4 | +import org.eclipse.collections.api.list.ImmutableList; |
| 5 | +import org.eclipse.collections.impl.factory.Lists; |
| 6 | +import org.eclipse.collections.impl.factory.Maps; |
| 7 | + |
| 8 | +import edu.hm.hafner.analysis.Report; |
| 9 | +import edu.hm.hafner.analysis.Severity; |
| 10 | +import edu.hm.hafner.echarts.Build; |
| 11 | +import edu.hm.hafner.util.VisibleForTesting; |
| 12 | +import edu.umd.cs.findbugs.annotations.CheckForNull; |
| 13 | +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
| 14 | + |
| 15 | +import java.io.Serial; |
3 | 16 | import java.io.Serializable;
|
4 | 17 | import java.lang.ref.WeakReference;
|
5 | 18 | import java.nio.file.Path;
|
|
14 | 27 | import java.util.regex.Matcher;
|
15 | 28 | import java.util.regex.Pattern;
|
16 | 29 |
|
17 |
| -import org.apache.commons.lang3.StringUtils; |
18 |
| -import org.eclipse.collections.api.list.ImmutableList; |
19 |
| -import org.eclipse.collections.impl.factory.Lists; |
20 |
| -import org.eclipse.collections.impl.factory.Maps; |
21 |
| - |
22 |
| -import edu.hm.hafner.analysis.Report; |
23 |
| -import edu.hm.hafner.analysis.Severity; |
24 |
| -import edu.hm.hafner.echarts.Build; |
25 |
| -import edu.hm.hafner.util.VisibleForTesting; |
26 |
| -import edu.umd.cs.findbugs.annotations.CheckForNull; |
27 |
| -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
28 |
| - |
29 | 30 | import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
|
30 | 31 | import hudson.model.Run;
|
31 | 32 |
|
|
52 | 53 | @SuppressFBWarnings(value = "SE, DESERIALIZATION_GADGET", justification = "transient fields are restored using a Jenkins callback (or are checked for null)")
|
53 | 54 | @SuppressWarnings({"PMD.TooManyFields", "PMD.ExcessiveClassLength", "PMD.GodClass", "checkstyle:ClassFanOutComplexity", "checkstyle:ClassDataAbstractionCoupling"})
|
54 | 55 | public class AnalysisResult implements Serializable, StaticAnalysisRun {
|
| 56 | + @Serial |
55 | 57 | private static final long serialVersionUID = 1110545450292087475L;
|
56 | 58 |
|
57 | 59 | private static final Pattern ISSUES_FILE_NAME = Pattern.compile("issues.xml", Pattern.LITERAL);
|
58 | 60 | private static final int NO_BUILD = -1;
|
59 | 61 | private static final String NO_REFERENCE = StringUtils.EMPTY;
|
60 | 62 |
|
61 | 63 | private final String id;
|
| 64 | + private /* almost final */ String parserId; |
62 | 65 |
|
63 | 66 | private IssuesStatistics totals;
|
64 | 67 |
|
@@ -227,8 +230,10 @@ protected AnalysisResult(final Run<?, ?> owner, final String id, final DeltaRepo
|
227 | 230 | this.owner = owner;
|
228 | 231 |
|
229 | 232 | Report allIssues = report.getAllIssues();
|
| 233 | + |
230 | 234 | new ValidationUtilities().ensureValidId(id);
|
231 | 235 | this.id = id;
|
| 236 | + this.parserId = allIssues.getParserId(); |
232 | 237 |
|
233 | 238 | totals = report.getStatistics();
|
234 | 239 | this.sizePerOrigin = new HashMap<>(sizePerOrigin);
|
@@ -265,13 +270,17 @@ protected AnalysisResult(final Run<?, ?> owner, final String id, final DeltaRepo
|
265 | 270 | *
|
266 | 271 | * @return this
|
267 | 272 | */
|
| 273 | + @Serial |
268 | 274 | protected Object readResolve() {
|
269 | 275 | if (qualityGateResult == null && qualityGateStatus != null) {
|
270 | 276 | qualityGateResult = new QualityGateResult(qualityGateStatus);
|
271 | 277 | }
|
272 | 278 | if (totals == null) {
|
273 | 279 | totals = new IssuesStatisticsBuilder().build();
|
274 | 280 | }
|
| 281 | + if (parserId == null) { |
| 282 | + parserId = id; // fallback for old data |
| 283 | + } |
275 | 284 | return this;
|
276 | 285 | }
|
277 | 286 |
|
@@ -353,6 +362,10 @@ public String getId() {
|
353 | 362 | return id;
|
354 | 363 | }
|
355 | 364 |
|
| 365 | + String getParserId() { |
| 366 | + return parserId; |
| 367 | + } |
| 368 | + |
356 | 369 | @Override
|
357 | 370 | public Run<?, ?> getOwner() {
|
358 | 371 | return owner;
|
|
0 commit comments