Sonar Violation: Security - Array is stored directly

后端 未结 7 2176
广开言路
广开言路 2020-11-27 04:53

There is a Sonar Violation:

Sonar Violation: Security - Array is stored directly

public void setMyArray(String[] myArray) { 
  this.         


        
7条回答
  •  情书的邮戳
    2020-11-27 05:25

    It's more ease than all of this. You only need to rename the method parameter to anything else to avoid Sonar violations.

    http://osdir.com/ml/java-sonar-general/2012-01/msg00223.html

    public void setInventoryClassId(String[] newInventoryClassId)
        {                
                if(newInventoryClassId == null)
                {
                        this.inventoryClassId = new String[0];
                }
                else
                {
                        this.inventoryClassId = Arrays.copyOf(newInventoryClassId, newInventoryClassId.length);
                }
    
        } 
    

提交回复
热议问题