I have created an ArrayList like the following:
def list = new ArrayList()
But the codenarc report it is warning like following.
You can do:
def list = [] // Default is ArrayList def list = [] as ArrayList ArrayList list = []
And again, for HashMap:
HashMap
HashMap map = [:] def map = [:] as HashMap
The default in this case is a LinkedHashMap:
LinkedHashMap
def map = [:]