Skip to content

Commit

Permalink
Eliminate SonarQube warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 19, 2024
1 parent af865e4 commit 4decaf3
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public boolean isAutoCrop() {
/**
* @return List of media formats with and without mandatory setting.
*/
@SuppressWarnings("java:S3776") // ignore complexity
public @NotNull MediaFormatOption @Nullable [] getMediaFormatOptions() {
Map<String, MediaFormatOption> mediaFormatOptions = new LinkedHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public class ImageMapParserImpl<T> implements ImageMapParser<T> {
private ImageMapLinkResolver linkResolver;

@Override
@SuppressWarnings({ "null", "unchecked" })
@SuppressWarnings({
"null", "unchecked",
"java:S3776", "S135" // ignore complexity
})
public @Nullable List<ImageMapArea<T>> parseMap(@Nullable String mapString) {
if (StringUtils.isBlank(mapString)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public final class ImageFileServlet extends AbstractMediaFileServlet {
private AssetStore assetStore;

@Override
@SuppressWarnings("java:S3776") // ignore complexity
protected byte @Nullable [] getBinaryData(@NotNull Resource resource, @NotNull SlingHttpServletRequest request) throws IOException {
// get media app config
MediaHandlerConfig config = AdaptTo.notNull(request, MediaHandlerConfig.class);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/wcm/handler/media/impl/MediaHandlerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ public final class MediaHandlerImpl implements MediaHandler {
*/
@NotNull
@SuppressWarnings({
"null", "unused",
"null", "unused", "java:S2589",
"java:S3776", "java:S6541", // ignore complexity
"java:S112" // allow runtime exception
"java:S112", // allow runtime exception
"java:S1192" // multiple strings
})
@SuppressFBWarnings({ "CORRECTNESS", "STYLE" })
Media processRequest(@NotNull final MediaRequest mediaRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package io.wcm.handler.mediasource.dam.impl.dynamicmedia;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

Expand Down Expand Up @@ -188,15 +187,10 @@ private static Dimension calcWidthHeight(@NotNull DamContext damContext, long wi
*/
private static String encodeDynamicMediaObject(@NotNull DamContext damContext) {
String[] pathParts = StringUtils.split(damContext.getDynamicMediaObject(), "/");
try {
for (int i = 0; i < pathParts.length; i++) {
pathParts[i] = URLEncoder.encode(pathParts[i], StandardCharsets.UTF_8.name());
// replace "+" with %20 in URL paths
pathParts[i] = StringUtils.replace(pathParts[i], "+", "%20");
}
}
catch (UnsupportedEncodingException ex) {
throw new RuntimeException("Unsupported encoding.", ex);
for (int i = 0; i < pathParts.length; i++) {
pathParts[i] = URLEncoder.encode(pathParts[i], StandardCharsets.UTF_8);
// replace "+" with %20 in URL paths
pathParts[i] = StringUtils.replace(pathParts[i], "+", "%20");
}
return StringUtils.join(pathParts, "/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ public String getFileExtension() {
}

@Override
@SuppressWarnings("java:S112") // allow runtime exception
public long getFileSize() {
Node node = this.resource.adaptTo(Node.class);
if (node != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
* Tests for {@link TransformedRenditionHandler}
*/
@ExtendWith(AemContextExtension.class)
@SuppressWarnings("java:S2699") // all tests have assertions
@SuppressWarnings({
"java:S2699", // all tests have assertions
"java:S5976" // similar tests
})
class TransformedRenditionHandlerTest {

private AemContext context = AppAemContext.newAemContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
import io.wcm.wcm.commons.contenttype.ContentType;

@ExtendWith(AemContextExtension.class)
@SuppressWarnings("java:S2699") // all tests have assertions
@SuppressWarnings({
"java:S2699", // all tests have assertions
"java:S5976" // similar tests
})
class SmartCropTest {

private final AemContext context = AppAemContext.newAemContext();
Expand Down

0 comments on commit 4decaf3

Please sign in to comment.