In my project I have a simple function that calculates the length of an iterable (as I don't think there is an easy way to get it? No .size()
or .length()
is accepted?) Here is the code:
public int getIterableSize(Iterable<User> users){
int size = 0;
for(User user : users){
size++;
}
return size;
}
I also use Sonarqube to keep my code quality and I get the following code smell about this function:
Remove this unused "user" local variable.
There must be an easy way to get rid of this right? Maybe an alternative for the for loop, maybe a different function provided by iterable?