Visual Studio 2017: Ruleset won't execute

Viewed 126

I want to define a custom set of rules to be checked at compile time. But it seems not to work.

Example: I choose one rule directly and I'll get the expected warning. enter image description here

But when I instead create a custom ruleset containing the exact same rule then I won't get the expected warning. enter image description here

What could be wrong?

Edit:

void f(std::string& i) {
    std::string s = i;
    cout << s;
}

int main()
{
    std::string s ("abc");
    f(s);
}

This gives me the expected warning Warnung C26460 The reference argument 'i' for function 'f' can be marked as const (con.3). in the first case. Even if I create a custom ruleset including all available rules, I won't get any warnings.

Here you see me selecting the custom ruleset: enter image description here

Edit: The ruleset action must change one time to enable it. When I create a new ruleset containing only the const-checks then I will get a .ruleset that does not work and look like this:
enter image description here In the ruleset editor it looks like this:
enter image description here When I then change its action from Warning to Error:
enter image description here Then the .ruleset gets additional lines for each test case:
enter image description here When I change the action back to warning it looks like this:
enter image description here Now it is working as expected.

1 Answers

I've been able to reproduce your error with Visual Studio 2017. I don't know exactly what I changed (or if I changed anything at all), but I am able to see the code analysis warning you expect with a custom rule set.

Things I would try:

  1. Double check the Error List window is visible and not hiding somewhere.
  2. Open the rule set file, change the Action to Error and then back to Warning and save it. I wouldn't expect this to be the problem but it's one of the things I did and after which I started seeing the Error List window.

Visual Studio 2017 screenshot with the custom rule set working OK

Related