From c7dbfed9f0af97113c32934be226d579f70d677f Mon Sep 17 00:00:00 2001 From: Matt Baker Date: Thu, 5 Dec 2013 21:13:38 -0700 Subject: [PATCH] Replace 'indexOf()' expression with 'contains()' Change-Id: Ida566a24d78174690b11d758c769b1d559b7fae9 --- .../java/com/google/gerrit/client/ui/CherryPickDialog.java | 2 +- .../java/com/google/gerrit/client/ui/MorphingTabPanel.java | 2 +- .../main/java/com/google/gerrit/httpd/raw/StaticServlet.java | 2 +- .../main/java/com/google/gerrit/launcher/GerritLauncher.java | 4 ++-- .../java/com/google/gerrit/server/account/EmailExpander.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/CherryPickDialog.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/CherryPickDialog.java index 3ffd25fcb8..1724f726c9 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/CherryPickDialog.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/CherryPickDialog.java @@ -53,7 +53,7 @@ public abstract class CherryPickDialog extends ActionDialog { LinkedList suggestions = new LinkedList(); for (final BranchInfo b : branches) { - if (b.ref().indexOf(request.getQuery()) >= 0) { + if (b.ref().contains(request.getQuery())) { suggestions.add(new BranchSuggestion(b)); } } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/MorphingTabPanel.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/MorphingTabPanel.java index 8c6fe07198..f68480e40b 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/MorphingTabPanel.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/MorphingTabPanel.java @@ -76,7 +76,7 @@ public class MorphingTabPanel extends TabPanel { public void setVisible(Widget w, boolean visible) { if (visible) { - if (visibles.indexOf(w) == -1) { + if (!visibles.contains(w)) { int origPos = widgets.indexOf(w); /* Re-insert the widget right after the first visible widget found diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticServlet.java index 3f4adba054..52b7a5c932 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/StaticServlet.java @@ -151,7 +151,7 @@ public class StaticServlet extends HttpServlet { private static boolean isUnreasonableName(String name) { if (name.length() < 1) return true; - if (name.indexOf('\\') >= 0) return true; // no windows/dos stlye paths + if (name.contains("\\")) return true; // no windows/dos style paths if (name.startsWith("../")) return true; // no "../etc/passwd" if (name.contains("/../")) return true; // no "foo/../etc/passwd" if (name.contains("/./")) return true; // "foo/./foo" is insane to ask diff --git a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java index fb2f254fdc..bd8f081ad5 100644 --- a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java +++ b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java @@ -288,10 +288,10 @@ public final class GerritLauncher { // match the name it was in the archive. // String name = ze.getName(); - if (0 <= name.lastIndexOf('/')) { + if (name.contains("/")) { name = name.substring(name.lastIndexOf('/') + 1); } - if (0 <= name.lastIndexOf('.')) { + if (name.contains(".")) { name = name.substring(0, name.lastIndexOf('.')); } if (name.isEmpty()) { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/EmailExpander.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/EmailExpander.java index 59091e66d8..c664377f2d 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/EmailExpander.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/EmailExpander.java @@ -62,7 +62,7 @@ public interface EmailExpander { @Override public boolean canExpand(final String user) { - return user.indexOf(' ') < 0; + return !user.contains(" "); } public String expand(final String user) {