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. * @return The unescaped string.
*/ */
public static String unescapeXml(final String str) { public static String unescapeXml(final String str) {
return str.replaceAll("&", "&") return str.replace("&", "&")
.replaceAll("&lt;", "<") .replace("&lt;", "<")
.replaceAll("&gt;", ">") .replace("&gt;", ">")
.replaceAll("&quot;", "\"") .replace("&quot;", "\"")
.replaceAll("&apos;", "'") .replace("&apos;", "'")
.replaceAll("&#39;", "'"); .replace("&#39;", "'");
} }
/** /**

View file

@ -115,6 +115,6 @@ public final class EntriesUtils {
* @return The entry's tags. * @return The entry's tags.
*/ */
public static String buildTags(final int entryIndex, final EntryLink entry) { 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") @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public final void setTags(final String tags) { public final void setTags(final String tags) {
if (tags != null) { if (tags != null) {
final String[] parts = tags.replaceAll(", ", " ").replaceAll(",", " ").split(" "); final String[] parts = tags.replace(", ", " ").replace(",", " ").split(" ");
SyndCategoryImpl tag; SyndCategoryImpl tag;
String part; String part;

View file

@ -71,7 +71,7 @@ public class Calc extends AbstractModule {
try { try {
final Expression calc = new ExpressionBuilder(query).build(); final Expression calc = new ExpressionBuilder(query).build();
return query.replaceAll(" ", "") + " = " + decimalFormat.format(calc.evaluate()); return query.replace(" ", "") + " = " + decimalFormat.format(calc.evaluate());
} catch (Exception e) { } catch (Exception e) {
return "No idea. This is the kind of math I don't get."; 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?"); return new ErrorMessage("You're kidding, right?");
} else { } else {
try { 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] final double from = Double.parseDouble(EXCHANGE_RATES.get(cmds[1]
.toUpperCase(Constants.LOCALE))); .toUpperCase(Constants.LOCALE)));
final double to = Double.parseDouble(EXCHANGE_RATES.get(cmds[3].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 //noinspection RegExpRedundantEscape
return new PublicMessage( return new PublicMessage(
json.getJSONObject("value").get("joke").toString().replaceAll("\\'", "'") json.getJSONObject("value").get("joke").toString().replace("\\'", "'")
.replaceAll("\\\"", "\"")); .replace("\\\"", "\""));
} }
} catch (Exception e) { } catch (Exception e) {
throw new ModuleException("randomJoke()", "An error has occurred retrieving a random joke.", 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) { private static String keyToEnv(final String key) {
return key.replaceAll("-", "_").toUpperCase(Constants.LOCALE); return key.replace("-", "_").toUpperCase(Constants.LOCALE);
} }
@BeforeSuite(alwaysRun = true) @BeforeSuite(alwaysRun = true)