Skip to content

Commit

Permalink
fix: sonarqube fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Jul 6, 2018
1 parent 41bfdce commit 198f86c
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 37 deletions.
2 changes: 1 addition & 1 deletion release.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def mergePullRequest(prId){
}

}
return this;
return this
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ContainerCreateConfig environment(String envPropsFile, Map<String, String
String value = entry.getValue();
if (value == null) {
value = "";
} else if(value.matches("^\\+\\$\\{.*\\}$")) {
} else if(value.matches("^\\+\\$\\{.*}$")) {
/*
* This case is to handle the Maven interpolation issue which used
* to occur when using ${..} only without any suffix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected String[] getArgs() {
}
}
args.add(machine.getName());
return args.toArray(new String[args.size()]);
return args.toArray(new String[0]);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ private void addContainerNetwork(RunImageConfiguration runConfig, List<String> r
private void addDependsOn(RunImageConfiguration runConfig, List<String> ret) {
// Only used in custom networks.
if (runConfig.getNetworkingConfig().isCustomNetwork()) {
for (String link : runConfig.getDependsOn()) {
ret.add(link);
}
ret.addAll(runConfig.getDependsOn());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ RestartPolicy getRestartPolicy() {

RestartPolicy.Builder builder = new RestartPolicy.Builder();
if (restart.contains(":")) {
String[] parts = restart.split("\\:", 2);
String[] parts = restart.split(":", 2);
builder.name(parts[0]).retry(Integer.valueOf(parts[1]));
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,11 @@ public enum ConfigKey {
// Convert to camel case
private String toVarName(String s) {
String[] parts = s.split("_");
String var = parts[0].toLowerCase();
StringBuilder var = new StringBuilder(parts[0].toLowerCase());
for (int i = 1; i < parts.length; i++) {
var = var + parts[i].substring(0, 1).toUpperCase() +
parts[i].substring(1).toLowerCase();
var.append(parts[i].substring(0, 1).toUpperCase()).append(parts[i].substring(1).toLowerCase());
}
return var;
return var.toString();
}

public String asPropertyKey(String prefix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.eclipse.aether.RepositorySystemSession;

/**
* A service for executing goals on configured plugins.
Expand All @@ -39,11 +40,6 @@
* @author roland
* @since 01/07/15
*/


/**
* Service for calling other plugin goals
*/
public class MojoExecutionService {

private final MavenProject project;
Expand Down Expand Up @@ -100,18 +96,18 @@ private MojoExecution getMojoExecution(String executionId, MojoDescriptor mojoDe
}

PluginDescriptor getPluginDescriptor(MavenProject project, Plugin plugin)
throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, PluginNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, MojoFailureException {
throws InvocationTargetException, IllegalAccessException, MojoFailureException {

try {
Method loadPlugin = pluginManager.getClass().getMethod("loadPluginDescriptor",
plugin.getClass(),
project.getClass(),
session.getClass());
return (PluginDescriptor) loadPlugin.invoke(plugin, project, session);
return (PluginDescriptor) loadPlugin.invoke(pluginManager, plugin, project, session);
} catch (NoSuchMethodException exp) {
try {
// Fallback for older Maven versions
Object repositorySession = session.getRepositorySession();
RepositorySystemSession repositorySession = session.getRepositorySession();
Method loadPlugin = pluginManager.getClass().getMethod("loadPlugin",
plugin.getClass(),
project.getRemotePluginRepositories().getClass(),
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/fabric8/maven/docker/util/EnvUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,11 @@ public static boolean isValidWindowsFileName(String filename) {
" $ # and end of string \n" +
") # End negative lookahead assertion. \n" +
"[^<>:\"/\\\\|?*\\x00-\\x1F]* # Zero or more valid filename chars.\n" +
"[^<>:\"/\\\\|?*\\x00-\\x1F\\ .] # Last char is not a space or dot. \n" +
"[^<>:\"/\\\\|?*\\x00-\\x1F .] # Last char is not a space or dot. \n" +
"$ # Anchor to end of string. ",
Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.COMMENTS);
Matcher matcher = pattern.matcher(filename);
boolean isMatch = matcher.matches();
return isMatch;
return matcher.matches();
}

}
19 changes: 8 additions & 11 deletions src/main/java/io/fabric8/maven/docker/util/StartOrderResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ public class StartOrderResolver {
public static final int MAX_RESOLVE_RETRIES = 10;

private final QueryService queryService;

private final List<Resolvable> secondPass;
private final Set<String> processedImages;

public static List<Resolvable> resolve(QueryService queryService, List<Resolvable> convertToResolvables) {
return new StartOrderResolver(queryService).resolve(convertToResolvables);
}

private StartOrderResolver(QueryService queryService) {
this.queryService = queryService;

this.secondPass = new ArrayList<>();
this.processedImages = new HashSet<>();
}


// Check images for volume / link dependencies and return it in the right order.
// Only return images which should be run
// Images references via volumes but with no run configuration are started once to create
Expand Down Expand Up @@ -95,7 +95,7 @@ private String remainingImagesDescription() {
}

private void resolveImageDependencies(List<Resolvable> resolved) throws DockerAccessException, ResolveSteadyStateException {
boolean changed = false;
boolean changed = false;
Iterator<Resolvable> iterator = secondPass.iterator();

while (iterator.hasNext()) {
Expand Down Expand Up @@ -129,15 +129,12 @@ private boolean hasRequiredDependencies(Resolvable config) throws DockerAccessEx
}
return false;
}

return true;
}

private List<String> extractDependentImagesFor(Resolvable config) {
LinkedHashSet<String> ret = new LinkedHashSet<>();
for (String id : config.getDependencies()) {
ret.add(id);
}
LinkedHashSet<String> ret = new LinkedHashSet<>(config.getDependencies());
return ret.isEmpty() ? null : new ArrayList<>(ret);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public void testGetUrlFromEnvironment() throws MojoExecutionException, IOExcepti
try {
assertEquals("npipe:////./pipe/docker_engine", detector.detectConnectionParameter(null, null).getUrl());
} catch (IllegalArgumentException expectedIfNoUnixSocket) {
// expected if no unix socket
}
} else {
try {
assertEquals("unix:///var/run/docker.sock", detector.detectConnectionParameter(null, null).getUrl());
} catch (IllegalArgumentException expectedIfNoUnixSocket) {
// expected if no unix socket
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void simple() {
config.getStandardMode("fail");
fail("Test " + i % 8);
} catch (IllegalArgumentException exp) {

// expected
}
}
assertEquals(Boolean.parseBoolean((String) data[i + 4]), config.isStandardNetwork());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ imageConfiguration, props()
BuildImageConfiguration buildConfiguration = configs.get(0).getBuildConfiguration();
assertNotNull(buildConfiguration);
buildConfiguration.initAndValidate(null);
assertEquals("/some/path", buildConfiguration.getDockerFile().getAbsolutePath().toString());
assertEquals("/some/path", buildConfiguration.getDockerFile().getAbsolutePath());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void namesUsedByDockerTests() {
try {
new ImageName(i);
fail(String.format("Name '%s' should fail",i));
} catch (IllegalArgumentException exp) {};
} catch (IllegalArgumentException exp) { /* expected */};
}

String[] legal = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void handle(HttpExchange httpExchange) throws IOException {
try {
wait(700, new HttpPingChecker(httpPingUrl));
} catch (TimeoutException | PreconditionFailedException exp) {

// expected
}
}

Expand Down

0 comments on commit 198f86c

Please sign in to comment.