Skip to content

Commit

Permalink
Optionally create tasks for each violation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Jul 6, 2018
1 parent 8a9f635 commit 3d33632
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Changelog of Violation Comments to Bitbucket Server Plugin.
<dependency>
<groupId>se.bjurr.violations</groupId>
<artifactId>violation-comments-to-bitbucket-server-lib</artifactId>
<version>1.51</version>
<version>1.52</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ViolationsToBitbucketServerConfig
private String bitbucketServerUrl;
private boolean createCommentWithAllSingleFileComments;
private boolean createSingleFileComments;
private boolean createSingleFileCommentsTasks;
private String projectKey;
private String pullRequestId;
private String repoSlug;
Expand Down Expand Up @@ -71,6 +72,7 @@ public ViolationsToBitbucketServerConfig(final ViolationsToBitbucketServerConfig
this.minSeverity = rhs.minSeverity;
this.keepOldComments = rhs.keepOldComments;
this.commentTemplate = rhs.commentTemplate;
this.createSingleFileCommentsTasks = rhs.createSingleFileCommentsTasks;
}

public void applyDefaults(final ViolationsToBitbucketServerGlobalConfiguration defaults) {
Expand Down Expand Up @@ -130,12 +132,29 @@ public boolean equals(final Object obj) {
if (commentOnlyChangedContentContext != other.commentOnlyChangedContentContext) {
return false;
}
if (commentTemplate == null) {
if (other.commentTemplate != null) {
return false;
}
} else if (!commentTemplate.equals(other.commentTemplate)) {
return false;
}
if (createCommentWithAllSingleFileComments != other.createCommentWithAllSingleFileComments) {
return false;
}
if (createSingleFileComments != other.createSingleFileComments) {
return false;
}
if (createSingleFileCommentsTasks != other.createSingleFileCommentsTasks) {
return false;
}
if (credentialsId == null) {
if (other.credentialsId != null) {
return false;
}
} else if (!credentialsId.equals(other.credentialsId)) {
return false;
}
if (keepOldComments != other.keepOldComments) {
return false;
}
Expand Down Expand Up @@ -163,13 +182,6 @@ public boolean equals(final Object obj) {
} else if (!repoSlug.equals(other.repoSlug)) {
return false;
}
if (credentialsId == null) {
if (other.credentialsId != null) {
return false;
}
} else if (!credentialsId.equals(other.credentialsId)) {
return false;
}
if (violationConfigs == null) {
if (other.violationConfigs != null) {
return false;
Expand Down Expand Up @@ -227,14 +239,16 @@ public int hashCode() {
result = prime * result + (bitbucketServerUrl == null ? 0 : bitbucketServerUrl.hashCode());
result = prime * result + (commentOnlyChangedContent ? 1231 : 1237);
result = prime * result + commentOnlyChangedContentContext;
result = prime * result + (commentTemplate == null ? 0 : commentTemplate.hashCode());
result = prime * result + (createCommentWithAllSingleFileComments ? 1231 : 1237);
result = prime * result + (createSingleFileComments ? 1231 : 1237);
result = prime * result + (createSingleFileCommentsTasks ? 1231 : 1237);
result = prime * result + (credentialsId == null ? 0 : credentialsId.hashCode());
result = prime * result + (keepOldComments ? 1231 : 1237);
result = prime * result + (minSeverity == null ? 0 : minSeverity.hashCode());
result = prime * result + (projectKey == null ? 0 : projectKey.hashCode());
result = prime * result + (pullRequestId == null ? 0 : pullRequestId.hashCode());
result = prime * result + (repoSlug == null ? 0 : repoSlug.hashCode());
result = prime * result + (credentialsId == null ? 0 : credentialsId.hashCode());
result = prime * result + (violationConfigs == null ? 0 : violationConfigs.hashCode());
return result;
}
Expand Down Expand Up @@ -296,6 +310,15 @@ public void setViolationConfigs(final List<ViolationConfig> parsers) {
violationConfigs = parsers;
}

public boolean getCreateSingleFileCommentsTasks() {
return createSingleFileCommentsTasks;
}

@DataBoundSetter
public void setCreateSingleFileCommentsTasks(final boolean createSingleFileCommentsTasks) {
this.createSingleFileCommentsTasks = createSingleFileCommentsTasks;
}

@Override
public String toString() {
return "ViolationsToBitbucketServerConfig [commentOnlyChangedContent="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public static void doPerform(
.withCreateCommentWithAllSingleFileComments(
config.getCreateCommentWithAllSingleFileComments()) //
.withCreateSingleFileComments(config.getCreateSingleFileComments()) //
.withCreateSingleFileCommentsTasks(config.getCreateSingleFileCommentsTasks()) //
.withCommentOnlyChangedContent(config.getCommentOnlyChangedContent()) //
.withCommentOnlyChangedContentContext(config.getCommentOnlyChangedContentContext()) //
.withShouldKeepOldComments(config.isKeepOldComments()) //
Expand Down Expand Up @@ -209,6 +210,7 @@ static ViolationsToBitbucketServerConfig expand(
expanded.setCreateCommentWithAllSingleFileComments(
config.getCreateCommentWithAllSingleFileComments());
expanded.setCreateSingleFileComments(config.getCreateSingleFileComments());
expanded.setCreateSingleFileCommentsTasks(config.getCreateSingleFileCommentsTasks());
expanded.setCredentialsId(config.getCredentialsId());
expanded.setCommentOnlyChangedContent(config.getCommentOnlyChangedContent());
expanded.setCommentOnlyChangedContentContext(config.getCommentOnlyChangedContentContext());
Expand Down Expand Up @@ -296,6 +298,7 @@ private static void logConfiguration(
logger.println(FIELD_PULLREQUESTID + ": " + config.getPullRequestId());
logger.println(FIELD_CREDENTIALSID + ": " + !isNullOrEmpty(config.getCredentialsId()));
logger.println(FIELD_CREATESINGLEFILECOMMENTS + ": " + config.getCreateSingleFileComments());
logger.println("createSingleFileCommentsTasks: " + config.getCreateSingleFileCommentsTasks());
logger.println(
FIELD_CREATECOMMENTWITHALLSINGLEFILECOMMENTS
+ ": "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<f:checkbox default="true" />
</f:entry>

<f:entry title="Create one task per violation" field="createSingleFileCommentsTasks">
<f:checkbox default="true" />
</f:entry>

<f:entry title="Create one big comment with all violations" field="createCommentWithAllSingleFileComments">
<f:checkbox />
</f:entry>
Expand Down

0 comments on commit 3d33632

Please sign in to comment.