Closed miikeat closed 3 years ago
Can you create a custom logger to solve this? Like they talk about here: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1090#issuecomment-126791044
And they say it is described here: https://docs.microsoft.com/sv-se/previous-versions/visualstudio/visual-studio-2015/msbuild/build-loggers?view=vs-2015&redirectedfrom=MSDN
I am not using that tool, but perhaps a custom logger can create a report in any of the supported formats of this tool.
I was about to try that, but msbuild has a -fileLogger
parameter that writes the whole output of msbuild also to a file.
https://docs.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2019
I'm going to try that tomorrow, but I'm not sure how the Parser is going to handle all the stuff before and after the relevant stuff. Also the file is not XML now... so I guess a new or different parser will then be required... I'll post my findings tomorrow.
The relevant output looks like this btw:
C:\Test\CON-Tests\SC-CON-FR01.cs(529,40): warning SA1003: Operator '=>' should be followed by whitespace. [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT03.cs(368,29): warning SA1117: The parameters should all be placed on the same line or each parameter should be placed on its own line. [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT03.cs(366,7): warning SA1614: Element parameter documentation should have text [C:\Test\Test.csproj]
C:\Test\BAS-Tests\SC-BAS-FT06.cs(122,48): warning SA1503: Braces should not be omitted [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT03.cs(367,16): warning SA1606: Element documentation should have summary text [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT03.cs(370,3): warning SA1505: An opening brace should not be followed by a blank line. [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT03.cs(367,20): warning SA1116: The parameters should begin on the line after the declaration, whenever the parameter span across multiple lines [C:\Test\Test.csproj]
C:\Test\COM-Tests\SC-COM-FT03.cs(298,51): warning SA1503: Braces should not be omitted [C:\Test\Test.csproj]
C:\Test\COM-Tests\SC-COM-FT03.cs(333,22): warning SA1108: Block statements should not contain embedded comments [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT01.cs(356,1): warning SA1137: Elements should have the same indentation [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT01.cs(357,1): warning SA1137: Elements should have the same indentation [C:\Test\Test.csproj]
C:\Test\COM-Tests\SC-COM-FT03.cs(270,71): warning SA1108: Block statements should not contain embedded comments [C:\Test\Test.csproj]
C:\Test\COM-Tests\SC-COM-FT03.cs(293,38): warning SA1108: Block statements should not contain embedded comments [C:\Test\Test.csproj]
C:\Test\COM-Tests\SC-COM-FT17.cs(381,36): warning SA1500: Braces for multi-line statements should not share line [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT01.cs(437,1): warning SA1137: Elements should have the same indentation [C:\Test\Test.csproj]
C:\Test\MIO-Tests\SC-MIO-FT01.cs(438,1): warning SA1137: Elements should have the same indentation [C:\Test\Test.csproj]
C:\Test\COM-Tests\SC-COM-FT17.cs(437,36): warning SA1500: Braces for multi-line statements should not share line [C:\Test\Test.csproj]
Should be no problem implementing a paraer for that.
Can probably be done similar to CLangParser: https://github.com/tomasbjerre/violations-lib/blob/master/src/main/java/se/bjurr/violations/lib/parsers/CLangParser.java
Nice, in that case i just copy that parser, replace the regex with something like that: https://regex101.com/r/t2ZFbH/1 and send you a pullrequest. Do you have some kind of Contribution guide?
Add it as a new parser. I dont know if StyleCop2 or MSBuild might be fitting names. Is this the same format for all MSBuild output? Or the format is only for Stylecop?
Add it here, and the docs will be automatically updated: https://github.com/tomasbjerre/violations-lib/blob/master/src/main/java/se/bjurr/violations/lib/reports/Reporter.java
You can see some reporters have some small explanation. You should add that fileLogger parameter in that text.
Also add test case, like: https://github.com/tomasbjerre/violations-lib/blob/master/src/test/java/se/bjurr/violations/lib/CLangTest.java
Yeah I thought so too that MSBuildLogParser might be a better name as it hast the same format as regular msbuild warnings too. At least from what i've seen so far.
Alright... i'll try my best =)
is it an issue when the same warnings are twice in the output file?
They are added to a Set. So duplicates will automatically be removed.
The new Version of StyleCop is not generating an xml file anymore as mentioned here: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1178
Therefore the current StyleCop Parser does not find the report. Is there a way to get it to work again? Or is a new Parser required for this?