Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper - keep named parameters when doing code cleanup

We've adopted a convention that when calling a C# function with a "non-obvious" parameter, we use a named parameter even when it's not necessary.

E.g.

obj.Process(save: true)

rather than

obj.Process(true)

While it's unnecessary, it makes it a lot easier when glancing through the code to see what's going on, particularly with booleans or magic numbers.

However, resharper's code cleanup has a habit of removing these. I haven't been able to find a way to tell it to keep named parameters - is there one?

like image 627
Stuart Moore Avatar asked Jul 08 '15 16:07

Stuart Moore


People also ask

How to run ReSharper code cleanup?

Select ReSharper | Options from the main menu or press Alt+R O . Go to the cleanup profiles settings page: Code Editing | Code Cleanup | Profiles. Select which Code Cleanup profile should be applied on save and click Set as default (the default profile is also used for silent cleanup).

What does code clean up do?

Code cleanup refers to the act of writing code so that it cleans up leftover data structures and other unwanted materials from memory and the filesystem. It is sometimes treated as a synonym of refactoring code, which involves making the source code itself easier to understand, maintain, and modify.

How do you code cleanup?

You can also run code cleanup across your entire project or solution. Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.

What is code cleanup in Intellij?

tip. You can also run code cleanup using the command-line utility. JetBrains Rider allows you to apply formatting and other code style preferences in a bulk mode to instantly eliminate code style violations in one or more files, in a project or in the entire solution.


1 Answers

Although you can achieve it by doing what @EricWalker said, I want to propose another option.

You can start up the ReSharper options, look for Inspection Severity then go to Redundant explicit argument name specification and change this to do not show. This way you won't lose all the other good cleanups (like removing full name qualifiers) that remove redundant code offers.

like image 148
Matthias Avatar answered Sep 23 '22 20:09

Matthias