sonarqube檢查出的bug修改總結
1.修改異常處理 Either log or rethrow this exception. private static String cc="error"; logger.error(cc,e);
2. 程式碼位置不符合規範 Move this variable to comply with Java Code Conventions. 放置到指定位置.
3. 直接返回結果 Immediately return this expression instead of assigning it to the temporary variable "callCount". return xxx; 4. 新增 @Override Add the "@Override" annotation above this method signature
5. 方法的引數過多 Method has 12 parameters, which is greater than 7 authorized.
6 將值直接付給變數 不再定義後再賦值 Remove this useless assignment to local variable "BySelf".
-----源 :List<TblDdcCpdCampaignHist> campaignHistList = new ArrayList<>(); campaignHistList = ddcDao.getResultList (); -----改 :List<TblDdcCpdCampaignHist> campaignHistList = ddcDao.getResultList ();
7 欄位小寫 Rename this local variable name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.
8. 使用 Integer.toString() 代替 Use "Integer.toString" instead.
Integer.toString(y);
9. 使用Hibernate的引數繫結而不是級聯。 Use Hibernate's parameter binding instead of concatenation.
源: Query query = getSession().createQuery("delete TabNew " + " where campaignid = '"+campainId+"' AND dealerCustom = 'Y'"); query.executeUpdate(); 改:Query query = getSession().createQuery("delete TabNew " + " where campaignid = ? AND dealerCustom = 'Y'"); query.setLong(0, campainId); query.executeUpdate();
10. 重新調整修飾符以符合Java語言規範。 Reorder the modifiers to comply with the Java Language Specification. 源: final static 改: static final