v
v copied to clipboard
tools.vet: add notice for empty strings conditions
After getting a response from Alex that it's fine to add the suggestion made in https://github.com/vlang/v/pull/21300 this should be the frist extension after #21417.
~~Currently, it includes the PR. It is planned to rebase it after it is resolved, this will reduce the diff greatly and to relevant changes.~~ Rebased.
fn main() {
foo := 'foo'
foo.len == 0
foo.len != 0
foo.len < 1
foo.len > 0
}
will result in:
cmd/tools/vvet/tests/empty_string.vv:3: notice: Use `foo == ''` instead of `foo.len == 0`
cmd/tools/vvet/tests/empty_string.vv:4: notice: Use `foo != ''` instead of `foo.len != 0`
cmd/tools/vvet/tests/empty_string.vv:5: notice: Use `foo == ''` instead of `foo.len < 1`
cmd/tools/vvet/tests/empty_string.vv:6: notice: Use `foo != ''` instead of `foo.len > 0`
The Vinix failure is not related, and already fixed on master.