Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Fix lint job in CI - #2581

Merged
vitek-karas merged 3 commits into
dotnet:mainfrom
vitek-karas:FixLintInCI
Feb 4, 2022
Merged

vitek-karas merged 3 commits into
dotnet:mainfrom
vitek-karas:FixLintInCI

Conversation

@vitek-karas

Copy link
Copy Markdown
Member

It did run linter, but didn't fail if any changes were to be applied, instead it actually applied them (and then dropped). So the job would actually never fail.

It did run linter, but didn't fail if any changes were to be applied, instead it actually applied them (and then dropped). So the job would actually never fail.
@vitek-karas
vitek-karas requested a review from sbomer as a code owner February 2, 2022 22:31

@sbomer sbomer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some formatting failures in test files, otherwise LGTM. We might want to exclude the test directory if those aren't easily fixed - it has RunAnalyzers set to false but it seems dotnet format doesn't respect this.

<RunAnalyzers>false</RunAnalyzers>

@vitek-karas

Copy link
Copy Markdown
Member Author

This is really weird - I ran it locally to "fix" things, and it didn't do those - but then it fails on them?

@sbomer

sbomer commented Feb 3, 2022

Copy link
Copy Markdown
Member

Weird... could it be using a different version of dotnet-format locally for some reason? I have hit problems in the past with breaking changes to dotnet-format and IIRC I had to be very careful to make sure it used the right SDK.

@vitek-karas

Copy link
Copy Markdown
Member Author

Honestly - the tool is... confusing.

dotnet format may not fix some warnings - and it says so with something like Unable to apply fixes for <id>. But it does not show the warnings it wasn't able to fix.
dotnet format --verify-no-changes on the other hand shows these warnings.

You can force dotnet format to show them as well with -v d, but that produces lot of output - mostly useless and the warnings are sort of hidden in the middle.

dotnet format does not return error exit code if fails to fix things.

dotnet format may say that it failed to fix things, while it actually did fix them (specifically IDE00005 - unused using).

So for now I did this:

  • Most of the warnings were unused parameters in tests -> I disabled those in the editorconfig as this is basically expected for tests
  • I fixed one warning which made sense
  • I modified our lint scripts to run the tool twice. First to actually apply formatting and second time with the --verify-no-change - this has the effect that it will report unfixed warnings and it will actually fail the command if there are any.

It's not perfect, it takes a while to run (twice) and the output is still unnecessarily long, but at least it works.

@vitek-karas

Copy link
Copy Markdown
Member Author

I filed dotnet/format#1508 to hopefully improve the tool

@vitek-karas vitek-karas self-assigned this Feb 3, 2022
@vitek-karas
vitek-karas merged commit cdd4079 into dotnet:main Feb 4, 2022
@vitek-karas
vitek-karas deleted the FixLintInCI branch February 4, 2022 11:52
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
It did run linter, but didn't fail if any changes were to be applied, instead it actually applied them (and then dropped). So the job would actually never fail.

Commit migrated from dotnet/linker@cdd4079
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants