Return unmodifiable collection from class in test code. #1555

Fixes `ReturnOfCollectionField` inspection violations in test code.

Description:
>Reports any attempt to return an array or Collection field from a method. Since the array or Collection may have its contents modified by the calling method, this construct may result in an object having its state modified unexpectedly. While occasionally useful for performance reasons, this construct is inherently bug-prone.
This commit is contained in:
Michal Kordas 2015-08-19 20:59:47 +02:00 committed by Roman Ivanov
parent 681e17be40
commit a17a01047f
1 changed files with 2 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;
@ -95,7 +96,7 @@ public class ConfigurationBuilder extends BaseCheckTestSupport {
}
public List<File> getFiles() {
return files;
return Collections.unmodifiableList(files);
}
public Integer[] getLinesWithWarn(String aFileName) throws IOException {