D-Scanner
D-Scanner copied to clipboard
The imports are not sorted in alphabetical order within version
$ cat dscanner.ini
imports_sortedness="skip-unittest"
$ cat test.d
import c;
version (Windows)
{
import e;
}
else
{
import d;
}
$ ~/.dub/packages/dscanner-0.5.9/dscanner/bin/dscanner --styleCheck test.d
test.d(9:12)[warn]: The imports are not sorted in alphabetical order
It is on Linux.
A workaround is to write the else
-version explicitely:
else version (Posix)
It would be possible to skip the check when imports are found within a version but then everything in the current scope would be skipped i think. It's a matter of false positive VS false negative. Maybe @wilzbach you can handle this issue since you wrote the check IIRC ?
I think every version
-block should have its own scope, so I can put all platform-specific imports together.
This one doesn't produce a warning:
version (Windows)
{
}
else
{
import d;
}
import c;
Only if there is a Windows import and it is > c
an error occurres.
Yes this would work. Technically version bodies are not scopes but a kind of scope can be pushed in the check.
@BBasile I can have a look at it, but I will continue to be away from my workstation for at least another week. Sorry.