Showing 821 of 821 total issues
File SimpleMapper.java
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
Copyright 2018-2023 Accenture Technology
Licensed under the Apache License, Version 2.0 (the "License");
Method handle
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void handle(HttpServerRequest request) {
Utility util = Utility.getInstance();
HttpServerResponse response = request.response();
response.putHeader(DATE, util.getHtmlDate(new Date()));
- 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 toBytes
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public byte[] toBytes() throws IOException {
Map<String, Object> message = new HashMap<>();
if (id != null) {
message.put(ID_FLAG, id);
}
- 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 loadRouteSubstitution
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
private void loadRouteSubstitution() {
AppConfigReader config = AppConfigReader.getInstance();
String location = config.getProperty(ROUTE_SUBSTITUTION_FILE);
if (location != 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 incoming
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public void incoming(EventEnvelope message) throws IOException {
PostOffice po = PostOffice.getInstance();
Map<String, String> control = message.getHeaders();
if (message.getTo() != null) {
String to = message.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 scan
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private Map scan(JsonObject o) {
Map<String, Object> result = new HashMap<>();
for (String k: o.keySet()) {
if (!o.get(k).isJsonNull()) {
if (o.get(k).isJsonObject()) {
- 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 eventFromMap
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
private EventEnvelope eventFromMap(Map<String, Object> map) {
EventEnvelope event = new EventEnvelope();
if (map.containsKey(ID)) {
event.setId((String) map.get(ID));
- 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
RoutingEntry
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
public class RoutingEntry {
private static final Logger log = LoggerFactory.getLogger(RoutingEntry.class);
private static final String ASYNC_HTTP_REQUEST = AppStarter.ASYNC_HTTP_REQUEST;
private static final String HTTP = "http://";
PubSubManager
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
public class PubSubManager implements PubSubProvider {
private static final Logger log = LoggerFactory.getLogger(PubSubManager.class);
private static final MsgPack msgPack = new MsgPack();
private static final String TYPE = "type";
Method pack
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings({ "unchecked", "rawtypes" })
private MessagePacker pack(MessagePacker packer, Object o) throws IOException {
if (o == null) {
// preserving null element in an array list
packer.packNil();
Method handleEvent
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
@Override
public Object handleEvent(Map<String, String> headers, Object body, int instance) throws IOException {
Platform platform = Platform.getInstance();
PostOffice po = PostOffice.getInstance();
Method load
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
public void load(ConfigReader config) {
if (config.exists(HEADERS)) {
Object headerList = config.get(HEADERS);
if (headerList instanceof List) {
Method start
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
@SuppressWarnings("unchecked")
public void start(String[] args) throws Exception {
Platform platform = Platform.getInstance();
String origin = platform.getOrigin();
Method handleEvent
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Object handleEvent(Map<String, String> headers, Object body, int instance)
throws AppException, TimeoutException {
String type = headers.getOrDefault(TYPE, INFO);
Platform platform = Platform.getInstance();
Method matchRoute
has a Cognitive Complexity of 19 (exceeds 5 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;
- 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 startService
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private boolean startService(String name, List<ClassInfo> services, boolean isConnector) {
if (name == null) {
return false;
}
final String type = isConnector? CONNECTOR : SERVICE;
- 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 setup
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private void setup() throws TimeoutException, IOException {
ServerPersonality.getInstance().setType(ServerPersonality.Type.RESOURCES);
Utility util = Utility.getInstance();
AppConfigReader config = AppConfigReader.getInstance();
Platform platform = Platform.getInstance();
- 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 setElement
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("unchecked")
private void setElement(String path, Object value, Map<String, Object> map, boolean delete) {
Utility util = Utility.getInstance();
List<String> segments = util.split(path, "./");
if (segments.isEmpty()) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
@DELETE
@Path("/{name}")
@Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML})
public Object stopJob(@PathParam("name") String name) throws AppException, SchedulerException, IOException {
ScheduledJob job = MainScheduler.getJob(name);
- 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 160.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
@PUT
@Path("/{name}")
@Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML})
public Object startJob(@PathParam("name") String name) throws AppException, SchedulerException, IOException {
ScheduledJob job = MainScheduler.getJob(name);
- 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 160.
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