If you need the items you receive for the order, then your method should get a list, not a set. But to get rid of the warning, you will have to use Set, not LinkedHashSet. It is good practice to use interfaces rather than actual classes in your methods. You should not disclose actual implementations of the interface.
Also, if you only need to iterate over the elements of the set, you can get an Iterator and just iterate over it.
EDIT: if you really want you to get only a LinkedHashSet, you can do something like this:
public void setFileNames(Set<String> fileNames) { if (!(fileNames instanceof LinkedHashSet)) { throw new IllegalArgumentException("I need a LinkedHashSet!"); } }
EDIT 2: I don't think there is a perfect answer here, but if you really need everything to get a LinkedHashSet, I would declare it in the interface and find a way to force Sonar to ignore this particular instance of this warning.
source share