-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--check along with --dry-run not working as expected #113
Comments
@francisminu can you post what the formatted file looks like? what does the formatter do with these settings? |
When I run just --check, the files are formatted (just like running dotnet format without any options) and the response is as below: 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");
}
} When I run --dry-run --check, the files are not formatted, but the message in CLI is as below and the code is given below it:
Code: 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");
}
} The console shows the same message in either case. But while running --dry-run --check together, the file is not modified. Thanks! |
@jmarolf Hi Jonathan, Thanks! |
Haven't had time to look at this yet @JoeRobich whitespace rules are always applied correct? |
If you don't mind, I think I can provide some input on this since I wrote some of the logging code. The As for some of the other points:
|
I installed this version
And ran the same command with some extra status reporting at the end
And I double-checked the git status just to be sure that check didn't change any files (adhering to the dry-run flag).
|
IMO, this behavior doesn't really make sense. Other autoformatters, like prettier or black (for JS and Python respectively), print out an error message instead of actually changing files. I feel like this tool should follow the same convention. |
@AnthonyMastrean Thanks for giving it a run. That is the expected behavior. The formatter is run against each file and the files with formatting changes are printed to the console as @arnavb I think the story around logging formatting issues is one that we could improve on. Perhaps an easy change to give more meaningful feedback would be to Log the |
@arnavb With #249, we now log individual messages for each formatting issue. These are printed during You can try this change by installing from myget
|
Closing issue due to inactivity. |
…thub.com/dotnet/arcade (dotnet#113) * Updating version files * Updating version files
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:
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:
Is it possible to display the files that doesn't abide by EditorConfig and the rules that it does not conform to?
Thanks!
The text was updated successfully, but these errors were encountered: