Fix quoting

This commit is contained in:
Clément Fournier committed 2022-04-15 21:16:33 +02:00
1 parent 3acc740925
commit bdc116e403
3 files changed
+10 -4

No files matched your search

@@ -46,6 +46,7 @@ import net.sourceforge.pmd.RuleSet.RuleSetBuilder;
import net.sourceforge.pmd.lang.rule.RuleReference;
import net.sourceforge.pmd.rules.RuleFactory;
import net.sourceforge.pmd.util.ResourceLoader;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.internal.xml.PmdXmlReporter;
import net.sourceforge.pmd.util.internal.xml.SchemaConstants;
import net.sourceforge.pmd.util.internal.xml.XmlUtil;
@@ -644,14 +645,15 @@ final class RuleSetFactory {
return new AccumulatingMessageHandler(
entry -> {
Level level = entry.getSeverity() == XmlSeverity.WARNING ? Level.WARN : Level.ERROR;
reporter.logEx(level, entry.toString(), new Object[0], entry.getCause());
String quotedText = StringUtil.quoteMessageFormat(entry.toString());
reporter.logEx(level, quotedText, new Object[0], entry.getCause());
},
XmlSeverity.WARNING
) {
@Override
protected void printSummaryLine(String kind, XmlSeverity severity, String message) {
Level level = severity == XmlSeverity.WARNING ? Level.WARN : Level.ERROR;
reporter.log(level, message);
reporter.log(level, StringUtil.quoteMessageFormat(message));
}
};
}
@@ -121,7 +121,11 @@ public class RuleFactory {
ruleReference.addExample(XmlUtil.parseTextNode(node));
break;
case PRIORITY:
ruleReference.setPriority(RulePriority.valueOf(Integer.parseInt(XmlUtil.parseTextNode(node))));
RulePriority priority = parsePriority(err, node);
if (priority == null) {
priority = RulePriority.MEDIUM;
}
ruleReference.setPriority(priority);
break;
case PROPERTIES:
setPropertyValues(ruleReference, node, err);
@@ -36,7 +36,7 @@ public final class XmlErrorMessages {
public static final String ERR__INVALID_LANG_VERSION = "Invalid language version ''{0}'' for language ''{1}'', supported versions are {2}";
public static final String WARN__DEPRECATED_USE_OF_ATTRIBUTE = "The use of the ''{0}'' attribute is deprecated. Use a nested element, e.g. {1}";
public static final String ERR__INVALID_PRIORITY_VALUE = "Not a valid priority ''{0}'', expected a number in [1,5]";
public static final String ERR__INVALID_PRIORITY_VALUE = "Not a valid priority: ''{0}'', expected a number in [1,5]";
public static final String ERR__UNSUPPORTED_PROPERTY_TYPE = "Unsupported property type ''{0}''";
private XmlErrorMessages() {