mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-18 09:44:47 +08:00
Fix checkstyle violations
This commit is contained in:
@@ -77,7 +77,7 @@ public class InitializrAutoConfiguration {
|
||||
public InitializrAutoConfiguration(
|
||||
ObjectProvider<List<ProjectRequestPostProcessor>> postProcessors) {
|
||||
List<ProjectRequestPostProcessor> list = postProcessors.getIfAvailable();
|
||||
this.postProcessors = list != null ? list : new ArrayList<>();
|
||||
this.postProcessors = (list != null ? list : new ArrayList<>());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@@ -65,7 +65,7 @@ public class InitializrMetadataV21JsonMapper extends InitializrMetadataV2JsonMap
|
||||
}
|
||||
|
||||
private ObjectNode dependenciesLink(String appUrl) {
|
||||
String uri = appUrl != null ? appUrl + "/dependencies" : "/dependencies";
|
||||
String uri = (appUrl != null ? appUrl + "/dependencies" : "/dependencies");
|
||||
UriTemplate uriTemplate = new UriTemplate(uri, this.dependenciesVariables);
|
||||
ObjectNode result = nodeFactory().objectNode();
|
||||
result.put("href", uriTemplate.toString());
|
||||
|
@@ -114,7 +114,7 @@ public class InitializrMetadataV2JsonMapper implements InitializrMetadataJsonMap
|
||||
}
|
||||
|
||||
private String generateTemplatedUri(String appUrl, Type type) {
|
||||
String uri = appUrl != null ? appUrl + type.getAction() : type.getAction();
|
||||
String uri = (appUrl != null ? appUrl + type.getAction() : type.getAction());
|
||||
uri = uri + "?type=" + type.getId();
|
||||
UriTemplate uriTemplate = new UriTemplate(uri, this.templateVariables);
|
||||
return uriTemplate.toString();
|
||||
|
@@ -52,7 +52,7 @@ public abstract class AbstractInitializrController {
|
||||
this.metadataProvider = metadataProvider;
|
||||
this.linkTo = (link) -> {
|
||||
String result = resourceUrlProvider.getForLookupPath(link);
|
||||
return result == null ? link : result;
|
||||
return (result != null ? result : link);
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -203,8 +203,8 @@ public class MainController extends AbstractInitializrController {
|
||||
private ResponseEntity<String> dependenciesFor(InitializrMetadataVersion version,
|
||||
String bootVersion) {
|
||||
InitializrMetadata metadata = this.metadataProvider.get();
|
||||
Version v = bootVersion != null ? Version.parse(bootVersion)
|
||||
: Version.parse(metadata.getBootVersions().getDefault().getId());
|
||||
Version v = (bootVersion != null ? Version.parse(bootVersion)
|
||||
: Version.parse(metadata.getBootVersions().getDefault().getId()));
|
||||
DependencyMetadata dependencyMetadata = this.dependencyMetadataProvider
|
||||
.get(metadata, v);
|
||||
String content = new DependencyMetadataV21JsonMapper().write(dependencyMetadata);
|
||||
@@ -324,15 +324,15 @@ public class MainController extends AbstractInitializrController {
|
||||
try {
|
||||
return URLEncoder.encode(tmp, "UTF-8") + "." + extension;
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("Cannot encode URL", e);
|
||||
catch (UnsupportedEncodingException ex) {
|
||||
throw new IllegalStateException("Cannot encode URL", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getWrapperScript(ProjectRequest request) {
|
||||
String script = "gradle".equals(request.getBuild()) ? "gradlew" : "mvnw";
|
||||
return request.getBaseDir() != null ? request.getBaseDir() + "/" + script
|
||||
: script;
|
||||
String script = ("gradle".equals(request.getBuild()) ? "gradlew" : "mvnw");
|
||||
return (request.getBaseDir() != null ? request.getBaseDir() + "/" + script
|
||||
: script);
|
||||
}
|
||||
|
||||
private ResponseEntity<byte[]> upload(File download, File dir, String fileName,
|
||||
|
@@ -79,8 +79,8 @@ public class DefaultInitializrMetadataProvider implements InitializrMetadataProv
|
||||
return new SpringBootMetadataReader(this.objectMapper, this.restTemplate,
|
||||
url).getBootVersions();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.warn("Failed to fetch spring boot metadata", e);
|
||||
catch (Exception ex) {
|
||||
log.warn("Failed to fetch spring boot metadata", ex);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@@ -57,7 +57,7 @@ public class UiController {
|
||||
List<DependencyGroup> dependencyGroups = this.metadataProvider.get()
|
||||
.getDependencies().getContent();
|
||||
List<DependencyItem> content = new ArrayList<>();
|
||||
Version v = StringUtils.isEmpty(version) ? null : Version.parse(version);
|
||||
Version v = (StringUtils.isEmpty(version) ? null : Version.parse(version));
|
||||
dependencyGroups.forEach((g) -> g.getContent().forEach((d) -> {
|
||||
if (v != null && d.getVersionRange() != null) {
|
||||
if (d.match(v)) {
|
||||
|
@@ -48,7 +48,7 @@ public abstract class AbstractInitializrControllerIntegrationTests
|
||||
|
||||
@Override
|
||||
protected String createUrl(String context) {
|
||||
return context.startsWith("/") ? context : "/" + context;
|
||||
return (context.startsWith("/") ? context : "/" + context);
|
||||
}
|
||||
|
||||
public MockMvcClientHttpRequestFactory getRequests() {
|
||||
|
@@ -226,8 +226,8 @@ public abstract class AbstractInitializrIntegrationTests {
|
||||
}
|
||||
return new ProjectAssert(project);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("Cannot unpack archive", e);
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Cannot unpack archive", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ public abstract class AbstractInitializrIntegrationTests {
|
||||
return new JSONObject(content);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Cannot read JSON from path=" + path);
|
||||
}
|
||||
}
|
||||
|
@@ -202,7 +202,7 @@ final class JsonFieldProcessor {
|
||||
List<String> segments, Match parent) {
|
||||
this.payload = payload;
|
||||
this.path = path;
|
||||
this.segments = segments == null ? path.getSegments() : segments;
|
||||
this.segments = (segments != null ? segments : path.getSegments());
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user