Arrays should not be copied using loops (java:S3012) has a false positive when using auto (un)boxing

Arrays should not be copied using loops (java:S3012)

has a false positive when using autoboxing or auto unboxing

	public Integer[] boxed(int[] arr) {
		Integer[] result = new Integer[arr.length];
		for (int i = 0; i < arr.length; i++) {
			result[i] = /* using auto boxing */ arr[i];
		}
		return result;
	}

	public int[] unboxed(Integer[] arr) {
		int[] result = new int[arr.length];
		for (int i = 0; i < arr.length; i++) {
			result[i] = /* using auto unboxing */ arr[i];
		}
		return result;
	}

I am using SonarLint v3.7.0 for VSCode

Thank you for reporting @PhoenixmitX !
It is indeed a false positive. I have created a ticket: [SONARJAVA-4287] - Jira.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.