dotnet / format

Home for the dotnet-format command
MIT License
1.93k stars 173 forks source link

Can I use dotnet format to just generate report and not make the changes to the file. #2098

Closed jikuma closed 7 months ago

jikuma commented 8 months ago

I have a legacy codebase, and I want to ensure that any new code added to it follows the standard coding style. My plan is to generate a report initially and commit this report. Later, during subsequent runs, I can generate a new report and compare it with the original one. If there are differences, it likely indicates that new errors have been introduced, and I can then address them.

My challenge lies in allowing users to run this tool locally. Allowing them to run the tool locally would inadvertently format all the legacy files as well. How can I prevent this from happening?

JoeRobich commented 8 months ago

I would make a script file for your users run instead of dotnet-format directly. It would wrap dotnet format --verify-no-changes --report {reportPath}.json and could even diff or comp the generated report against your baseline report. Do note that if legacy files are modified that may move the location of the previously reported changes and would require a new baseline report to be generated.

sharwell commented 7 months ago

Resolving as answered