This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
TasksReporter.java
284 lines (260 loc) · 10.8 KB
/
TasksReporter.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
package hudson.plugins.tasks;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.project.MavenProject;
import org.kohsuke.stapler.DataBoundConstructor;
import hudson.FilePath;
import hudson.maven.MavenAggregatedReport;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenModule;
import hudson.maven.MojoInfo;
import hudson.plugins.analysis.core.HealthAwareReporter;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.util.PluginLogger;
import hudson.plugins.tasks.parser.TasksParserResult;
import hudson.plugins.tasks.parser.WorkspaceScanner;
/**
* Publishes the results of the task scanner (maven 2 project type).
*
* @author Ulli Hafner
*/
// CHECKSTYLE:COUPLING-OFF
public class TasksReporter extends HealthAwareReporter<TasksResult> {
/** Unique identifier of this class. */
private static final long serialVersionUID = -4159947472293502606L;
/** Default files pattern. */
private static final String DEFAULT_PATTERN = "**/*.java";
/** Ant file-set pattern of files to scan for open tasks in. */
private final String pattern;
/** Ant file-set pattern of files to exclude from scan. */
private final String excludePattern;
/** Tag identifiers indicating high priority. */
private final String high;
/** Tag identifiers indicating normal priority. */
private final String normal;
/** Tag identifiers indicating low priority. */
private final String low;
/** Tag identifiers indicating case sensitivity. */
private final boolean ignoreCase;
/** If the identifiers should be treated as regular expression. */
private final boolean asRegexp;
/**
* Creates a new instance of <code>TasksReporter</code>.
*
* @param pattern
* Ant file-set pattern of files to scan for open tasks in
* @param excludePattern
* Ant file-set pattern of files to exclude from scan
* @param healthy
* Report health as 100% when the number of warnings is less than
* this value
* @param unHealthy
* Report health as 0% when the number of warnings is greater
* than this value
* @param thresholdLimit
* determines which warning priorities should be considered when
* evaluating the build stability and health
* @param useDeltaValues
* determines whether the absolute annotations delta or the
* actual annotations set difference should be used to evaluate
* the build stability
* @param unstableTotalAll
* annotation threshold
* @param unstableTotalHigh
* annotation threshold
* @param unstableTotalNormal
* annotation threshold
* @param unstableTotalLow
* annotation threshold
* @param unstableNewAll
* annotation threshold
* @param unstableNewHigh
* annotation threshold
* @param unstableNewNormal
* annotation threshold
* @param unstableNewLow
* annotation threshold
* @param failedTotalAll
* annotation threshold
* @param failedTotalHigh
* annotation threshold
* @param failedTotalNormal
* annotation threshold
* @param failedTotalLow
* annotation threshold
* @param failedNewAll
* annotation threshold
* @param failedNewHigh
* annotation threshold
* @param failedNewNormal
* annotation threshold
* @param failedNewLow
* annotation threshold
* @param high
* tag identifiers indicating high priority
* @param normal
* tag identifiers indicating normal priority
* @param low
* tag identifiers indicating low priority
* @param ignoreCase
* if case should be ignored during matching
* @param asRegexp
* if the identifiers should be treated as regular expression
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param usePreviousBuildAsReference
* determines whether to always use the previous build as the reference build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param canComputeNew
* determines whether new warnings should be computed (with
* respect to baseline)
*/
// CHECKSTYLE:OFF
@SuppressWarnings("PMD.ExcessiveParameterList")
@DataBoundConstructor
public TasksReporter(final String pattern, final String excludePattern,
final String healthy, final String unHealthy, final String thresholdLimit, final boolean useDeltaValues,
final String unstableTotalAll, final String unstableTotalHigh, final String unstableTotalNormal, final String unstableTotalLow,
final String unstableNewAll, final String unstableNewHigh, final String unstableNewNormal, final String unstableNewLow,
final String failedTotalAll, final String failedTotalHigh, final String failedTotalNormal, final String failedTotalLow,
final String failedNewAll, final String failedNewHigh, final String failedNewNormal, final String failedNewLow,
final String high, final String normal, final String low, final boolean ignoreCase, final boolean asRegexp,
final boolean canRunOnFailed, final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final boolean canComputeNew) {
super(healthy, unHealthy, thresholdLimit, useDeltaValues,
unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow,
unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, canComputeNew, "TASKS");
this.pattern = pattern;
this.excludePattern = excludePattern;
this.high = high;
this.normal = normal;
this.low = low;
this.ignoreCase = ignoreCase;
this.asRegexp = asRegexp;
}
// CHECKSTYLE:ON
/**
* Returns the Ant file-set pattern to the workspace files.
*
* @return ant file-set pattern to the workspace files.
*/
public String getPattern() {
return pattern;
}
/**
* Returns the Ant file-set pattern of files to exclude from work.
*
* @return Ant file-set pattern of files to exclude from work.
*/
public String getExcludePattern() {
return excludePattern;
}
/**
* Returns the high priority task identifiers.
*
* @return the high priority task identifiers
*/
public String getHigh() {
return high;
}
/**
* Returns the normal priority task identifiers.
*
* @return the normal priority task identifiers
*/
public String getNormal() {
return normal;
}
/**
* Returns the low priority task identifiers.
*
* @return the low priority task identifiers
*/
public String getLow() {
return low;
}
/**
* Returns whether case should be ignored during the scanning.
*
* @return <code>true</code> if case should be ignored during the scanning
*/
public boolean getIgnoreCase() {
return ignoreCase;
}
/**
* Returns whether the identifiers should be treated as regular expression.
*
* @return <code>true</code> if the identifiers should be treated as regular expression
*/
public boolean getAsRegexp() {
return asRegexp;
}
@Override
protected boolean acceptGoal(final String goal) {
return true;
}
@SuppressWarnings("PMD.AvoidFinalLocalVariable")
@Override
public TasksParserResult perform(final MavenBuildProxy build, final MavenProject pom, final MojoInfo mojo, final PluginLogger logger) throws InterruptedException, IOException {
FilePath basedir = new FilePath(pom.getBasedir());
WorkspaceScanner workspaceScanner = new WorkspaceScanner(
StringUtils.defaultIfEmpty(pattern, DEFAULT_PATTERN),
excludePattern, getDefaultEncoding(), high, normal, low, ignoreCase, pom.getName(),
pom.getModules(), asRegexp);
TasksParserResult project = basedir.act(workspaceScanner);
project.setLog(project.getLogMessages()
+ String.format("Found %d open tasks.%n", project.getNumberOfAnnotations()));
return project;
}
@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings("BC")
protected TasksResult createResult(final MavenBuild build, final ParserResult project) {
return new TasksReporterResult(build, getDefaultEncoding(), (TasksParserResult)project,
usePreviousBuildAsStable(), useOnlyStableBuildsAsReference(), high, normal, low);
}
@Override
protected MavenAggregatedReport createMavenAggregatedReport(final MavenBuild build, final TasksResult result) {
return new TasksMavenResultAction(build, this, getDefaultEncoding(), high, normal, low, result);
}
@Override
public List<TasksProjectAction> getProjectActions(final MavenModule module) {
return Collections.singletonList(new TasksProjectAction(module, getResultActionClass()));
}
@Override
protected Class<TasksMavenResultAction> getResultActionClass() {
return TasksMavenResultAction.class;
}
// Backward compatibility. Do not remove.
// CHECKSTYLE:OFF
@edu.umd.cs.findbugs.annotations.SuppressWarnings("")
@SuppressWarnings({"all", "PMD"})
@Deprecated
private transient boolean isThresholdEnabled;
@edu.umd.cs.findbugs.annotations.SuppressWarnings("")
@SuppressWarnings({"all", "PMD"})
@Deprecated
private transient boolean isHealthyReportEnabled;
@edu.umd.cs.findbugs.annotations.SuppressWarnings("")
@SuppressWarnings({"all", "PMD"})
@Deprecated
private transient int healthyTasks;
@edu.umd.cs.findbugs.annotations.SuppressWarnings("")
@SuppressWarnings({"all", "PMD"})
@Deprecated
private transient int unHealthyTasks;
@edu.umd.cs.findbugs.annotations.SuppressWarnings("")
@SuppressWarnings({"all", "PMD"})
@Deprecated
private transient int minimumTasks;
@edu.umd.cs.findbugs.annotations.SuppressWarnings("")
@SuppressWarnings({"all", "PMD"})
@Deprecated
private transient String height;
}