smolnar82 commented on a change in pull request #201: KNOX-2131 - Fixed
sonarcloud bugs
URL: https://github.com/apache/knox/pull/201#discussion_r347560281
##########
File path:
gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlFilterReaderBase.java
##########
@@ -264,19 +262,20 @@ private String getNamespace( String prefix ) {
return getNamespaces().get( prefix );
}
- private QName getQName( String name ) {
- String prefix;
- String local;
- int colon = ( name == null ? -1 : name.indexOf( ':' ) );
- if( colon < 0 ) {
- prefix = "";
- local = name;
- } else {
- prefix = name.substring( 0, colon );
- local = ( colon + 1 < name.length() ? name.substring( colon + 1 ) : ""
);
- }
- String namespace = getNamespace( prefix );
- return new QName( namespace, local, prefix );
+ private QName getQName(String name) {
+ final int colon = name == null ? -1 : name.indexOf(':');
+ final String prefix = getPrefix(name, colon);
+ final String local = getLocal(name, colon);
+ final String namespace = getNamespace(prefix);
+ return new QName(namespace, local, prefix);
+ }
+
+ private String getPrefix(String name, final int colon) {
+ return name != null && colon > 0 ? name.substring(0, colon) : "";
+ }
+
+ private String getLocal(String name, final int colon) {
+ return name != null && colon > 0 ? (colon + 1 < name.length() ?
name.substring(colon + 1) : "") : name;
Review comment:
Done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services