[java] Update rule AvoidInstantiatingObjectsInLoops#3394
Conversation
Generated by 🚫 Danger |
WRONG_LANGUAGE_CODE_KEY, new Object[] {code}, getId(), getClass(), null);ArrayAllocations are not considered anymore obviously....
for (String configName : new String[] {"config", "test"}) {We should add a test case for this.
this.propertyValueList.add(new PropertyValue(pv));Maybe worth to add a test case - I guess in pmd6 we stumble over "this." ...
this.configResources[i] = new ClassPathResource(paths[i], clazz);Same as 3 - we probably stumble in pmd6 over "this." for this array access. Maybe worth a test case.
dataBuffers.add(this.bufferFactory.wrap(new byte[]{b}));I think, this is not reported because of the array allocation. But we should make sure, that this is not reported at all, because it is part of the "Collection.add" call - which should be ignored. In this case, it is not the direct argument, but only indirectly.
cookieStrings[i] = new ToStringCreator(cookie)...It's assigning it to an array so it should be ignored. Maybe we don't recognize the method call chain correctly... Update: All of these have been fixed ✔️ |
|
New round:
powerCache[i] = new BigInteger[] { BigInteger.valueOf(i) };ArrayAllocation should also be ignored if it is assigned to an array (like collection).
return new Proxy[] {SocksProxy.create(saddr, socksProxyVersion())};ArrayAllocation should also be ignored, if the array is returned and therefore the loop is exited.
pathResolver.setAllowedLocations(getLocations().toArray(new Resource[0]));getLocations() returns a Collection, so the ArrayAllocation is used in a collection method call. That's correct, this usage should not be flagged. Update: All of these have been fixed ✔️ |
oowekyala
left a comment
There was a problem hiding this comment.
Thanks, I think this is fine
Describe the PR