Skip to content

Commit

Permalink
Merge pull request #35 from jenkinsci/codingstyle-1.4.0
Browse files Browse the repository at this point in the history
Bump version of analysis-pom to 4.1.0 (and codingstyle to 1.4.0)
  • Loading branch information
XiongKezhi authored Aug 25, 2020
2 parents e9ab753 + 7b151f3 commit 37de36b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 39 deletions.
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>4.0.0</version>
<version>4.1.0</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -58,6 +58,16 @@
<tag>${scmTag}</tag>
</scm>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.jenkins.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials;

import edu.umd.cs.findbugs.annotations.Nullable;
import io.jenkins.plugins.util.PluginLogger;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials;
import hudson.model.Job;

import io.jenkins.plugins.util.PluginLogger;

/**
* Base class for a context that publishes GitHub checks.
*/
Expand Down Expand Up @@ -62,7 +63,7 @@ public GitHubAppCredentials getCredentials() {
return getGitHubAppCredentials(credentialsId);
}

@Nullable
@CheckForNull
protected abstract String getCredentialsId();

/**
Expand Down Expand Up @@ -94,7 +95,7 @@ Optional<GitHubAppCredentials> findGitHubAppCredentials(final String credentials
abstract boolean isValid(PluginLogger listener);

protected boolean hasGitHubAppCredentials() {
return findGitHubAppCredentials(getCredentialsId()).isPresent();
return findGitHubAppCredentials(StringUtils.defaultIfEmpty(getCredentialsId(), "")).isPresent();
}

protected boolean hasCredentialsId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
import java.util.logging.Logger;

import org.apache.commons.lang3.StringUtils;
import org.jenkinsci.plugins.github_branch_source.Connector;
import org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials;

import edu.hm.hafner.util.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import org.kohsuke.github.GHCheckRunBuilder;
import org.kohsuke.github.GitHub;
import org.jenkinsci.plugins.github_branch_source.Connector;
import org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials;
import hudson.model.TaskListener;

import edu.hm.hafner.util.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.Nullable;
import io.jenkins.plugins.checks.api.ChecksDetails;
import io.jenkins.plugins.checks.api.ChecksPublisher;

import hudson.model.TaskListener;

/**
* A publisher which publishes GitHub check runs.
*/
Expand All @@ -27,7 +28,7 @@ public class GitHubChecksPublisher extends ChecksPublisher {
private static final Logger LOGGER = Logger.getLogger(GitHubChecksPublisher.class.getName());

private final GitHubChecksContext context;
@Nullable
@CheckForNull
private final TaskListener listener;
private final String gitHubUrl;

Expand All @@ -37,11 +38,11 @@ public class GitHubChecksPublisher extends ChecksPublisher {
* @param context
* a context which contains SCM properties
*/
public GitHubChecksPublisher(final GitHubChecksContext context, @Nullable final TaskListener listener) {
public GitHubChecksPublisher(final GitHubChecksContext context, @CheckForNull final TaskListener listener) {
this(context, listener, GITHUB_URL);
}

GitHubChecksPublisher(final GitHubChecksContext context, @Nullable final TaskListener listener,
GitHubChecksPublisher(final GitHubChecksContext context, @CheckForNull final TaskListener listener,
final String gitHubUrl) {
super();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import java.util.Optional;

import edu.hm.hafner.util.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import org.jenkinsci.plugins.displayurlapi.DisplayURLProvider;
import org.jenkinsci.plugins.github_branch_source.GitHubSCMSource;
import org.jenkinsci.plugins.github_branch_source.PullRequestSCMRevision;

import edu.hm.hafner.util.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.Nullable;
import io.jenkins.plugins.util.PluginLogger;
import hudson.model.Job;
import hudson.model.Run;
import jenkins.plugins.git.AbstractGitSCMSource;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMRevision;

import hudson.model.Job;
import hudson.model.Run;
import io.jenkins.plugins.util.PluginLogger;

/**
* Provides a {@link GitHubChecksContext} for a Jenkins job that uses a supported {@link GitHubSCMSource}.
Expand Down Expand Up @@ -59,7 +59,7 @@ public String getRepository() {
return source.getRepoOwner() + "/" + source.getRepository();
}

@Override @Nullable
@Override @CheckForNull
protected String getCredentialsId() {
return resolveSource().getCredentialsId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import org.apache.commons.lang3.StringUtils;

import edu.umd.cs.findbugs.annotations.Nullable;
import io.jenkins.plugins.util.PluginLogger;
import edu.umd.cs.findbugs.annotations.CheckForNull;

import hudson.model.Run;
import hudson.model.TaskListener;
Expand All @@ -15,6 +14,8 @@
import hudson.plugins.git.UserRemoteConfig;
import hudson.plugins.git.util.BuildData;

import io.jenkins.plugins.util.PluginLogger;

/**
* Provides a {@link GitHubChecksContext} for a Jenkins job that uses a supported {@link GitSCM}.
*/
Expand Down Expand Up @@ -72,7 +73,7 @@ public String getRepository() {
return StringUtils.removeEnd(removeProtocol(getRemoteUrl()), ".git");
}

@Nullable
@CheckForNull
private String getRemoteUrl() {
return getUserRemoteConfig().getUrl();
}
Expand All @@ -81,7 +82,7 @@ private String removeProtocol(final String url) {
return StringUtils.removeStart(StringUtils.removeStart(url, GIT_PROTOCOL), HTTPS_PROTOCOL);
}

@Override @Nullable
@Override @CheckForNull
protected String getCredentialsId() {
return getUserRemoteConfig().getCredentialsId();
}
Expand Down Expand Up @@ -130,8 +131,8 @@ boolean isValid(final PluginLogger logger) {
return true;
}

private boolean isValidUrl(@Nullable final String remoteUrl) {
private boolean isValidUrl(@CheckForNull final String remoteUrl) {
return StringUtils.startsWith(remoteUrl, GIT_PROTOCOL)
|| StringUtils.startsWith(remoteUrl, HTTPS_PROTOCOL);
}
}
}
21 changes: 10 additions & 11 deletions src/main/java/io/jenkins/plugins/checks/github/SCMFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@
import java.util.List;
import java.util.Optional;

import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;

import edu.umd.cs.findbugs.annotations.CheckForNull;

import org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials;
import org.jenkinsci.plugins.github_branch_source.GitHubSCMSource;
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition;
import org.jenkinsci.plugins.workflow.flow.FlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;

import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;

import edu.umd.cs.findbugs.annotations.Nullable;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
import jenkins.triggers.SCMTriggerItem;

import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.model.Run;
Expand All @@ -29,6 +24,10 @@
import hudson.scm.NullSCM;
import hudson.scm.SCM;
import hudson.security.ACL;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
import jenkins.triggers.SCMTriggerItem;

/**
* Facade to {@link GitHubSCMSource} and {@link GitSCM} in Jenkins.
Expand All @@ -42,7 +41,7 @@ public class SCMFacade {
* the Jenkins project
* @return the found GitHub SCM source used or empty
*/
@Nullable
@CheckForNull
public SCMSource findSCMSource(final Job<?, ?> job) {
return SCMSource.SourceByItem.findSource(job);
}
Expand Down

0 comments on commit 37de36b

Please sign in to comment.