Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reformat-declarative-pipeline #343

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
/*******************************************************************************
* The MIT License
*
*
* Copyright (C) 2020, CloudBees, Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/


package io.jenkins.plugins.bitbucketpushandpullrequest.filter.pullrequest.cloud;

import static io.jenkins.plugins.bitbucketpushandpullrequest.common.BitBucketPPRConst.PULL_REQUEST_REVIEWER;
import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand All @@ -37,7 +37,6 @@
import io.jenkins.plugins.bitbucketpushandpullrequest.model.BitBucketPPRHookEvent;
import io.jenkins.plugins.bitbucketpushandpullrequest.model.cloud.BitBucketPPRParticipant;


public class BitBucketPPRPullRequestApprovedActionFilter
extends BitBucketPPRPullRequestActionFilter {
private static final Logger logger =
Expand Down Expand Up @@ -71,8 +70,8 @@
}

@Override
public BitBucketPPRTriggerCause getCause(File pollingLog, BitBucketPPRAction pullRequestAction,
BitBucketPPRHookEvent bitBucketEvent)
public BitBucketPPRTriggerCause getCause(
File pollingLog, BitBucketPPRAction pullRequestAction, BitBucketPPRHookEvent bitBucketEvent)
throws IOException {
return new BitBucketPPRPullRequestApprovedCause(pollingLog, pullRequestAction, bitBucketEvent);
}
Expand All @@ -81,12 +80,13 @@
public boolean shouldSendApprove() {
return false;
}

@Override
public boolean shouldSendDecline() {
return false;
}

@Symbol("bitbucketCloudPullRequestApproved")
@Extension
public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor {

Expand All @@ -102,7 +102,9 @@

private boolean allReviewersHaveApproved(BitBucketPPRAction pullRequestAction) {
return pullRequestAction.getPayload().getPullRequest().getParticipants().stream()
.filter(p -> isReviewer(p) && !p.getApproved()).count() == 0;
.filter(p -> isReviewer(p) && !p.getApproved())
.count()

Check warning on line 106 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestApprovedActionFilter.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 105-106 are not covered by tests
== 0;
}

private boolean isReviewer(BitBucketPPRParticipant pullRequestParticipant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.io.IOException;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand Down Expand Up @@ -64,44 +65,52 @@

@Override
public boolean shouldTriggerBuild(BitBucketPPRAction bitbucketAction) {
return matches(allowedBranches, bitbucketAction.getTargetBranch(), null) &&
hasInComment(bitbucketAction.getComment(), null);
}
return matches(allowedBranches, bitbucketAction.getTargetBranch(), null)
&& hasInComment(bitbucketAction.getComment(), null);
}

@Override
public BitBucketPPRTriggerCause getCause(File pollingLog, BitBucketPPRAction pullRequestAction,
BitBucketPPRHookEvent bitBucketEvent)
public BitBucketPPRTriggerCause getCause(
File pollingLog, BitBucketPPRAction pullRequestAction, BitBucketPPRHookEvent bitBucketEvent)
throws IOException {
return new BitBucketPPRPullRequestCommentCreatedCause(pollingLog, pullRequestAction, bitBucketEvent);
return new BitBucketPPRPullRequestCommentCreatedCause(
pollingLog, pullRequestAction, bitBucketEvent);
}

@Override
public boolean shouldSendApprove() {
return false;
}

@Override
public boolean shouldSendDecline() {
return false;
}

public boolean hasInComment(String comment, EnvVars vars) {
return BitBucketPPRUtils.matchWithRegex(comment, commentFilter, vars);
}

@Symbol("bitbucketCloudPullRequestCommentCreated")
@Extension
public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor {

@Override
public String getDisplayName() {
return "Comment Created";
}
}

@Override
public String toString() {
return "BitBucketPPRPullRequestCommentCreatedActionFilter [getDescriptor()=" + getDescriptor()
+ ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()="
+ super.toString() + "]";
return "BitBucketPPRPullRequestCommentCreatedActionFilter [getDescriptor()="
+ getDescriptor()
+ ", getClass()="
+ getClass()
+ ", hashCode()="
+ hashCode()
+ ", toString()="
+ super.toString()

Check warning on line 113 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentCreatedActionFilter.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 68-113 are not covered by tests
+ "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.io.IOException;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand Down Expand Up @@ -56,35 +57,43 @@
}

@Override
public BitBucketPPRTriggerCause getCause(File pollingLog, BitBucketPPRAction pullRequestAction,
BitBucketPPRHookEvent bitBucketEvent)
public BitBucketPPRTriggerCause getCause(
File pollingLog, BitBucketPPRAction pullRequestAction, BitBucketPPRHookEvent bitBucketEvent)
throws IOException {
return new BitBucketPPRPullRequestCommentDeletedCause(pollingLog, pullRequestAction, bitBucketEvent);
return new BitBucketPPRPullRequestCommentDeletedCause(
pollingLog, pullRequestAction, bitBucketEvent);
}

@Override
public boolean shouldSendApprove() {
return false;
}

@Override
public boolean shouldSendDecline() {
return false;
}

@Symbol("bitbucketCloudPullRequestCommentDeletedActionFilter")
@Extension
public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor {

@Override
public String getDisplayName() {
return "Comment Deleted";
}
}

@Override
public String toString() {
return "BitBucketPPRPullRequestCommentDeletedActionFilter [getDescriptor()=" + getDescriptor()
+ ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()="
+ super.toString() + "]";
return "BitBucketPPRPullRequestCommentDeletedActionFilter [getDescriptor()="
+ getDescriptor()
+ ", getClass()="
+ getClass()
+ ", hashCode()="
+ hashCode()
+ ", toString()="
+ super.toString()

Check warning on line 96 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentDeletedActionFilter.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 63-96 are not covered by tests
+ "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.io.IOException;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand Down Expand Up @@ -69,39 +70,47 @@
}

@Override
public BitBucketPPRTriggerCause getCause(File pollingLog, BitBucketPPRAction pullRequestAction,
BitBucketPPRHookEvent bitBucketEvent)
public BitBucketPPRTriggerCause getCause(
File pollingLog, BitBucketPPRAction pullRequestAction, BitBucketPPRHookEvent bitBucketEvent)
throws IOException {
return new BitBucketPPRPullRequestCommentUpdatedCause(pollingLog, pullRequestAction, bitBucketEvent);
return new BitBucketPPRPullRequestCommentUpdatedCause(
pollingLog, pullRequestAction, bitBucketEvent);
}

@Override
public boolean shouldSendApprove() {
return false;
}

@Override
public boolean shouldSendDecline() {
return false;
}

public boolean hasInComment(String comment, EnvVars vars) {
return BitBucketPPRUtils.matchWithRegex(comment, commentFilter, vars);
}

@Symbol("bitbucketCloudPullRequestCommentUpdated")
@Extension
public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor {

@Override
public String getDisplayName() {
return "Comment Updated";
}
}

@Override
public String toString() {
return "BitBucketPPRPullRequestCommentUpdatedActionFilter [getDescriptor()=" + getDescriptor()
+ ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()="
+ super.toString() + "]";
return "BitBucketPPRPullRequestCommentUpdatedActionFilter [getDescriptor()="
+ getDescriptor()
+ ", getClass()="
+ getClass()
+ ", hashCode()="
+ hashCode()
+ ", toString()="
+ super.toString()

Check warning on line 113 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCommentUpdatedActionFilter.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 76-113 are not covered by tests
+ "]";
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*******************************************************************************
* The MIT License
*
*
* Copyright (C) 2020, CloudBees, Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Expand All @@ -24,6 +24,7 @@
import java.io.File;
import java.io.IOException;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand Down Expand Up @@ -56,7 +57,7 @@
public void setIsToApprove(boolean isToApprove) {
this.isToApprove = isToApprove;
}

@DataBoundSetter
public void setIsToDecline(boolean isToDecline) {
this.isToDecline = isToDecline;
Expand All @@ -68,8 +69,8 @@
}

@Override
public BitBucketPPRTriggerCause getCause(File pollingLog, BitBucketPPRAction pullRequestAction,
BitBucketPPRHookEvent bitBucketEvent)
public BitBucketPPRTriggerCause getCause(
File pollingLog, BitBucketPPRAction pullRequestAction, BitBucketPPRHookEvent bitBucketEvent)
throws IOException {
return new BitBucketPPRPullRequestCreatedCause(pollingLog, pullRequestAction, bitBucketEvent);
}
Expand All @@ -78,12 +79,13 @@
public boolean shouldSendApprove() {
return isToApprove;
}

@Override
public boolean shouldSendDecline() {
return isToDecline;
}

@Symbol("bitbucketCloudPullRequestCreatedActionFilter")
@Extension
public static class ActionFilterDescriptorImpl extends BitBucketPPRPullRequestActionDescriptor {

Expand All @@ -95,8 +97,14 @@

@Override
public String toString() {
return "BitBucketPPRPullRequestCreatedActionFilter [getDescriptor()=" + getDescriptor()
+ ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()="
+ super.toString() + "]";
return "BitBucketPPRPullRequestCreatedActionFilter [getDescriptor()="
+ getDescriptor()
+ ", getClass()="
+ getClass()
+ ", hashCode()="
+ hashCode()
+ ", toString()="
+ super.toString()

Check warning on line 107 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/filter/pullrequest/cloud/BitBucketPPRPullRequestCreatedActionFilter.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 100-107 are not covered by tests
+ "]";
}
}
Loading
Loading