新增需求 #1815
已結束[SonarQube]軟體檢測BUG
0%
概述
%{color:red}package com.globalwafers.iwms.service.wcs.ActionService%
1. line 140 ~ 142
Resource Date Description
ActionService.java 7 minutes ago Use "BigDecimal.valueOf" instead.
private static BigDecimal ZERO = new BigDecimal(0.0);
private static BigDecimal ONE = new BigDecimal(1.0);
要修改如下:
new BigDecimal(0.0) → BigDecimal.valueOf(0.0)
new BigDecimal(1.0) → BigDecimal.valueOf(0.0)
2. line 990, 998
Resource Date Description
ActionService.java 14 days ago A "NullPointerException" could be thrown; "detailProdCode" is nullable here. [+2 locations]
DocInboundDetail detailProdCode = docInBoundDetailRepo.findById(detailDesc.getDetailId()). orElse(null) ;
//新增庫存明細
log.debug("新增庫存明細");
stockService.addStockByReceiveDetail(toStockDto(carrierId, subCarrierId, "IN"
, detailDesc.getExp01(),detailDesc.getExp02(), detailDesc.getExp03(), detailDesc.getExp04()
, detailDesc.getExp05(), detailDesc.getExp06(), detailDesc.getExp07(), detailDesc.getExp08()
, detailDesc.getExp09(), detailDesc.getExp10(), detailDesc.getExp11(), detailDesc.getExp12()
, detailDesc.getExp13(), detailDesc.getExp14(), detailDesc.getExp15(), detailDesc.getExp16()
, detailDesc.getExp17(), detailDesc.getExp18(), *detailProdCode.getProdCode(), detailProdCode.getRefNo()
-
, "1"));
要修改如下:(加入非null判斷)
if(detailProdCode != null){
stockService.addStockByReceiveDetail(...)
}
3. line 1153 ~ 1157
Resource Date Description
ActionService.java 14 days ago A "NullPointerException" could be thrown; "newDocInBoundDetail" is nullable here. [+2 locations]
DocInboundDetail newDocInBoundDetail = docInBoundDetailRepo.findById(newEntity.getId()). orElse(null) ;
DocInboundDetailDesc docInBoundDetailDesc = new DocInboundDetailDesc();
docInBoundDetailDesc.setCreateTime(now);
docInBoundDetailDesc.setCreator("IAM");
docInBoundDetailDesc.setDetailId( newDocInBoundDetail .getId());
docInBoundDetailDesc.setParentId( newDocInBoundDetail .getParentId());
要修改如下:(加入非null判斷)
4. line 799 ~ 800
Resource Date Description
ActionService.java 14 days ago Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.
catch (InterruptedException e) {
ThrowableUtil.printThrowableLog(e);
}
要修改如下:
catch (InterruptedException e) {
ThrowableUtil.printThrowableLog(e);
Thread.currentThread().interrupt();
}
%{color:red}package com.globalwafers.iwms.service.inbound.InboundService%
5. line 449 ~ 450
Resource Date Description
InboundService.java null "NullPointerException" will be thrown when invoking method "addStock()". [+4 locations]
DocInboundDetailDesc detailDesc = inboundDetailDescRepo.findDetailIdOrNull(detail.getId()). orElse(null) ;
addStock(detail, detailDesc );
要修改如下:(加入非null判斷)
6. line 1247 ~ 1254
Resource Date Description
InboundService.java null A "NullPointerException" could be thrown; "detailDescEntity" is nullable here. [+2 locations]
InboundService.java null A "NullPointerException" could be thrown; "detailEntity" is nullable here. [+2 locations]
DocInboundDetail detailEntity = inboundDetailRepo.findById(detailId). orElse(null) ;
DocInboundDetailDesc detailDescEntity = inboundDetailDescRepo.findDetailIdOrNull(detailId). orElse(null) ;
LocationProductStockDto stockDto = new LocationProductStockDto();
stockDto.setSubCarrieId( detailEntity .getSubCarrierId());
stockDto.setCarrierId( detailEntity .getCarrierId());
stockDto.setDocType("IN");
stockDto.setRowSeq(String.valueOf(rowSeq));
stockDto.setExp01( detailDescEntity .getExp01());
要修改如下:(加入非null判斷)
%{color:red}package com.globalwafers.iwms.service.auth.AuthRoleService%
7. line 330 ~ 333
Resource Date Description
AuthRoleService.java null A "NullPointerException" could be thrown; "p" is nullable here. [+2 locations]
AuthPrivilege p = privilRepo.findById(newEntity.getPrivilegeId()). orElse(null) ;
Map<String, Object> permission = new HashMap<String, Object>();
//頁面有啟用且有權限
if ( p.getIsEnable() && newEntity.getPermission()) {
permission.put("isCreate", true);
要修改如下:(加入非null判斷)
AuthPrivilege p = privilRepo.findById(newEntity.getPrivilegeId()). orElse(null) ;
Map<String, Object> permission = new HashMap<String, Object>();
//頁面有啟用且有權限
if(p != null){
if ( p.getIsEnable() && newEntity.getPermission()) {
permission.put("isCreate", true);
} else {
}
}
%{color:red}package com.globalwafers.iwms.service.auth.AuthService%
8. line 221~ 225
SysUser existUser = sysUserRepo.findById(userId). orElse(null) ;
String key = new StringBuilder(SystemConstants.CACHE_AUTH_BLACKLIST).append(token).toString();
redisService.set(key, existUser .getAccount(), TokenUtil.getExptime())
要修改如下:(加入非null判斷)
%{color:red}package com.globalwafers.iwms.service.core.DocReceivementSevice%
9. 1771 ~ 1775
Resource Date Description
DocReceivementSevice.java 1 minute ago A "NullPointerException" could be thrown; "newDocInBoundDetail" is nullable here. [+2 locations]
DocInboundDetail newDocInBoundDetail = docInBoundDetailRepo.findById(newEntity.getId()). orElse(null) ;
DocInboundDetailDesc docInBoundDetailDesc = new DocInboundDetailDesc();
docInBoundDetailDesc.setCreateTime(now);
docInBoundDetailDesc.setCreator("IAM");
docInBoundDetailDesc.setDetailId( newDocInBoundDetail .getId());
要修改如下:(加入非null判斷)
10. 1877~ 1882
Resource Date Description
DocReceivementSevice.java 3 minutes ago A "NullPointerException" could be thrown; "newDocInBoundDetail" is nullable here. [+2 locations]
DocInboundDetail newDocInBoundDetail = docInBoundDetailRepo.findById(newEntity.getId()). orElse(null) ;
DocInboundDetailDesc docInBoundDetailDesc = new DocInboundDetailDesc();
docInBoundDetailDesc.setCreateTime(now);
docInBoundDetailDesc.setCreator("IAM");
docInBoundDetailDesc.setDetailId( newDocInBoundDetail .getId());
docInBoundDetailDesc.setParentId( newDocInBoundDetail .getParentId());
要修改如下:(加入非null判斷)
- line 326, 458, 1446
Resource Date Description
DocReceivementSevice.java 3 minutes ago Strings and Boxed types should be compared using "equals()".
if (docInBound.getDocStatus() != DocStatus.COMPLETE.getId()) {
if (docProcess.getDocStatus() != DocStatus.COMPLETE.getId()) {
if (docInBound.getDocStatus() != DocStatus.COMPLETE.getId()) {
要修改如下:
用!A.equals(B)取代不等於,要留意是不等於,最前面要加驚嘆號
if (!docInBound.getDocStatus().equals(DocStatus.COMPLETE.getId())) {
if (!docProcess.getDocStatus().equals(DocStatus.COMPLETE.getId())) {
if (!docInBound.getDocStatus().equals( DocStatus.COMPLETE.getId())) {
檔案