Task :qmoney:spotbugsMain FAILED

In spotbug i am getting this 3 error

PMD

PMD report

Problems found

# File Line Problem
1 /home/crio-user/workspace/niteshnanda02-ME_QMONEY/qmoney/src/main/java/com/crio/warmup/stock/dto/AnnualizedReturn.java 7 It is somewhat confusing to have a field name matching the declaring class name
2 /home/crio-user/workspace/niteshnanda02-ME_QMONEY/qmoney/src/main/java/com/crio/warmup/stock/dto/AnnualizedReturn.java 7 It is somewhat confusing to have a field name matching the declaring class name
3 /home/crio-user/workspace/niteshnanda02-ME_QMONEY/qmoney/src/main/java/com/crio/warmup/stock/log/UncaughtExceptionHandler.java 15 Found 'UR'-anomaly for variable 'stackTraceElement' (lines '15'-'21').

I search on google but i can’t find any solution to solve this error. Please check it!!

share the screen shot please


I don’t know why i am getting the error in this file because i had not change any of these files

Are you using any field name which is same as your class name please check it

yes in the AnnualizedReturn class.
In this i have not change anything

check line number 7 for the same

I already check and change the variable name, then i got some another error after changing it

share the file that file please

package com.crio.warmup.stock.dto;

public class AnnualizedReturn {

private final String symbol;
private final Double annualizedReturn;
private final Double totalReturns;

public AnnualizedReturn(String symbol, Double annualizedReturn, Double totalReturns) {
this.symbol = symbol;
this.annualizedReturn = annualizedReturn;
this.totalReturns = totalReturns;
}

public String getSymbol() {
return symbol;
}

public Double getAnnualizedReturn() {
return annualizedReturn;
}

public Double getTotalReturns() {
return totalReturns;
}
}

can you check that log for uncaughtexceptionhandle.java and share the ss for the same

I have just noticed that you passed your pmd now you got spotbug error please share those errors

package com.crio.warmup.stock.log;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class UncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {

private static final Logger log = LogManager.getLogger(UncaughtExceptionHandler.class);

@Override
public void uncaughtException(Thread t, Throwable e) {
ObjectNode logEventJsonObjNode = JsonNodeFactory.instance.objectNode();

if (e.getStackTrace() != null && e.getStackTrace().length > 0) {
  ArrayNode logStacktraceJsonArrNode = JsonNodeFactory.instance.arrayNode();
  for (StackTraceElement stackTraceElement : e.getStackTrace()) {
    logStacktraceJsonArrNode.add(stackTraceElement.toString());
  }
  logEventJsonObjNode.set("stacktrace", logStacktraceJsonArrNode);
}

logEventJsonObjNode.put("cause", e.toString());

log.error(logEventJsonObjNode.toString(), e);

}
}

Bro see my last comment you have spotbug error and you are giving the pmd error logs

But in main.tml i will get the spotbug error na?

You are showing pmd error yrrr

then from where can i see spotbug error?

See Just below the pmd error log

There is nothing below pmd error

I hope you never forgot this