sonarqube检查出的bug修改总结

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/T_Mac9334/article/details/83181320

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
 

猜你喜欢

转载自blog.csdn.net/T_Mac9334/article/details/83181320