This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
/
DryResult.java
112 lines (98 loc) · 4.04 KB
/
DryResult.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package hudson.plugins.dry;
import com.thoughtworks.xstream.XStream;
import hudson.model.AbstractBuild;
import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.core.ResultAction;
import hudson.plugins.dry.parser.DuplicateCode;
/**
* Represents the results of the DRY analysis. One instance of this class is persisted for
* each build via an XML file.
*
* @author Ulli Hafner
*/
public class DryResult extends BuildResult {
private static final long serialVersionUID = 2768250056765266658L;
/**
* Creates a new instance of {@link DryResult}.
*
* @param build
* the current build as owner of this action
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param usePreviousBuildAsReference
* determines whether to use the previous build as the reference
* build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*/
public DryResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference,
DryResultAction.class);
}
/**
* Creates a new instance of {@link DryResult}.
*
* @param build
* the current build as owner of this action
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param usePreviousBuildAsReference
* determines whether to use the previous build as the reference
* build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @param actionType
* the type of the result action
*/
protected DryResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final Class<? extends ResultAction<DryResult>> actionType) {
this(build, new BuildHistory(build, actionType, usePreviousBuildAsReference, useStableBuildAsReference),
result, defaultEncoding, true);
}
DryResult(final AbstractBuild<?, ?> build, final BuildHistory history,
final ParserResult result, final String defaultEncoding, final boolean canSerialize) {
super(build, history, result, defaultEncoding);
if (canSerialize) {
serializeAnnotations(result.getAnnotations());
}
}
@Override
public String getHeader() {
return Messages.DRY_ResultAction_Header();
}
@Override
protected void configure(final XStream xstream) {
xstream.alias("dry", DuplicateCode.class);
}
@Override
public String getSummary() {
return Messages.DRY_ProjectAction_Name() + ": "
+ createDefaultSummary(DryDescriptor.RESULT_URL, getNumberOfAnnotations(), getNumberOfModules());
}
@Override
protected String createDeltaMessage() {
return createDefaultDeltaMessage(DryDescriptor.RESULT_URL, getNumberOfNewWarnings(), getNumberOfFixedWarnings());
}
@Override
protected String getSerializationFileName() {
return "dry-warnings.xml";
}
@Override
public String getDisplayName() {
return Messages.DRY_ProjectAction_Name();
}
@Override
protected Class<? extends ResultAction<? extends BuildResult>> getResultActionType() {
return DryResultAction.class;
}
}