maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [3/5] git commit: Use String.contains() instead of indexOf() when possible
Date Thu, 14 Nov 2013 03:13:55 GMT
Use String.contains() instead of indexOf() when possible


Project: http://git-wip-us.apache.org/repos/asf/maven-wagon/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-wagon/commit/e4db9c20
Tree: http://git-wip-us.apache.org/repos/asf/maven-wagon/tree/e4db9c20
Diff: http://git-wip-us.apache.org/repos/asf/maven-wagon/diff/e4db9c20

Branch: refs/heads/master
Commit: e4db9c20a379befe2fe1d2151852155368a3df89
Parents: 6e09858
Author: Emmanuel Bourg <ebourg@apache.org>
Authored: Wed Nov 13 12:09:06 2013 +0100
Committer: Emmanuel Bourg <ebourg@apache.org>
Committed: Wed Nov 13 12:09:06 2013 +0100

----------------------------------------------------------------------
 .../maven/wagon/providers/scm/AbstractScmSvnWagonTest.java    | 2 +-
 .../maven/wagon/providers/ssh/external/ScpExternalWagon.java  | 7 +++----
 .../maven/wagon/providers/ssh/jsch/AbstractJschWagon.java     | 2 +-
 .../org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java   | 4 ++--
 .../org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java  | 2 +-
 5 files changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/e4db9c20/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
index 1c9ce05..2b4c7bd 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
@@ -53,7 +53,7 @@ public abstract class AbstractScmSvnWagonTest
 
         // TODO: this is a hack for windows
         // Note: why not use File.toURL() ?
-        if ( repository.indexOf( ":" ) >= 0 )
+        if ( repository.contains( ":" ) )
         {
             repository = "/" + repository;
         }

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/e4db9c20/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
b/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
index 1a15e7e..849ff4f 100644
--- a/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
+++ b/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
@@ -217,7 +217,7 @@ public class ScpExternalWagon
 
     protected boolean isPuTTY()
     {
-        return sshExecutable.toLowerCase( Locale.ENGLISH ).indexOf( "plink" ) >= 0;
+        return sshExecutable.toLowerCase( Locale.ENGLISH ).contains( "plink" );
     }
 
     private Commandline createBaseCommandLine( boolean putty, String executable, File privateKey
)
@@ -310,8 +310,7 @@ public class ScpExternalWagon
             int exitCode = CommandLineUtils.executeCommandLine( cl, null, err );
             if ( exitCode != 0 )
             {
-                if ( !put && err.getOutput().trim().toLowerCase( Locale.ENGLISH ).indexOf(
"no such file or directory" )
-                    != -1 )
+                if ( !put && err.getOutput().trim().toLowerCase( Locale.ENGLISH ).contains(
"no such file or directory" ))
                 {
                     throw new ResourceDoesNotExistException( err.getOutput() );
                 }
@@ -336,7 +335,7 @@ public class ScpExternalWagon
 
     boolean isPuTTYSCP()
     {
-        return scpExecutable.toLowerCase( Locale.ENGLISH ).indexOf( "pscp" ) >= 0;
+        return scpExecutable.toLowerCase( Locale.ENGLISH ).contains( "pscp" );
     }
 
     private String normalizeResource( Resource resource )

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/e4db9c20/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
index cc0e041..c065474 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
@@ -272,7 +272,7 @@ public abstract class AbstractJschWagon
             {
                 throw new UnknownHostException( host, e );
             }
-            else if ( e.getMessage().indexOf( "HostKey has been changed" ) >= 0 )
+            else if ( e.getMessage().contains( "HostKey has been changed" ) )
             {
                 throw new KnownHostChangedException( host, e );
             }

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/e4db9c20/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
index b167a41..9ce7561 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
@@ -258,7 +258,7 @@ public class ScpWagon
 
             if ( exitCode != COPY_START_CHAR )
             {
-                if ( exitCode == 1 && ( line.indexOf( "No such file or directory"
) != -1
+                if ( exitCode == 1 && ( line.contains( "No such file or directory"
)
                     || line.indexOf( "no such file or directory" ) != 1 ) )
                 {
                     throw new ResourceDoesNotExistException( line );
@@ -402,7 +402,7 @@ public class ScpWagon
     private void handleIOException( Resource resource, IOException e )
         throws TransferFailedException
     {
-        if ( e.getMessage().indexOf( "set mode: Operation not permitted" ) >= 0 )
+        if ( e.getMessage().contains( "set mode: Operation not permitted" ) )
         {
             fireTransferDebug( e.getMessage() );
         }

http://git-wip-us.apache.org/repos/asf/maven-wagon/blob/e4db9c20/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
----------------------------------------------------------------------
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
index e8b7388..9a2dace 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
@@ -242,7 +242,7 @@ public class SftpWagon
             {
                 throw new ResourceDoesNotExistException( e.toString(), e );
             }
-            else if ( e.toString().trim().indexOf( "Can't change directory" ) != -1 )
+            else if ( e.toString().trim().contains( "Can't change directory" ) )
             {
                 throw new ResourceDoesNotExistException( e.toString(), e );
             }   


Mime
View raw message