Skip to content

Commit

Permalink
fix checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Ramillien committed Jan 4, 2019
1 parent 5cb35bf commit c1fb600
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
Expand Up @@ -248,7 +248,8 @@ private void tryLoadProjectList() {
}
sshConnection.disconnect();
} else {
logger.warn("Could not connect to Gerrit server when updating Gerrit project list: Server is not connected (timeout)");
logger.warn("Could not connect to Gerrit server when updating Gerrit project list: "
+ "Server is not connected (timeout)");
}
} catch (SshException ex) {
logger.warn("Could not connect to Gerrit server when updating Gerrit project list: ", ex);
Expand Down
Expand Up @@ -53,7 +53,6 @@
import com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginDraftPublishedEvent;
import com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginGerritEvent;
import com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent;
import com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginWipStateChangedEvent.PluginWorkInProgressStateChangedEventDescriptor;
import com.sonyericsson.hudson.plugins.gerrit.trigger.version.GerritVersionChecker;
import com.sonyericsson.hudson.plugins.gerrit.trigger.version.GerritVersionChecker.Feature;

Expand Down Expand Up @@ -81,7 +80,6 @@
import hudson.model.AutoCompletionCandidates;
import hudson.model.Cause;
import hudson.model.Computer;
import hudson.model.Descriptor;
import hudson.model.Executor;
import hudson.model.Hudson;
import hudson.model.Item;
Expand Down Expand Up @@ -980,15 +978,17 @@ public boolean isInteresting(GerritTriggeredEvent event) {
&& p.isInteresting(changeBasedEvent.getChange().getProject(),
changeBasedEvent.getChange().getBranch(),
changeBasedEvent.getChange().getTopic())) {

if (event instanceof WipStateChanged && !isServerSupportFeature(event, GerritVersionChecker.Feature.wipStateChanged)) {

if (event instanceof WipStateChanged
&& !isServerSupportFeature(event, GerritVersionChecker.Feature.wipStateChanged)) {
return false;
}

if (event instanceof PrivateStateChanged && !isServerSupportFeature(event, GerritVersionChecker.Feature.privateStateChanged)){

if (event instanceof PrivateStateChanged
&& !isServerSupportFeature(event, GerritVersionChecker.Feature.privateStateChanged)) {
return false;
}

boolean containsFilePathsOrForbiddenFilePaths =
((p.getFilePaths() != null && p.getFilePaths().size() > 0)
|| (p.getForbiddenFilePaths() != null && p.getForbiddenFilePaths().size() > 0));
Expand Down Expand Up @@ -1805,16 +1805,19 @@ public boolean isTriggerOnDraftPublishedEnabled() {
return GerritVersionChecker
.isCorrectVersion(GerritVersionChecker.Feature.triggerOnDraftPublished, serverName);
}

/**
* helper function to check if server support specific feature
* if "any server" is selected, use the server provided by event
* if "any server" is selected, use the server provided by event
* @param event target event
* @param f the feature
* @return true if the feature is supported by server
*/
private boolean isServerSupportFeature(GerritTriggeredEvent event, Feature f) {
String svrName = (isAnyServer())? initializeProvider(event).getName() : serverName;
String svrName = serverName;
if (isAnyServer()) {
svrName = initializeProvider(event).getName();
}
boolean isSupported = GerritVersionChecker.isCorrectVersion(f, svrName);
if (!isSupported) {
logger.warn("server[{}] doesn't support {}", svrName, f.getDisplayName());
Expand Down Expand Up @@ -1931,7 +1934,7 @@ public Object readResolve() throws ObjectStreamException {
public TriggerDescriptor getDescriptor() {
return Jenkins.getInstance().getDescriptorByType(DescriptorImpl.class);
}

/**
* The Descriptor for the Trigger.
*/
Expand Down
Expand Up @@ -24,7 +24,6 @@
package com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events;

import com.sonymobile.tools.gerrit.gerritevents.dto.GerritChangeKind;
import com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeBasedEvent;
import com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent;
import com.sonymobile.tools.gerrit.gerritevents.dto.events.PatchsetCreated;
import com.sonyericsson.hudson.plugins.gerrit.trigger.Messages;
Expand Down Expand Up @@ -116,7 +115,7 @@ public boolean isExcludeTrivialRebase() {
public boolean isExcludeNoCodeChange() {
return excludeNoCodeChange;
}

/**
* Getter for the excludePrivateState field.
* @return excludePrivateState
Expand Down
Expand Up @@ -67,12 +67,12 @@ public static enum Feature {
* Gerrit CommentAdded always contains approval information, added in Gerrit 2.13.
*/
commentAlwaysApproval("CommentAdded always contains approval", "2.13"),

/**
* WIPStateChanged events, added in Gerrit 2.15.
*/
wipStateChanged("WIPStateChanged events", "2.15"),

/**
* PrivateStateChanged events, added in Gerrit 2.15.
*/
Expand Down
Expand Up @@ -22,7 +22,8 @@ public class PluginPatchsetCreatedEventTest {
*/
@Test
public void shouldFireOnAllTypeOfPatchset() {
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent = new PluginPatchsetCreatedEvent(false, false, false, false, false);
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent =
new PluginPatchsetCreatedEvent(false, false, false, false, false);
PatchsetCreated patchsetCreated = new PatchsetCreated();
patchsetCreated.setPatchset(new PatchSet());

Expand All @@ -37,7 +38,8 @@ public void shouldFireOnAllTypeOfPatchset() {
*/
@Test
public void shouldNotFireOnDraftPatchsetWhenExcluded() {
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent = new PluginPatchsetCreatedEvent(true, false, false, false, false);
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent =
new PluginPatchsetCreatedEvent(true, false, false, false, false);
PatchsetCreated patchsetCreated = new PatchsetCreated();
patchsetCreated.setPatchset(new PatchSet());

Expand All @@ -53,7 +55,8 @@ public void shouldNotFireOnDraftPatchsetWhenExcluded() {
*/
@Test
public void shouldNotFireOnTrivialRebaseWhenExcluded() {
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent = new PluginPatchsetCreatedEvent(false, true, false, false, false);
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent =
new PluginPatchsetCreatedEvent(false, true, false, false, false);
PatchsetCreated patchsetCreated = new PatchsetCreated();
patchsetCreated.setPatchset(new PatchSet());

Expand All @@ -69,7 +72,8 @@ public void shouldNotFireOnTrivialRebaseWhenExcluded() {
*/
@Test
public void shouldNotFireOnNoCodeChangeWhenExcluded() {
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent = new PluginPatchsetCreatedEvent(false, false, true, false, false);
PluginPatchsetCreatedEvent pluginPatchsetCreatedEvent =
new PluginPatchsetCreatedEvent(false, false, true, false, false);
PatchsetCreated patchsetCreated = new PatchsetCreated();
patchsetCreated.setPatchset(new PatchSet());

Expand Down

0 comments on commit c1fb600

Please sign in to comment.