This commit is contained in:
Clément Fournier committed 2022-02-16 18:59:25 +01:00
1 parent 3bd8e0281a
commit e30271f165
2 files changed
+40

No files matched your search

@@ -221,6 +221,7 @@ public class LawOfDemeterRule extends AbstractJavaRulechainRule {
private boolean isPureDataContainer(JTypeMirror type) {
return TypeTestUtil.isA(Collection.class, type)
|| TypeTestUtil.isA(Map.class, type)
|| type.isArray();
}
@@ -695,4 +695,43 @@ public final class ControlEvent {
}
]]></code>
</test-code>
<test-code>
<description>FP with enum</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import java.nio.charset.StandardCharsets;
public final class FileText {
void FileText(String fileToProcess, String charset) {
final FileText fileText = FileText(fileToProcess,
StandardCharsets.UTF_8.name());
}
}
]]></code>
</test-code>
<test-code>
<description>FP with map iteration</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import java.util.*;
import java.text.MessageFormat;
public final class FileText {
void foo(Map<String, String> messages, String messageKey) {
String checkMessage;
for (Map.Entry<String, String> entry : messages.entrySet()) {
if (messageKey.equals(entry.getKey())) {
final MessageFormat formatter = new MessageFormat(entry.getValue(), Locale.ROOT);
checkMessage = formatter.format(arguments);
break;
}
}
}
}
]]></code>
</test-code>
</test-data>