question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--check along with --dry-run not working as expected

See original GitHub issue

Hi,

My intention was to get a set of files and the errors associated with them with the --check command. But seems like --check returns just a non-zero response if there are any files that do not conform to the rules.

I tried the same, but the command ‘dotnet format --check’ doesn’t seem to be different from running dotnet format without any options. They both format the file and save changes to disk.

Now, I tried to run the option --dry-run --check (as mentioned in another issue), so that it shows just the files that have error and returns a non-zero exit code. But, the command executed successfully.

Please find below the code against which the command was run:

       class Program
       {
          static void Main(string[] args)
         {
            test();
            Console.WriteLine("Inside Main");
         }
         public static void test()
         {
            var i = 0;
            if (i == 0){
                Console.WriteLine("i is 0");
            }
            else
            {
                Console.WriteLine("i is not 0");
            }
            Console.WriteLine("Inside Test method");
         }
       }

Rule: csharp_new_line_before_else = true csharp_new_line_before_open_brace = all

When I ran > dotnet format --check The braces were formatted in the file Program.cs and the changes were saved.

Now, I tried running > dotnet format --dry-run --check With the hope that it will exit with non-zero exit code. But it showed the below message:

Formatting code files in workspace ‘C:\Project\MyHobbyProjects\EditoConfigCLISample\ConsoleApp1\ConsoleApp1.sln’. Loading workspace. Workspace loaded in 1785ms. Formatting code files in project ‘ConsoleApp1’. Formatting code file ‘Program.cs’. Formatted code file ‘Program.cs’. Formatted 1 of 3 files in 1275ms. Format complete.

Is it possible to display the files that doesn’t abide by EditorConfig and the rules that it does not conform to?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JoeRobichcommented, Feb 8, 2020

Closing issue due to inactivity.

1reaction
JoeRobichcommented, Jul 13, 2019

@arnavb With https://github.com/dotnet/format/pull/249, we now log individual messages for each formatting issue. These are printed during --dry-runs and when you also include the --check flag it will log as an Error instead of a Warning.

You can try this change by installing from myget

dotnet tool install -g dotnet-format --version 3.1.36303 --add-source https://dotnet.myget.org/F/format/api/v3/index.json
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dry run in Ansible not showing errors as in actual run
The issue is that in check mode, the user module only checks whether or not the user exists. The solution is to add...
Read more >
In praise of --dry-run
I'm adamantly pro dry-run and like OP I've found that you really need to design for it. From my experience, OP's two main...
Read more >
What is meant by dry run testing in software testing?
Software Testing is to ensure that product will be delivered will meet customer's need or could help to solve their problem. And it...
Read more >
Is dry-run testing done before the code is written out?
A dry run test is a mental exercise where a developer runs through their proposed solution, step by step, to ensure that it...
Read more >
Troubleshoot Amazon EC2 Auto Scaling: Launch templates
After making your changes, re-run the run-instances command with the --dry-run option to verify that your launch template uses valid values.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found