Showing 821 of 821 total issues
Method mapFromEvent
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Map<String, Object> mapFromEvent(EventEnvelope event) {
Map<String, Object> result = new HashMap<>();
result.put(ID, event.getId());
if (event.getTo() != null) {
result.put(TO, event.getTo());
Method send
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void send(String token, EventEnvelope event) throws IOException {
String txPath = LanguageConnector.getTxPathFromToken(token);
if (txPath != null) {
if (event.getBroadcastLevel() == 2) {
event.setBroadcastLevel(3);
Method suspendSubscription
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public void suspendSubscription() {
Utility util = Utility.getInstance();
List<String> subscribers = new ArrayList<>(currentSubscribers.keySet());
for (String subscriber: subscribers) {
suspendedSubscribers.put(subscriber, currentSubscribers.get(subscriber));
- 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 write
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
@SuppressWarnings("unchecked")
public void write(Object o, MediaType contentType, HttpOutputMessage outputMessage) throws HttpMessageNotWritableException, IOException {
outputMessage.getHeaders().setContentType(XML);
// this may be too late to validate because Spring RestController has already got the object
- 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 substituteRouteIfAny
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public String substituteRouteIfAny(String to) {
if (to != null) {
int slash = to.indexOf('@');
if (slash > 0) {
String replacement = reRoutes.get(to.substring(0, slash));
- 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 scanExpiredStores
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private void scanExpiredStores(File tmpRoot) {
if (runningInCloud) {
removeExpiredStore(tmpRoot);
} else {
File[] dirs = tmpRoot.listFiles();
- 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 expandList
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
private List<Object> expandList(List<Integer> indexes, List<Object> dataset) {
List<Object> current = dataset;
int len = indexes.size();
for (int i=0; i < len; i++) {
- 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 getScanComponents
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private Set<String> getScanComponents(String components) {
Set<String> result = new HashSet<>();
AppConfigReader reader = AppConfigReader.getInstance();
String list = reader.getProperty(components);
if (list != 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 asyncRequest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public Future<EventEnvelope> asyncRequest(final EventEnvelope event, long timeout) throws IOException {
if (event == null) {
throw new IllegalArgumentException(MISSING_EVENT);
}
String dest = event.getTo();
- 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 isIntranetAddress
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public boolean isIntranetAddress(String host) {
Utility util = Utility.getInstance();
if (host == null) {
return false;
}
- 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 handleEvent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
public Object handleEvent(Map<String, String> headers, Object body, int instance) {
if (body instanceof String && db != null && dbEnv != null) {
Utility util = Utility.getInstance();
int n = 0;
- 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 handleEvent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
@Override
public Object handleEvent(Map<String, String> headers, Object body, int instance) {
EventEnvelope trace = (EventEnvelope) body;
if (trace.getBody() 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 unpackValue
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Object unpackValue(MessageUnpacker unpacker, MessageFormat mf) throws IOException {
ValueType type = mf.getValueType();
switch (type) {
case STRING:
return unpacker.unpackString();
Method appendNode
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
private void appendNode(StringBuilder buffer, String nodeName, Object value, int indent) {
// Skip null value
if (value == null) {
return;
Method decode
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Object decode(TypedPayload typed) throws ClassNotFoundException {
String type = typed.getType();
if (NOTHING.equals(type)) {
return null;
}
Method run
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void run() {
log.info("Started");
Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown));
Method hasRsvpRights
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean hasRsvpRights() {
Utility util = Utility.getInstance();
long now = System.currentTimeMillis();
String me = Platform.getInstance().getOrigin();
// remove expired bids
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static void closeConnection(String txPath, int status, String message) throws IOException {
if (txPath != null && message != null) {
EventEnvelope error = new EventEnvelope();
error.setTo(txPath);
error.setHeader(STATUS, status);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 84.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static void closeConnection(String txPath, int status, String message) throws IOException {
if (txPath != null && message != null) {
EventEnvelope error = new EventEnvelope();
error.setTo(txPath);
error.setHeader(STATUS, status);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 84.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method matchRoute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean matchRoute(List<String> input, List<String> segments, boolean wildcard) {
// segment is lowercase parts of the configured URL
if (wildcard) {
if (segments.size() > input.size()) {
return false;