2016-05-24 153 views
1

这个未使用的方法参数我有重大的问题“删除此未使用的方法参数‘shiftId’”(和一些类似的问题):删除春季安全@PreAuthorize

@RequestMapping(value = "/refund/{invoiceId}", method = RequestMethod.GET) 
@PreAuthorize("@AccessPosition.toMeOpen(#shiftId)") 
public PosTransactionRefundInfoDTO getTransactionRefund(@PathVariable("shiftId") Long shiftId, @PathVariable("invoiceId") Long invoiceId) 
{ 
    // ... some code here 
} 

参数shiftId声明只为@PreAuthorize注释,它在方法代码中没有用到。 我能以某种方式解决这个问题吗“以正确的方式”,而不用“不会修复”或“误报”来标记它?

+0

你可能会开始讨论解决此上[Google网上论坛](https://groups.google.com/forum/?pli=1#!forum/sonarqube)。 –

回答

1

首先确保它不是一个逻辑/设计错误:为什么授权你不使用的东西?这会导致安全漏洞吗?

为了摆脱警告,我会建议使用一个简单的日志语句方法参数:

logger.debug("ShiftId: {}", shiftId);