Do you know when functions are too complicated?
Updated by Brady Stroud [SSW] 1 year ago. See history
123
<introEmbed
body={<>
You should generally be looking for ways to simplify your code (e.g. removing heavily-nested case statements). As a minimum, look for the most complicated method you have and check whether it needs simplifying.
In Visual Studio, there is built-in support for Cyclomatic Complexity analysis.
</>}
/>

- Go to Analyze | Calculate Code Metrics | For Solution

Figure: Launching the Code Metrics tool within Visual Studio
- Look at the function with the largest Cyclomatic Complexity number and consider refactoring to make it simpler.

Figure: Results from cyclomatic analysis (and other analyses) give an indication of how complicated functions are
Tip: Aim for "green" against each function's Maintainability Index.
Categories
Related rules
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.