Rider: reformat names

I must be stupid somehow, but I found no way to auto-correct ("reformat") incorrectly styled variable names etc. There's a catalog in the settings for what style (e. g. camel case) I want for certain elements in the editor, but how do I make Rider appy them to the entire code or a selection of it?

0
11 comments

Hello Andreas,

Thank you for contacting Rider support.

Try selecting ‘Fix naming in solution’. Does it help?

Have a nice day!

0

The quick fix is shown like in the screenshot that you posted.

The thing is that I want to check the entire project for inconsistent naming. My understanding is that:

  • Naming rules are configured in Settings > Code Style > C# > Naming.
  • Inspection is enabled in Settings > Inspection Settings > Inspection Severity > C# > Constraints Violations > Inconsistent Naming.
  • Code > Inspect Code opens the Find Issues dialog where I can select Project [ProjectName] for inspection.
  • Selecting OK performs the code inspection.

I made sure that Rider's defaults have the rules and inspections for inconsistent naming enabled. When I run the inspection, inconsistent naming for a local variable is not shown on the Code Issues tab of the Problems pane. The quick fix however is shown, see the below screenshot.

What am I doing wrong?

0

One more: The Problems pane doesn't show the name inconsistency, too:

0

Hello Andreas,

Thank you for the details shared.

Would you mind telling me what severity is set for the Inconsistent Naming inspection? Does increasing severity to Warning or Error help? And what Rider version do you use (Help | About JetBrains Rider)

As a workaround, try the “Find similar issues” feature:

Have a nice day!

0

Dmitry,

The severity level is Warning. The version is JetBrains Rider 2025.2.1, Build #RD-252.25557.182, built on September 4, 2025.

Thank you for the Find similar issues heads-up.

0

Thank you for the clarification, I reproduced the same. I will check with the Team and get back to you when I have any news. Now I see, that when there is another similar severity inspection triggered on a token, the “Inconsistent Naming” inspection violation isn't shown in the “Inspect {}” results:

Have a nice day!

0

Hello Andreas,

I confirmed with the team that this is by-design behavior. There is no issue. Should you wish to dive into details below is the explanation for the behavior you observe.

When you need to search for a specific code issue in a project, you can use the “Find similar issues” feature as I mentioned.

Should you have any other questions or anything is unclear, please tell me.

Have a nice day!

________________________________________________________________________

When analyzing the code, there is such an entity called ‘range’. In simple words, it is two numbers: start and end positions. Position is an offset of a character starting from the beginning of the file. This range is also being used to highlight a code issue (squiggles) in the editor. In the below snippet (considering it as a file), code analysis can find several issues in ‘IntVal’. The range for that is 31-36, so the IntVal is highlighted in the editor. What squiggle style to use is determined by the severity of the most critical inspection triggered. 

Note: by design squiggles can't overlap. There is no sense in highlighting the same piece of code with multiple underlines (of different severity). And overlapping squiggles also would be confusing.

class Foo
{
 void Bar()
 {
  int IntVal = 5;
 }
}

So, Inspections can interfere with each other by range. When two or more inspections are triggered on the same range or intersecting by range, Rider highlights the most critical one (selecting the inspection with the highest severity and the smaller range). More critical inspection often makes it completely useless to address other minor inspections at the same range. E.g. if you are looking at an error saying that string is not allowed as a type argument somewhere, there's no point recommending you to change it to String type name as per code style.

When a range intersects for two or more code issues with the same severity, and Inspect Code is run, similar rules are being used to ‘filter out’ the minor code issues. The only inspection with the smaller range and the highest severity is shown in results. For e.g. the compiler warning is more critical than any other inspection with severity of Warning.

The Inspect Code ‘filters out’ the less minor inspections that interfere with more critical those (either because of severity difference, nor other heuristics when severity is the same). Otherwise, you might end up navigating to an inspection that isn't visible in the editor.

Hope that clears the situation. This is the by-design behavior.

0

Thank you Dmitry, understand, I tested and it works okay.

Last question: Can I run something like a “reformat names” across an entire project or solution, so that all instances of incorrect naming are auto-corrected according to the rules I configured in the settings?

0

Hello Andreas, 

Isn't “Fix naming in solution” what you want?

0

Sorry, I should have been more precise: instead of using this context action, is there a “global” command, like a menu item, that allows me to run a replace? The downside of having the rename option available as a context action is that I first need to place the cursor on one of the name inconsistencies before I can access the command…

0

I am afraid there is no way to fix naming in a solution via one action (having no inspection violation sample opened in the editor). However, that is what you can do:

  1. Find the naming violations via Code | Analyze Code | Run Inspection by Name:

  2. Type and select “Inconsistent Naming”

  3. Navigate to the sample issue occurrence and invoke “Fix naming in {}”:

Hope that helps. 
You might want to upvote this feature request to demonstrate your interest: RSRP-389273 There is no option in code cleanup to apply naming style

0

Please sign in to leave a comment.