Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonarqube Fixes #299

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public class Five extends One {
private int two;
private boolean three;
private char four;
private StringBuffer five;
private CharSequence five;

public Five(String one, int two, boolean three, char four, StringBuffer five) {
public Five(String one, int two, boolean three, char four, CharSequence five) {
super(one);
this.two = two;
this.three = three;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class FiveBean extends OneBean {
private int two;
private boolean three;
private char four;
private StringBuffer five;
private CharSequence five;

public int getTwo() {
return this.two;
Expand All @@ -49,11 +49,11 @@ public void setFour(char four) {
this.four = four;
}

public StringBuffer getFive() {
public CharSequence getFive() {
return this.five;
}

public void setFive(StringBuffer five) {
public void setFive(CharSequence five) {
this.five = five;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class SerializableFive extends SerializableOne {
private int two;
private boolean three;
private char four;
private StringBuffer five;
private CharSequence five;

public SerializableFive(String one, int two, boolean three, char four, StringBuffer five) {
public SerializableFive(String one, int two, boolean three, char four, CharSequence five) {
super(one);
this.two = two;
this.three = three;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006 Joe Walnes.
* Copyright (C) 2006, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2015 XStream Committers.
* All rights reserved.
*
Expand Down Expand Up @@ -57,7 +57,7 @@ public void startBenchmark() {
}

private String css() {
StringBuffer css = new StringBuffer("\n");
StringBuilder css = new StringBuilder("\n");
css.append("body, h1, h2, h3, td { font-family: arial; }\n");
css.append("h1 { text-align: center; }\n");
css.append("table, h3 { margin-left: 40px; }\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006 Joe Walnes.
* Copyright (C) 2006, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2015 XStream Committers.
* All rights reserved.
*
Expand Down Expand Up @@ -83,7 +83,7 @@ public void endBenchmark() {
}

private String pad(String value) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
result.append(value);
while (result.length() < 50) {
result.append('.');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009, 2011, 2015 XStream Committers.
* Copyright (C) 2009, 2011, 2015, 2022 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
Expand Down Expand Up @@ -41,7 +41,7 @@ public JavaBeanTarget() {
five.setTwo(2);
five.setThree(true);
five.setFour('4');
five.setFive(new StringBuffer("5"));
five.setFive(new StringBuilder("5"));
list.add(five);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004, 2005 Joe Walnes.
* Copyright (C) 2004, 2005, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2009, 2014, 2018 XStream Committers.
* All rights reserved.
*
Expand Down Expand Up @@ -87,7 +87,7 @@ private void resizeStack(final int newCapacity) {

@Override
public String toString() {
final StringBuffer result = new StringBuffer("[");
final StringBuilder result = new StringBuilder("[");
for (int i = 0; i < pointer; i++) {
if (i > 0) {
result.append(", ");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2007, 2008, 2010, 2014, 2015, 2020 XStream Committers.
* Copyright (C) 2007, 2008, 2010, 2014, 2015, 2020, 2022 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
Expand Down Expand Up @@ -74,8 +74,8 @@ private Map<String, String> getHeader(final PushbackInputStream[] in) throws IOE
int i = 0;
char ch = 0;
char valueEnd = 0;
final StringBuffer name = new StringBuffer();
final StringBuffer value = new StringBuffer();
final StringBuilder name = new StringBuilder();
final StringBuilder value = new StringBuilder();
boolean escape = false;
while (i != -1 && (i = in[0].read()) != -1) {
out.write(i);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004, 2005, 2006 Joe Walnes.
* Copyright (C) 2004, 2005, 2006, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2009, 2011, 2014, 2015, 2020 XStream Committers.
* All rights reserved.
*
Expand Down Expand Up @@ -130,7 +130,7 @@ public String peekElement(final int i) {
final Integer integer = indexMapStack[idx].get(pathStack[idx]);
final int index = integer.intValue();
if (index > 1) {
final StringBuffer chunk = new StringBuffer(pathStack[idx].length() + 6);
final StringBuilder chunk = new StringBuilder(pathStack[idx].length() + 6);
chunk.append(pathStack[idx]).append('[').append(index).append(']');
name = chunk.toString();
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005, 2006 Joe Walnes.
* Copyright (C) 2005, 2006, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2009, 2010, 2011, 2014, 2015, 2016 XStream Committers.
* All rights reserved.
*
Expand Down Expand Up @@ -183,7 +183,7 @@ public String getValue() {
// lets only use a string buffer when we get 2 strings
// to avoid copying strings
String last = null;
StringBuffer buffer = null;
StringBuilder buffer = null;

mark();
Event event = readEvent();
Expand All @@ -195,7 +195,7 @@ public String getValue() {
last = text;
} else {
if (buffer == null) {
buffer = new StringBuffer(last);
buffer = new StringBuilder(last);
}
buffer.append(text);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004, 2005, 2006 Joe Walnes.
* Copyright (C) 2004, 2005, 2006, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2008, 2009, 2011, 2014, 2015, 2020 XStream Committers.
* All rights reserved.
*
Expand All @@ -20,6 +20,7 @@
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URL;
import javax.xml.XMLConstants;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
Expand Down Expand Up @@ -102,6 +103,9 @@ private HierarchicalStreamReader createReader(final InputSource source) {
}
}
}
//https://rules.sonarsource.com/java/RSPEC-2755
documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
if (encoding != null) {
source.setEncoding(encoding);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006 Joe Walnes.
* Copyright (C) 2006, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2008, 2009, 2011, 2013, 2014, 2015, 2019, 2020, 2021 XStream Committers.
* All rights reserved.
*
Expand Down Expand Up @@ -497,7 +497,7 @@ private String encodeName(final String name) {
}

// Otherwise full processing
final StringBuffer result = new StringBuffer(length + 8);
final StringBuilder result = new StringBuilder(length + 8);

// We know first N chars are safe
if (i > 0) {
Expand Down Expand Up @@ -555,7 +555,7 @@ private String decodeName(final String name) {
}

// Otherwise full processing
final StringBuffer result = new StringBuffer(length + 8);
final StringBuilder result = new StringBuilder(length + 8);

// We know first N chars are safe
if (i > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004, 2005, 2006 Joe Walnes.
* Copyright (C) 2004, 2005, 2006, 2022 Joe Walnes.
* Copyright (C) 2006, 2007, 2009, 2011, 2014 XStream Committers.
* All rights reserved.
*
Expand Down Expand Up @@ -72,7 +72,7 @@ public String getNodeName() {
@Override
public String getValue() {
// currentElement.getValue() not used as this includes text of child elements, which we don't want.
final StringBuffer result = new StringBuffer();
final StringBuilder result = new StringBuilder();
final int childCount = currentElement.getChildCount();
for (int i = 0; i < childCount; i++) {
final Node child = currentElement.getChild(i);
Expand Down