Skip to content

Tool should return error exit code if it fails to apply fixes and report the relevant warnings #1508

Open

Description

@vitek-karas

Repro:

Program.cs:

TestMethod(0);

void TestMethod(int unused)
{
}

.editorconfig:

[*cs]
# IDE0060: Remove unused parameter
dotnet_diagnostic.IDE0060.severity = warning
> dotnet format
Unable to fix IDE0060. No associated code fix found.
> dotnet format --verify-no-changes
...\Program.cs(6,21): warning IDE0060: Remove unused parameter 'unused' [...csproj]
<failure exit code>

I definitely understand that there are warnings which can't be fixed automatically - like removing parameters to a method. But in that case I would expect the tool to report the actual warning. Just saying the it can't fix IDE0060 doesn't help ... where? Also note that it will say this even if there are 100s warnings like that, so there's no indication of how "bad" it is.

I would also expect the tool to report failure exit code if this happens. Mainly since it should match what it does when run with --verify-no-changes.

Scenario:
In the CI, we run dotnet format --verify-no-changes to enforce the rules. The guide is: "If this fails, run dotnet format locally before PR".
But with the above if I run dotnet format it doesn't fail and it only says that it could not fix something but doesn't say what, so people tend to simply ignore that. And then it fails in CI.

If not by default, there should at least be some command line option to get a better behavior. I do know that it's possible to get the warnings with -v d, but that produces lot of additional output, which again makes it confusing.

Activity

  1. justinmchase commented on Mar 22, 2022

    @justinmchase

    I just got hit by this also if you add -v d it adds the info so its not like it can't it just seems like it needs to have a higher default verbosity for fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions