diff --git a/src/main/java/io/wcm/handler/media/MediaComponentPropertyResolver.java b/src/main/java/io/wcm/handler/media/MediaComponentPropertyResolver.java index fbd95198..21c2111b 100644 --- a/src/main/java/io/wcm/handler/media/MediaComponentPropertyResolver.java +++ b/src/main/java/io/wcm/handler/media/MediaComponentPropertyResolver.java @@ -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 mediaFormatOptions = new LinkedHashMap<>(); diff --git a/src/main/java/io/wcm/handler/media/imagemap/impl/ImageMapParserImpl.java b/src/main/java/io/wcm/handler/media/imagemap/impl/ImageMapParserImpl.java index 0a9a34d7..de27898a 100644 --- a/src/main/java/io/wcm/handler/media/imagemap/impl/ImageMapParserImpl.java +++ b/src/main/java/io/wcm/handler/media/imagemap/impl/ImageMapParserImpl.java @@ -51,7 +51,10 @@ public class ImageMapParserImpl implements ImageMapParser { private ImageMapLinkResolver linkResolver; @Override - @SuppressWarnings({ "null", "unchecked" }) + @SuppressWarnings({ + "null", "unchecked", + "java:S3776", "S135" // ignore complexity + }) public @Nullable List> parseMap(@Nullable String mapString) { if (StringUtils.isBlank(mapString)) { return null; diff --git a/src/main/java/io/wcm/handler/media/impl/ImageFileServlet.java b/src/main/java/io/wcm/handler/media/impl/ImageFileServlet.java index 6d567dd8..05ba4fba 100644 --- a/src/main/java/io/wcm/handler/media/impl/ImageFileServlet.java +++ b/src/main/java/io/wcm/handler/media/impl/ImageFileServlet.java @@ -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); diff --git a/src/main/java/io/wcm/handler/media/impl/MediaHandlerImpl.java b/src/main/java/io/wcm/handler/media/impl/MediaHandlerImpl.java index 7d0c2a6b..75942a1c 100644 --- a/src/main/java/io/wcm/handler/media/impl/MediaHandlerImpl.java +++ b/src/main/java/io/wcm/handler/media/impl/MediaHandlerImpl.java @@ -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) { diff --git a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java index 060d747c..67359e8e 100644 --- a/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java +++ b/src/main/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/DynamicMediaPath.java @@ -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; @@ -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, "/"); } diff --git a/src/main/java/io/wcm/handler/mediasource/inline/InlineRendition.java b/src/main/java/io/wcm/handler/mediasource/inline/InlineRendition.java index a739bec7..db0e9b71 100644 --- a/src/main/java/io/wcm/handler/mediasource/inline/InlineRendition.java +++ b/src/main/java/io/wcm/handler/mediasource/inline/InlineRendition.java @@ -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) { diff --git a/src/test/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandlerTest.java b/src/test/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandlerTest.java index 1a13547b..6fd047f0 100644 --- a/src/test/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandlerTest.java +++ b/src/test/java/io/wcm/handler/mediasource/dam/impl/TransformedRenditionHandlerTest.java @@ -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(); diff --git a/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/SmartCropTest.java b/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/SmartCropTest.java index 6fd63595..8bbcdcc5 100644 --- a/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/SmartCropTest.java +++ b/src/test/java/io/wcm/handler/mediasource/dam/impl/dynamicmedia/SmartCropTest.java @@ -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();