vala-lang / vala-lint

Check code-style of Vala code files
GNU General Public License v2.0
96 stars 15 forks source link

Ignore linting in regex expressions #141

Open ryonakano opened 4 years ago

ryonakano commented 4 years ago

It seems like linting is ignored in strings:

// This code does not raise any error in vala-lint
var regex = new Regex ("^(xkb|m17n):(\\w+)");

However, if you use regex directly, vala-lint raise "space-before-paren" error:

// This code raise "space-before-paren" error in vala-lint
var regex = /^(xkb|m17n):(\w+)/;

You need to disable linting in the line to fix this, but I feel it's not smart:

var regex = /^(xkb|m17n):(\w+)/; // vala-lint=space-before-paren

It would be great if linting is disabled in regex expressions.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/93853615-ignore-linting-in-regex-expressions?utm_campaign=plugin&utm_content=tracker%2F45980444&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F45980444&utm_medium=issues&utm_source=github).
Arcitec commented 1 month ago

This is still a major problem with the Vala linter.

It needs to completely ignore the entirety of Regexp literals, everything between the / / markers!

We just had a project whose if (/^NAME="\s*(.+?)\s*"/m.match (distro_info, 0, out m)) was subtly broken by being "fixed" by vala-lint to if (/^NAME = "\s*(.+?)\s*"/m.match (distro_info, 0, out m))