Index: src/main/java/hudson/plugins/violations/types/fxcop/FxCopParser.java =================================================================== --- src/main/java/hudson/plugins/violations/types/fxcop/FxCopParser.java (revision 28082) +++ src/main/java/hudson/plugins/violations/types/fxcop/FxCopParser.java (working copy) @@ -128,7 +128,7 @@ private void parseAccessors(Element accessorsElement, String parentName) { if (accessorsElement != null) { - for (Element member : XmlElementUtil.getNamedChildElements(accessorsElement, "Accessors")) { + for (Element member : XmlElementUtil.getNamedChildElements(accessorsElement, "Accessor")) { parseMember(member, parentName); } } Index: src/test/java/hudson/plugins/violations/types/fxcop/FxCopParserTest.java =================================================================== --- src/test/java/hudson/plugins/violations/types/fxcop/FxCopParserTest.java (revision 0) +++ src/test/java/hudson/plugins/violations/types/fxcop/FxCopParserTest.java (revision 0) @@ -0,0 +1,41 @@ +package hudson.plugins.violations.types.fxcop; + +import static org.junit.Assert.*; +import hudson.plugins.violations.model.FullBuildModel; +import hudson.plugins.violations.model.Violation; +import hudson.plugins.violations.types.fxcop.FxCopParser; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Iterator; + +import org.junit.Test; + +public class FxCopParserTest { + + private FullBuildModel getFullBuildModel(String filename) throws IOException { + URL url = getClass().getResource(filename); + File xmlFile; + try { + xmlFile = new File(url.toURI()); + } catch(URISyntaxException e) { + xmlFile = new File(url.getPath()); + } + + FxCopParser parser = new FxCopParser(); + FullBuildModel model = new FullBuildModel(); + parser.parse(model, xmlFile.getParentFile(), xmlFile.getName(), null); + model.cleanup(); + return model; + } + + @Test + public void testParseFullBuildModelFileStringStringArray() throws Exception { + FullBuildModel model = getFullBuildModel("fxcop.xml"); + + assertEquals("Number of violations is incorrect", 2, model.getCountNumber("fxcop")); + assertEquals("Number of files is incorrect", 2, model.getFileModelMap().size()); + } +} Index: src/test/resources/hudson/plugins/violations/types/fxcop/fxcop.xml =================================================================== --- src/test/resources/hudson/plugins/violations/types/fxcop/fxcop.xml (revision 0) +++ src/test/resources/hudson/plugins/violations/types/fxcop/fxcop.xml (revision 0) @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="utf-8"?> +<?xml-stylesheet type="text/xsl" href="c:\program files\microsoft fxcop 1.36\Xml\FxCopReport.xsl"?> +<FxCopReport Version="1.36"> + <Targets> + <Target Name="C:\Hudson\data\jobs\job1\workspace\test\bin\test.dll"> + <Modules> + <Module Name="test.dll"> + <Namespaces> + <Namespace Name="Test.Space"> + <Types> + <Type Name="TestBase" Kind="Class" Accessibility="Public" ExternallyVisible="True"> + <Members> + <Member Name="#Price" Kind="Property" Static="False" Accessibility="Public" ExternallyVisible="True"> + <Accessors> + <Accessor Name="#get_Price()" Kind="Method" Static="False" Accessibility="Public" ExternallyVisible="True"> + <Messages> + <Message Id="System.Decimal.ToString(System.String)" TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305" Status="Active" Created="2010-03-01 17:03:03Z" FixCategory="DependsOnFix"> + <Issue Certainty="95" Level="Error" Path="c:\Hudson\data\jobs\job1\workspace\test\Space" File="TestBase.cs" Line="299">Because the behavior of 'decimal.ToString(string)' could vary based on the current user's locale settings, replace this call in 'FilmFacadeBase.Price.get()' with a call to 'decimal.ToString(string, IFormatProvider)'. If the result of 'decimal.ToString(string, IFormatProvider)' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.</Issue> + </Message> + </Messages> + </Accessor> + </Accessors> + </Member> + </Members> + </Type> + </Types> + </Namespace> + </Namespaces> + </Module> + </Modules> + </Target> + <Target Name="C:\Hudson\data\jobs\job1\workspace\web\bin\web.dll"> + <Modules> + <Module Name="web.dll"> + <Namespaces> + <Namespace Name="Web.UserControls"> + <Types> + <Type Name="MyControl" Kind="Class" Accessibility="Public" ExternallyVisible="True"> + <Members> + <Member Name="#InitialParameters(System.Boolean)" Kind="Method" Static="False" Accessibility="Family" ExternallyVisible="True"> + <Messages> + <Message Id="javascript" TypeName="CompoundWordsShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1702" Status="Active" Created="2010-03-01 17:03:03Z" FixCategory="Breaking"> + <Issue Name="MemberParameterShouldBeCompoundWord" Certainty="80" Level="Error" Path="c:\Hudson\data\jobs\job1\workspace\web\UserControls" File="MyControl.ascx.cs" Line="37">In member 'MyControl.InitialParameters(bool)', the discrete term 'javascript' in parameter name 'javascript' should be expressed as a compound word, 'javaScript'.</Issue> + </Message> + </Messages> + </Member> + </Members> + </Type> + </Types> + </Namespace> + </Namespaces> + </Module> + </Modules> + </Target> + </Targets> + <Rules> + <Rule TypeName="AvoidUncalledPrivateCode" Category="Microsoft.Performance" CheckId="CA1811"> + <Name>Avoid uncalled private code</Name> + <Description>There is uncalled code that is not externally visible and is not a known runtime entry point. If this violation fires in error, please send a problem report to the Visual Studio Code Analysis team.</Description> + <Resolution Name="Default">{0} appears to have no upstream public or protected callers.</Resolution> + <Owner /> + <Url>http://msdn2.microsoft.com/library/ms182264(VS.90).aspx</Url> + <Email>[none]</Email> + <MessageLevel Certainty="75">Warning</MessageLevel> + <File Name="PerformanceRules.dll" Version="9.0.0.0" /> + </Rule> + <Rule TypeName="CompoundWordsShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1702"> + <Name>Compound words should be cased correctly</Name> + <Description>Avoid creating compound words from terms which exist in the dictionary as discrete terms. Do not create a compound word such as 'StopWatch' or 'PopUp'. These terms are recognized in the dictionary and should be cased as 'Stopwatch' and 'Popup'.</Description> + <Resolution Name="MemberParameterShouldBeCompoundWord">In member {0}, the discrete term '{1}' in parameter name {2} should be expressed as a compound word, '{3}'.</Resolution> + <Owner /> + <Url>http://msdn2.microsoft.com/library/bb264474(VS.90).aspx</Url> + <Email>[none]</Email> + <MessageLevel Certainty="80">Error</MessageLevel> + <File Name="NamingRules.dll" Version="9.0.0.0" /> + </Rule> + <Rule TypeName="DoNotInitializeUnnecessarily" Category="Microsoft.Performance" CheckId="CA1805"> + <Name>Do not initialize unnecessarily</Name> + <Description>Do not make initializations that have already been done by the runtime.</Description> + <Resolution Name="Default">{0} initializes field {1} of type {2} to {3}. Remove this initialization because it will be done automatically by the runtime.</Resolution> + <Owner /> + <Url>http://msdn2.microsoft.com/library/ms182274(VS.90).aspx</Url> + <Email>[none]</Email> + <MessageLevel Certainty="90">Warning</MessageLevel> + <File Name="PerformanceRules.dll" Version="9.0.0.0" /> + </Rule> + <Rule TypeName="InstantiateArgumentExceptionsCorrectly" Category="Microsoft.Usage" CheckId="CA2208"> + <Name>Instantiate argument exceptions correctly</Name> + <Description>String arguments passed to constructors of ArgumentException and its derived types should be correct. Types derived from ArgumentException have inconsistent constructor overloads with respect to the message and paramName parameters as compared to ArgumentException.</Description> + <Resolution Name="IncorrectParameterName">Method {0} passes '{1}' as the {2} argument to a {3} constructor. Replace this argument with one of the method's parameter names. Note that the provided parameter name should have the exact casing as declared on the method.</Resolution> + <Owner /> + <Url>http://msdn2.microsoft.com/library/ms182347(VS.90).aspx</Url> + <Email>[none]</Email> + <MessageLevel Certainty="95">CriticalError</MessageLevel> + <File Name="UsageRules.dll" Version="9.0.0.0" /> + </Rule> + <Rule TypeName="SpecifyCultureInfo" Category="Microsoft.Globalization" CheckId="CA1304"> + <Name>Specify CultureInfo</Name> + <Description>If an overload exists that takes a CultureInfo argument, it should always be called in favor of an overload that does not. The CultureInfo type contains culture-specific information required for performing numeric and string operations, such as casing, formatting, and string comparisons. In scenarios where conversion and parsing behavior should never change between cultures, specify CultureInfo.InvariantCulture, otherwise, specify CultureInfo.CurrentCulture.</Description> + <Resolution Name="Default">Because the behavior of {0} could vary based on the current user's locale settings, replace this call in {1} with a call to {2}. If the result of {2} will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'CultureInfo' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.</Resolution> + <Owner /> + <Url>http://msdn2.microsoft.com/library/ms182189(VS.90).aspx</Url> + <Email>[none]</Email> + <MessageLevel Certainty="95">Error</MessageLevel> + <File Name="GlobalizationRules.dll" Version="9.0.0.0" /> + </Rule> + <Rule TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305"> + <Name>Specify IFormatProvider</Name> + <Description>If an overload exists that takes an IFormatProvider argument, it should always be called in favor of an overload that does not. Some methods in the runtime convert a value to or from a string representation and take a string parameter that contains one or more characters, called format specifiers, which indicate how the value is to be converted. If the meaning of the format specifier varies by culture, a formatting object supplies the actual characters used in the string representation. In scenarios where sorting and comparison behavior should never change between cultures, specify CultureInfo.InvariantCulture, otherwise, specify CultureInfo.CurrentCulture.</Description> + <Resolution Name="Default">Because the behavior of {0} could vary based on the current user's locale settings, replace this call in {1} with a call to {2}. If the result of {2} will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.</Resolution> + <Owner /> + <Url>http://msdn2.microsoft.com/library/ms182190(VS.90).aspx</Url> + <Email>[none]</Email> + <MessageLevel Certainty="95">Error</MessageLevel> + <File Name="GlobalizationRules.dll" Version="9.0.0.0" /> + </Rule> + <Rule TypeName="UsePreferredTerms" Category="Microsoft.Naming" CheckId="CA1726"> + <Name>Use preferred terms</Name> + <Description>Use preferred terms over deprecated alternates.</Description> + <Resolution Name="Type">Replace the term '{0}' in type name {1} with the preferred alternate '{2}'.</Resolution> + <Owner /> + <Url>http://msdn2.microsoft.com/library/ms182258(VS.90).aspx</Url> + <Email>[none]</Email> + <MessageLevel Certainty="95">Error</MessageLevel> + <File Name="NamingRules.dll" Version="9.0.0.0" /> + </Rule> + </Rules> + <Localized> + <String Key="Category">Category</String> + <String Key="Certainty">Certainty</String> + <String Key="CollapseAll">Collapse All</String> + <String Key="CheckId">Check Id</String> + <String Key="Error">Error</String> + <String Key="Errors">error(s)</String> + <String Key="ExpandAll">Expand All</String> + <String Key="Help">Help</String> + <String Key="Line">Line</String> + <String Key="Messages">message(s)</String> + <String Key="LocationNotStoredInPdb">[Location not stored in Pdb]</String> + <String Key="Project">Project</String> + <String Key="Resolution">Resolution</String> + <String Key="Rule">Rule</String> + <String Key="RuleFile">Rule File</String> + <String Key="RuleDescription">Rule Description</String> + <String Key="Source">Source</String> + <String Key="Status">Status</String> + <String Key="Target">Target</String> + <String Key="Warning">Warning</String> + <String Key="Warnings">warning(s)</String> + <String Key="ReportTitle">Code Analysis Report</String> + </Localized> +</FxCopReport>