So there are quite a few components to code optimisation and refactoring of code.
The largest indicator for me is cyclomatic complexity, I work on the bases of anything over 7 should be refactored.
I want other methods of detecting code issues with large projects that other people use, specifically with SharePoint.
Regards,
Hugh
Okay, sounds reasonable.
I would go with custom rules for FxCop/SPCop/SPCAF, then. The issues is that there is no such a tool which knows specific API set including say asp.net, or SharePoint, or SAP, or whatsoever.
API set is the most challenging thing if we work under the particular platform, such as SharePoint. We has the same challenges with CRM, for example.
Right now, several people and I have teamed up and working on SPCAFContrib: we use SPCAF/SPCOP as an infrastructure, and extending it with the new rules to address the common pitfall both on XML/code. It includes poor performance, potential null-references issues, potential bad practices and so on.
Finally, we stumbled LOTS of challenges. As you mentioned, “Code with poor CA and CC metrics can often be poor performing and it is very rarely there are no ways around it” which basiacally means “It depends”, and leads to “some cases have to be checked manually”.
For example, we tried to implement “try-catch-finally” rule, but there are SO MANY cases where you might have empty catch statement what we almost gave up. Still working and researching, but really – some cases so hard to check/implement. Also, for examples, a good exception handling inside web controls, web pages, web parts – this is tricky thing, really. Some cases might be checked with automated rules, and most of them – not. So it leads to the false-positives and meaningless warnings, as you mentioned.
To sum up, we see that as trade off between several things:
- current code style of the current team
- manual checking of the doubtful code pieces
- tending to have no “false-positives”
- extending SPCAF/SPCOP to our needs
Mixing up these ideas to the good trade off might help to address common pitfalls and issues.Â