Changed replaceAll() to replace() (sonarqube)

This commit is contained in:
Erik C. Thauvin 2019-09-13 01:23:48 -07:00
parent f161ac2e79
commit 2166e166e8
7 changed files with 13 additions and 13 deletions

View file

@ -247,12 +247,12 @@ public final class Utils {
* @return The unescaped string.
*/
public static String unescapeXml(final String str) {
return str.replaceAll("&", "&")
.replaceAll("&lt;", "<")
.replaceAll("&gt;", ">")
.replaceAll("&quot;", "\"")
.replaceAll("&apos;", "'")
.replaceAll("&#39;", "'");
return str.replace("&amp;", "&")
.replace("&lt;", "<")
.replace("&gt;", ">")
.replace("&quot;", "\"")
.replace("&apos;", "'")
.replace("&#39;", "'");
}
/**

View file

@ -115,6 +115,6 @@ public final class EntriesUtils {
* @return The entry's tags.
*/
public static String buildTags(final int entryIndex, final EntryLink entry) {
return (Commands.LINK_CMD + (entryIndex + 1) + "T: " + entry.getPinboardTags().replaceAll(",", ", "));
return (Commands.LINK_CMD + (entryIndex + 1) + "T: " + entry.getPinboardTags().replace(",", ", "));
}
}

View file

@ -297,7 +297,7 @@ public class EntryLink implements Serializable {
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public final void setTags(final String tags) {
if (tags != null) {
final String[] parts = tags.replaceAll(", ", " ").replaceAll(",", " ").split(" ");
final String[] parts = tags.replace(", ", " ").replace(",", " ").split(" ");
SyndCategoryImpl tag;
String part;

View file

@ -71,7 +71,7 @@ public class Calc extends AbstractModule {
try {
final Expression calc = new ExpressionBuilder(query).build();
return query.replaceAll(" ", "") + " = " + decimalFormat.format(calc.evaluate());
return query.replace(" ", "") + " = " + decimalFormat.format(calc.evaluate());
} catch (Exception e) {
return "No idea. This is the kind of math I don't get.";
}

View file

@ -175,7 +175,7 @@ public final class CurrencyConverter extends ThreadedModule {
return new ErrorMessage("You're kidding, right?");
} else {
try {
final double amt = Double.parseDouble(cmds[0].replaceAll(",", ""));
final double amt = Double.parseDouble(cmds[0].replace(",", ""));
final double from = Double.parseDouble(EXCHANGE_RATES.get(cmds[1]
.toUpperCase(Constants.LOCALE)));
final double to = Double.parseDouble(EXCHANGE_RATES.get(cmds[3].toUpperCase(Constants.LOCALE)));

View file

@ -89,8 +89,8 @@ public final class Joke extends ThreadedModule {
//noinspection RegExpRedundantEscape
return new PublicMessage(
json.getJSONObject("value").get("joke").toString().replaceAll("\\'", "'")
.replaceAll("\\\"", "\""));
json.getJSONObject("value").get("joke").toString().replace("\\'", "'")
.replace("\\\"", "\""));
}
} catch (Exception e) {
throw new ModuleException("randomJoke()", "An error has occurred retrieving a random joke.", e);

View file

@ -65,7 +65,7 @@ class LocalProperties {
}
private static String keyToEnv(final String key) {
return key.replaceAll("-", "_").toUpperCase(Constants.LOCALE);
return key.replace("-", "_").toUpperCase(Constants.LOCALE);
}
@BeforeSuite(alwaysRun = true)