Monday, January 23, 2012

HTML reporting for StyleCop

Based on the outputs from the earlier script; and using an appearance inspired by the output from the XSL report approach from codecampserver; but with the source in-lined into the report, and violation messages inserted after the affected lines. Each file (and the nested violation messages) are hidden by default, and can be expanded by clicking the file header or the source marked as violation (where the hand cursor shows):

N.B. Defined as it is within a PowerShell here-string, the jQuery script needs its $ symbols to be escaped to keep the PowerShell parser happy.



You will need to adjust the script to find the appropriate StyleCop output files from your build process, and create suitably named/located reports based on those files.

4 comments :

Anonymous said...

Looks very good, except:

1) Use this XML file and your script says no violations for a few files even though there is a violation: http://pastie.org/private/dn9xbgienhklbivrocq

2) It would be sweet if you could expand everything (all the code blocks and all the separate violations) by clicking one thing or hitting one button on the keyboard.

Steve Gilham said...

Without the exact source files I can't be certain what is going on -- but two things would cause a violation not to be visible:

1) It's against a zero-length line, so change line 140 0f the script to

$li.InnerText = " " + $_.InnerText

2) The line number is not present in the file -- this could happen if generated files get changed after the StyleCop inspection. That seems less likely to me; and would require a bit more work in the script.

Making everything visible at once should be a simple enough bit of extra Javascript.

I'll get around to these eventually.

Anonymous said...

Thanks, dude :)

Steve Gilham said...

All this done, and handling missing files too (code above updated).