Skip to content

Commit

Permalink
JSPWIKI-1157 - Remove redundant String
Browse files Browse the repository at this point in the history
  • Loading branch information
arturobernalg authored and juanpablo-santos committed Oct 28, 2021
1 parent e07427a commit ae435be
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Map< String, Integer > checkFile( final String en, final String lang ) throws IO
System.out.println( iter.next() );
}
}
System.out.println( "" );
System.out.println( );
return metrics;
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public Map< String, Integer > diff( final String source1, final String source2 )
}
}
if( missing > 0 ) {
System.out.println( "" );
System.out.println();
}

iter = sortedNames( p2 ).iterator();
Expand All @@ -175,7 +175,7 @@ public Map< String, Integer > diff( final String source1, final String source2 )
}
}
if( outdated > 0 ) {
System.out.println( "" );
System.out.println();
}

final Map< String, Integer > diff = new HashMap<>( 2 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private String replaceCCReferrerString( final Context context, final String sour

while( matcher.find( start ) ) {
final String match = matcher.group();
sb.append( sourceText.substring( start, matcher.start() ) );
sb.append( sourceText, start, matcher.start() );
final int lastOpenBrace = sourceText.lastIndexOf( '[', matcher.start() );
final int lastCloseBrace = sourceText.lastIndexOf( ']', matcher.start() );

Expand Down Expand Up @@ -270,7 +270,7 @@ private String replaceReferrerString( final Context context, final String source

if( !matcher.group(1).isEmpty() || charBefore == '~' || charBefore == '[' ) {
// Found an escape character, so I am escaping.
sb.append( sourceText.substring( start, matcher.end() ) );
sb.append( sourceText, start, matcher.end() );
start = matcher.end();
continue;
}
Expand All @@ -291,7 +291,7 @@ private String replaceReferrerString( final Context context, final String source
//
// Construct the new string
//
sb.append( sourceText.substring( start, matcher.start() ) );
sb.append( sourceText, start, matcher.start() );
sb.append( "[" ).append( text );
if( !link.isEmpty() ) {
sb.append( "|" ).append( link );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private static String translateLists(final String content, final String sourceSy
&& (actSourceSymbol.equals("") || line.substring(0, 1).equals(actSourceSymbol)))
{
actSourceSymbol = line.substring(0, 1);
line = line.substring(1, line.length());
line = line.substring( 1 );
counter++;
}
if ((inList == -1 && counter != 1) || (inList != -1 && inList + 1 < counter))
Expand Down Expand Up @@ -358,7 +358,7 @@ private String unprotectMarkup(String content, final boolean replacePlugins)
final String protectedMarkup = c_protectionMap.get(hash);
content = content.replace(hash, protectedMarkup);
if ((protectedMarkup.length() < 3 || (protectedMarkup.length() > 2 &&
!protectedMarkup.substring(0, 3).equals("{{{")))&&replacePlugins)
!protectedMarkup.startsWith("{{{")))&&replacePlugins)
content = translateElement(content, CREOLE_PLUGIN, JSPWIKI_PLUGIN);

}
Expand Down Expand Up @@ -475,7 +475,7 @@ private String replaceImageArea(final Properties wikiProps, final String content

final int pos = contentCopy.indexOf(temp);
contentCopy = contentCopy.substring(0, pos) + protectedMarkup
+ contentCopy.substring(pos + temp.length(), contentCopy.length());
+ contentCopy.substring(pos + temp.length());
}
return contentCopy;
}
Expand All @@ -492,7 +492,7 @@ private String replaceArea(final String content, final String markupRegex, final
protectedMarkup = protectedMarkup.replaceAll(replaceSource, replaceTarget);
final int pos = contentCopy.indexOf(temp);
contentCopy = contentCopy.substring(0, pos) + protectedMarkup
+ contentCopy.substring(pos + temp.length(), contentCopy.length());
+ contentCopy.substring(pos + temp.length() );
}
return contentCopy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ private Element handleGeneralList()
{
// Substitute all but the last character (keep the expressed bullet preference)
strBullets = (numBullets > 1 ? m_genlistBulletBuffer.substring(0, numBullets-1) : "")
+ strBullets.substring(numBullets-1, numBullets);
+ strBullets.charAt( numBullets-1 );
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private void addEntryHTML( final Context context, final DateFormat entryFormat,
}
cutoff++;
}
buffer.append(html.substring(0, cutoff));
buffer.append( html, 0, cutoff );
if (hasBeenCutOff) {
buffer.append( " <a href=\"" ).append( entryCtx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), entry.getName() ) ).append( "\">" ).append( rb.getString( "weblogentryplugin.more" ) ).append( "</a>\n" );
}
Expand Down
6 changes: 3 additions & 3 deletions jspwiki-util/src/main/java/org/apache/wiki/util/TextUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public static String replaceString( final String orig, final String src, final S
int last = 0;

while ( ( start = orig.indexOf( src,end ) ) != -1 ) {
res.append( orig.substring( last, start ) );
res.append( orig, last, start );
res.append( dest );
end = start + src.length();
last = start + src.length();
Expand Down Expand Up @@ -291,7 +291,7 @@ public static String replaceStringCaseUnsensitive( final String orig, final Stri
final String origCaseUnsn = orig.toLowerCase();
final String srcCaseUnsn = src.toLowerCase();
while( ( start = origCaseUnsn.indexOf( srcCaseUnsn, end ) ) != -1 ) {
res.append( orig.substring( last, start ) );
res.append( orig, last, start );
res.append( dest );
end = start + src.length();
last = start + src.length();
Expand Down Expand Up @@ -829,7 +829,7 @@ public static String generateRandomPassword() {
final StringBuilder pw = new StringBuilder();
for( int i = 0; i < PASSWORD_LENGTH; i++ ) {
final int index = ( int )( RANDOM.nextDouble() * PWD_BASE.length() );
pw.append(PWD_BASE.substring(index, index + 1));
pw.append(PWD_BASE.charAt( index ));
}
return pw.toString();
}
Expand Down

0 comments on commit ae435be

Please sign in to comment.