JetBrains Rider 2024.3 Help

Code inspection: Confusing body-like statement

This inspection reports statements that look like a body of the previous statement and can cause confusion when reading the code.

In the example below, wr.WriteLine("hello"); looks like a nested statement of using. JetBrains Rider suggests removing the indent and separating the statements with a new line to improve readability and avoid ambiguity.

public void Test() { using var wr = new StreamWriter("C:\\hi.txt"); wr.WriteLine("hello"); Console.WriteLine("hi"); }
public void Test() { using var wr = new StreamWriter("C:\\hi.txt"); wr.WriteLine("hello"); Console.WriteLine("hi"); }
Last modified: 08 November 2024