From 20,663 issues to 1 issue–style-copping C5.Tests
Posted
by TATWORTH
on Geeks with Blogs
See other posts from Geeks with Blogs
or by TATWORTH
Published on Wed, 28 May 2014 13:56:58 GMT
Indexed on
2014/05/28
21:30 UTC
Read the original article
Hit count: 194
Originally posted on: http://geekswithblogs.net/TATWORTH/archive/2014/05/28/from-20663-issues-to-1-issuendashstyle-copping-c5.tests.aspx
I recently became interested in the potential of the C5 Collections solution from http://www.itu.dk/research/c5/, however I was dismayed at the state of the code in the unit test project, so I set about fixing the 20,663 issues detected by StyleCop.
The tools I used were the latest versions of:
- My 64-bit development PC running Windows 8 Update with 8Gb RAM
- Visual Studio 2013 Ultimate with SP2
- ReSharper
- GhostDoc Pro
My first attempt had to be abandoned due to collision of class names which broke one of the unit tests. So being aware of this duplication of class names, I started again and planned to prepend the class names with the namespace name. In some cases I additionally prepended the item of the C5 collection that was being tested.
So what was the condition of code at the start? Besides the sprawl of C# code not written to style cop standard, there was:
1) Placing of many classes within one physical file.
2) Namespace within name space that did not follow the project structure.
3) As already mentioned, duplication of class names across namespaces.
4) A copyright notice that spawled but had to be preserved.
5) Project sub-folders were all lower case instead of initial letter capitalised.
The first step was to add a stylecop heading plus the original heading contained within a region, to every file. The next step was to run GhostDoc Pro using its “Document File” option on every file but not letting it replace the headers, I had added. This brought the number of issues down to 18,192. I then went through each file collapsing each class and prepending names as appropriate. At each step, I saved the changes to my local Git.
The step was to move each class to its own file and to style-cop each file. ReSharper provides a very useful feature for doing this which also fixes missing “this.” and moves using statements inside the namespace. Some classes required minimal work whereas others required extensive work to reach the stylecop standard. The unit tests were run at each split and when each class was completed.
When all was done, one issue remained which I will need to submit to stylecop team for their advice (and possibly a fix to stylecop).
The updated solution has been made available at https://c5stylecopped.codeplex.com/releases/view/122785.
© Geeks with Blogs or respective owner