File NodeProxyTCP.java
has 706 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.uniks.networkparser.ext.petaf.proxy;
/*
The MIT License
NodeProxyTCP
has 45 methods (exceeds 20 allowed). Consider refactoring. Open
public class NodeProxyTCP extends NodeProxy {
public static int BUFFER = 100 * 1024;
public static final String POST = "POST";
public static final String GET = "GET";
public static final String PUT = "PUT";
Method startProxy
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected boolean startProxy() {
boolean isInput = NodeProxy.isInput(getType());
if (url == null && getType() == null || isInput) {
if (server != null) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method postHTTP
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static HTMLEntity postHTTP(HTMLEntity session, String path, String bodyType, Object... params) {
if (session == null) {
return null;
}
CharacterBuffer buffer = new CharacterBuffer();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method executeInputStream
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public Message executeInputStream(Socket socket) throws IOException {
ByteBuffer buffer = new ByteBuffer();
byte[] messageArray = new byte[BUFFER];
InputStream is = socket.getInputStream();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method sending
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected boolean sending(Message msg) {
if (super.sending(msg)) {
return true;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method postHTTP
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static HTMLEntity postHTTP(HTMLEntity session, String path, String bodyType, Object... params) {
if (session == null) {
return null;
}
CharacterBuffer buffer = new CharacterBuffer();
Method executeInputStream
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Message executeInputStream(Socket socket) throws IOException {
ByteBuffer buffer = new ByteBuffer();
byte[] messageArray = new byte[BUFFER];
InputStream is = socket.getInputStream();
Method sending
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected boolean sending(Message msg) {
if (super.sending(msg)) {
return true;
}
Method readAnswer
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static HTMLEntity readAnswer(HttpURLConnection conn, HTMLEntity root) {
if (root == null) {
root = new HTMLEntity();
}
if (conn == null) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method startProxy
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected boolean startProxy() {
boolean isInput = NodeProxy.isInput(getType());
if (url == null && getType() == null || isInput) {
if (server != null) {
Method readAnswer
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static HTMLEntity readAnswer(HttpURLConnection conn, HTMLEntity root) {
if (root == null) {
root = new HTMLEntity();
}
if (conn == null) {
Method getHTTP
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static HTMLEntity getHTTP(HTMLEntity session, String path, Object... params) {
if (session == null) {
return null;
}
CharacterBuffer buffer = new CharacterBuffer();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getHTTP
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static HTMLEntity getHTTP(HTMLEntity session, String path, Object... params) {
if (session == null) {
return null;
}
CharacterBuffer buffer = new CharacterBuffer();
Method postHTTP
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static HTMLEntity postHTTP(String url, int port, String path, String bodyType, Object... params) {
String uri = convertPath(url, port, path);
if (uri == null) {
return null;
}
Method postHTTP
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static HTMLEntity postHTTP(String url, int port, String path, String bodyType, Object... params) {
String uri = convertPath(url, port, path);
if (uri == null) {
return null;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method convertParams
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static BaseItem convertParams(BaseItem result, Object... params) {
if (params == null || params.length < 1) {
return result;
}
if (params[0] instanceof Map<?, ?>) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method convertPath
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static String convertPath(String url, int port, String path) {
if (url == null) {
return null;
}
CharacterBuffer buffer = new CharacterBuffer();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method postHTTP
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static HTMLEntity postHTTP(String url, int port, String path, String bodyType, Object... params) {
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Method getValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object getValue(Object element, String attrName) {
if (element instanceof NodeProxyTCP) {
NodeProxyTCP nodeProxy = (NodeProxyTCP) element;
if (PROPERTY_URL.equals(attrName)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method setValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean setValue(Object element, String attrName, Object value, String type) {
if (element instanceof NodeProxyTCP) {
NodeProxyTCP nodeProxy = (NodeProxyTCP) element;
if (PROPERTY_URL.equals(attrName)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getConnection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static HttpURLConnection getConnection(String url, String type) {
HttpURLConnection conn = null;
try {
if (url == null || url.isEmpty()) {
return null;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Do not hard code the IP address Open
public static final String LOCALHOST = "127.0.0.1";
- Read upRead up
- Exclude checks
AvoidUsingHardCodedIP
Since: PMD 4.1
Priority: Medium
Categories: Style
Remediation Points: 50000
Application with hard-coded IP addresses can become impossible to deploy in some cases. Externalizing IP adresses is preferable.
Example:
public class Foo {
private String ip = '127.0.0.1'; // not recommended
}