Skip to content

Commit 4f5352a

Browse files
committed
fix sonar issues
1 parent 44d60ba commit 4f5352a

22 files changed

Lines changed: 116 additions & 115 deletions

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/util/ContentPackageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private static String mergeDescriptionFileHeader(String description, FileHeaderC
173173
@SuppressWarnings("null")
174174
String fileHeaderString = StringUtils.trim(fileHeader.getCommentLines().stream()
175175
.filter(line -> !StringUtils.contains(line, "*****"))
176-
.map(line -> StringUtils.trim(line))
176+
.map(StringUtils::trim)
177177
.collect(Collectors.joining("\n")));
178178
result.append(fileHeaderString);
179179
}

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/validator/ContentPackageValidator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ private void setProperty(Object object, String propertyName, Object value)
135135
setProperty(object, object.getClass(), propertyName, value);
136136
}
137137

138-
private void setProperty(Object object, Class clazz, String propertyName, Object value)
138+
@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
139+
private void setProperty(Object object, Class<?> clazz, String propertyName, Object value)
139140
throws IllegalArgumentException, IllegalAccessException {
140141
try {
141142
Field field = clazz.getDeclaredField(propertyName);
@@ -144,7 +145,7 @@ private void setProperty(Object object, Class clazz, String propertyName, Object
144145
}
145146
catch (NoSuchFieldException ex) {
146147
// check super class
147-
Class superClass = clazz.getSuperclass();
148+
Class<?> superClass = clazz.getSuperclass();
148149
if (superClass != null) {
149150
setProperty(object, superClass, propertyName, value);
150151
}

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/crypto/CryptoStringTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import org.junit.jupiter.api.Test;
2828

29-
public class CryptoStringTest {
29+
class CryptoStringTest {
3030

3131
@Test
32-
public void testIsCryptoString() {
32+
void testIsCryptoString() {
3333
assertTrue(CryptoString.isCryptoString("{abc}"));
3434

3535
assertFalse(CryptoString.isCryptoString(null));
@@ -41,7 +41,7 @@ public void testIsCryptoString() {
4141
}
4242

4343
@Test
44-
public void testConversion() {
44+
void testConversion() {
4545
byte[] input = new byte[] { 0x01, 0x02, 0x03, 0x04, (byte)0x99, (byte)0xFF };
4646

4747
String encrypted = CryptoString.toString(input);
@@ -53,28 +53,28 @@ public void testConversion() {
5353

5454

5555
@Test
56-
public void testToByteArrayNull() throws Exception {
56+
void testToByteArrayNull() throws Exception {
5757
assertThrows(IllegalArgumentException.class, () -> {
5858
CryptoString.toByteArray(null);
5959
});
6060
}
6161

6262
@Test
63-
public void testToByteArrayIllegalString() throws Exception {
63+
void testToByteArrayIllegalString() throws Exception {
6464
assertThrows(IllegalArgumentException.class, () -> {
6565
CryptoString.toByteArray("abc");
6666
});
6767
}
6868

6969
@Test
70-
public void testToStringNull() throws Exception {
70+
void testToStringNull() throws Exception {
7171
assertThrows(IllegalArgumentException.class, () -> {
7272
CryptoString.toString(null);
7373
});
7474
}
7575

7676
@Test
77-
public void testToStringEmptyArray() throws Exception {
77+
void testToStringEmptyArray() throws Exception {
7878
assertThrows(IllegalArgumentException.class, () -> {
7979
CryptoString.toString(new byte[0]);
8080
});

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/crypto/impl/AesCryptoSupportTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import io.wcm.devops.conga.plugins.aem.crypto.CryptoString;
3232
import io.wcm.devops.conga.plugins.aem.crypto.CryptoSupport;
3333

34-
public class AesCryptoSupportTest {
34+
class AesCryptoSupportTest {
3535

3636
@Test
37-
public void testKeySupport() throws Exception {
37+
void testKeySupport() throws Exception {
3838
CryptoKeySupport keysupport = new AesCryptoSupport();
3939

4040
Key generatedKey = keysupport.generateKey();
@@ -50,7 +50,7 @@ public void testKeySupport() throws Exception {
5050
}
5151

5252
@Test
53-
public void testEncryptDecrypt() throws Exception {
53+
void testEncryptDecrypt() throws Exception {
5454
CryptoSupport crypto = new AesCryptoSupport();
5555
Key key = crypto.generateKey();
5656

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/crypto/impl/HmacCryptoKeySupportTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
import io.wcm.devops.conga.plugins.aem.crypto.CryptoKeySupport;
3030

31-
public class HmacCryptoKeySupportTest {
31+
class HmacCryptoKeySupportTest {
3232

3333
@Test
34-
public void testKeySupport() throws Exception {
34+
void testKeySupport() throws Exception {
3535
CryptoKeySupport keysupport = new HmacCryptoKeySupport();
3636

3737
Key generatedKey = keysupport.generateKey();

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/fileheader/AnyFileHeaderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
import io.wcm.devops.conga.generator.spi.context.FileHeaderContext;
3838
import io.wcm.devops.conga.generator.util.PluginManagerImpl;
3939

40-
public class AnyFileHeaderTest {
40+
class AnyFileHeaderTest {
4141

4242
private FileHeaderPlugin underTest;
4343

4444
@BeforeEach
45-
public void setUp() {
45+
void setUp() {
4646
underTest = new PluginManagerImpl().get(AnyFileHeader.NAME, FileHeaderPlugin.class);
4747
}
4848

4949
@Test
50-
public void testApply() throws Exception {
50+
void testApply() throws Exception {
5151
File file = new File("target/generation-test/fileHeader.any");
5252
FileUtils.write(file, "myany { }", StandardCharsets.UTF_8);
5353

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/handlebars/escaping/AnyEscapingStrategyTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@
2929
import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin;
3030
import io.wcm.devops.conga.generator.util.PluginManagerImpl;
3131

32-
public class AnyEscapingStrategyTest {
32+
class AnyEscapingStrategyTest {
3333

3434
private EscapingStrategyPlugin underTest;
3535

3636
@BeforeEach
37-
public void setUp() {
37+
void setUp() {
3838
underTest = new PluginManagerImpl().get(AnyEscapingStrategy.NAME, EscapingStrategyPlugin.class);
3939
}
4040

4141
@Test
42-
public void testValid() {
42+
void testValid() {
4343
assertTrue(underTest.accepts("any", null));
4444
assertEquals("\\\"\\\\", underTest.escape("\"\\", null));
4545
assertEquals("äöü߀/", underTest.escape("äöü߀/", null));
4646
}
4747

4848
@Test
49-
public void testInvalid() {
49+
void testInvalid() {
5050
assertFalse(underTest.accepts("txt", null));
5151
}
5252

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/handlebars/helper/AemCryptoEncryptHelperTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import io.wcm.devops.conga.generator.util.PluginManagerImpl;
4646
import io.wcm.devops.conga.plugins.aem.crypto.CryptoString;
4747

48-
public class AemCryptoEncryptHelperTest {
48+
class AemCryptoEncryptHelperTest {
4949

5050
private static final String INPUT = "mytext";
5151
private static final String ENCRYPTED = "{bb71ce8b28ac304c269d7f9a4697f30d7f335a3f279c7834e8f72389d86539ce}";
@@ -55,7 +55,7 @@ public class AemCryptoEncryptHelperTest {
5555

5656
@SuppressWarnings("unchecked")
5757
@BeforeEach
58-
public void setUp() {
58+
void setUp() {
5959
PluginManager pluginManager = new PluginManagerImpl();
6060
helper = pluginManager.get(AemCryptoEncryptHelper.NAME, HelperPlugin.class);
6161

@@ -67,28 +67,28 @@ public void setUp() {
6767
}
6868

6969
@Test
70-
public void testNull() throws Exception {
70+
void testNull() throws Exception {
7171
Object passwordHash = executeHelper(helper, null, new MockOptions());
7272
assertNull(passwordHash);
7373
}
7474

7575
@Test
76-
public void testWithoutKey() throws Exception {
76+
void testWithoutKey() throws Exception {
7777
assertThrows(IOException.class, () -> {
7878
executeHelper(helper, INPUT, new MockOptions(), pluginContext);
7979
});
8080
}
8181

8282
@Test
83-
public void testWithoutKey_Skip() throws Exception {
83+
void testWithoutKey_Skip() throws Exception {
8484
pluginContext.getGenericPluginConfig().put(PLUGIN_NAME,
8585
ImmutableMap.of(PARAMETER_CRYPTO_SKIP, true));
8686

8787
assertHelper(INPUT, helper, INPUT, new MockOptions(), pluginContext);
8888
}
8989

9090
@Test
91-
public void testEncrypt() throws Exception {
91+
void testEncrypt() throws Exception {
9292
pluginContext.getGenericPluginConfig().put(PLUGIN_NAME,
9393
ImmutableMap.of(PARAMETER_CRYPTO_AES_KEY_URL, "classpath:/crypto/master"));
9494

@@ -97,7 +97,7 @@ public void testEncrypt() throws Exception {
9797
}
9898

9999
@Test
100-
public void testEncrypt_Skip() throws Exception {
100+
void testEncrypt_Skip() throws Exception {
101101
pluginContext.getGenericPluginConfig().put(PLUGIN_NAME,
102102
ImmutableMap.of(PARAMETER_CRYPTO_AES_KEY_URL, "classpath:/crypto/master",
103103
PARAMETER_CRYPTO_SKIP, "true"));
@@ -106,12 +106,12 @@ public void testEncrypt_Skip() throws Exception {
106106
}
107107

108108
@Test
109-
public void testAlreadyEncrypted() throws Exception {
109+
void testAlreadyEncrypted() throws Exception {
110110
assertHelper(ENCRYPTED, helper, ENCRYPTED, new MockOptions(), pluginContext);
111111
}
112112

113113
@Test
114-
public void testFallbackWithoutKey() throws Exception {
114+
void testFallbackWithoutKey() throws Exception {
115115
assertHelper(INPUT, helper, INPUT, new MockOptions().withHash(HASH_IGNORE_MISSING_KEY, true), pluginContext);
116116
}
117117

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/handlebars/helper/AemDispatcherFilterHelperTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@
3232
import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin;
3333
import io.wcm.devops.conga.generator.util.PluginManagerImpl;
3434

35-
public class AemDispatcherFilterHelperTest {
35+
class AemDispatcherFilterHelperTest {
3636

3737
private HelperPlugin<Object> helper;
3838

3939
@SuppressWarnings("unchecked")
4040
@BeforeEach
41-
public void setUp() {
41+
void setUp() {
4242
helper = new PluginManagerImpl().get(AemDispatcherFilterHelper.NAME, HelperPlugin.class);
4343
}
4444

4545
@Test
46-
public void testUrl() throws Exception {
46+
void testUrl() throws Exception {
4747
assertHelper("{ /type \"allow\" /url '/abc(/.*)?' }",
4848
helper, ImmutableMap.of("type", "allow", "url", "/abc(/.*)?"), new MockOptions());
4949
}
5050

5151
@Test
52-
public void testAll() throws Exception {
52+
void testAll() throws Exception {
5353
Map<String, Object> map = new HashMap<>();
5454
map.put("type", "deny");
5555
map.put("method", "method1");

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/handlebars/helper/AemHttpdFilterHelperTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@
2929
import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin;
3030
import io.wcm.devops.conga.generator.util.PluginManagerImpl;
3131

32-
public class AemHttpdFilterHelperTest {
32+
class AemHttpdFilterHelperTest {
3333

3434
private HelperPlugin<Object> helper;
3535

3636
@SuppressWarnings("unchecked")
3737
@BeforeEach
38-
public void setUp() {
38+
void setUp() {
3939
helper = new PluginManagerImpl().get(AemHttpdFilterHelper.NAME, HelperPlugin.class);
4040
}
4141

4242
@Test
43-
public void testLocation() throws Exception {
43+
void testLocation() throws Exception {
4444
assertHelper("<Location \"/abc\">\n" +
4545
" <IfVersion < 2.4>\n" +
4646
" Allow from all\n" +
@@ -53,7 +53,7 @@ public void testLocation() throws Exception {
5353
}
5454

5555
@Test
56-
public void testLocationMatch() throws Exception {
56+
void testLocationMatch() throws Exception {
5757
assertHelper("<LocationMatch \"/abc(/.*)?\">\n" +
5858
" <IfVersion < 2.4>\n" +
5959
" Order Deny,Allow\n" +
@@ -67,7 +67,7 @@ public void testLocationMatch() throws Exception {
6767
}
6868

6969
@Test
70-
public void testLocationDenyAllowAdmin_NoHash() throws Exception {
70+
void testLocationDenyAllowAdmin_NoHash() throws Exception {
7171
assertHelper("<Location \"/abc\">\n" +
7272
" <IfVersion < 2.4>\n" +
7373
" Order Deny,Allow\n" +
@@ -81,7 +81,7 @@ public void testLocationDenyAllowAdmin_NoHash() throws Exception {
8181
}
8282

8383
@Test
84-
public void testLocationDenyAllowAdmin() throws Exception {
84+
void testLocationDenyAllowAdmin() throws Exception {
8585
assertHelper("<Location \"/abc\">\n" +
8686
" <IfVersion < 2.4>\n" +
8787
" Order Deny,Allow\n" +

0 commit comments

Comments
 (0)