【问题标题】:FxCop rule list subset for ASP.NET web applicationASP.NET Web 应用程序的 FxCop 规则列表子集
【发布时间】:2012-05-10 06:27:34
【问题描述】:

我们正在将 FxCop 与 VS 2010 专业版集成以使用 FxCop 集成 VS 扩展进行代码分析。我们已经看到,通过在 FxCop 中配置的所有默认规则集,我们得到了一大堆点报告,这些点很好,但不一定严格违反最佳实践,或者在大多数情况下可以不用。是否有任何规则列表,基本上是 FxCop 中所有规则的子集,人们通常使用这些规则对基于 Web 的项目进行代码分析,这些规则可以被认为是必须具备的。我们用谷歌搜索了一下,但找不到一个单一的(关于忽略基于个人选择的特定规则的讨论遍布整个网络)资源,其中列出了社区通常遵循的基于 web 的 asp.net/C# 的首选规则子集项目。

【问题讨论】:

    标签: fxcop


    【解决方案1】:

    实际上我正在使用 TeamCity 集成,但规则应该相同。尝试以下一次:

    <?xml version="1.0" encoding="utf-8"?>
    <FxCopProject Version="1.36" Name="testApplication">
     <ProjectOptions>
      <SharedProject>True</SharedProject>
      <Stylesheet Apply="False">\tools\fxcop\Xml\FxCopReport.xsl</Stylesheet>
      <SaveMessages>
       <Project Status="Excluded" NewOnly="False" />
       <Report Status="Active" NewOnly="False" />
      </SaveMessages>
      <ProjectFile Compress="True" DefaultTargetCheck="True" DefaultRuleCheck="True" SaveByRuleGroup="" Deterministic="True" />
      <EnableMultithreadedLoad>True</EnableMultithreadedLoad>
      <EnableMultithreadedAnalysis>True</EnableMultithreadedAnalysis>
      <SourceLookup>True</SourceLookup>
      <AnalysisExceptionsThreshold>10</AnalysisExceptionsThreshold>
      <RuleExceptionsThreshold>1</RuleExceptionsThreshold>
      <Spelling Locale="en-GB" />
      <OverrideRuleVisibilities>False</OverrideRuleVisibilities>
      <CustomDictionaries SearchFxCopDir="True" SearchUserProfile="True" SearchProjectDir="True" />
      <SearchGlobalAssemblyCache>False</SearchGlobalAssemblyCache>
      <DeadlockDetectionTimeout>120</DeadlockDetectionTimeout>
      <IgnoreGeneratedCode>False</IgnoreGeneratedCode>
     </ProjectOptions>
     <Targets>
        <Target Name="$(ProjectDir)/../../solution/PrecompiledWeb/application/bin/App_Code.dll" Analyze="True" AnalyzeAllChildren="True" />
     </Targets>
     <Rules>
      <RuleFiles>
       <RuleFile Name="$(FxCopDir)\Rules\DesignRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\GlobalizationRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\InteroperabilityRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\MobilityRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\NamingRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\PerformanceRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\PortabilityRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\SecurityRules.dll" Enabled="True" AllRulesEnabled="True" />
       <RuleFile Name="$(FxCopDir)\Rules\UsageRules.dll" Enabled="True" AllRulesEnabled="True" />
      </RuleFiles>
      <Groups />
      <Settings />
     </Rules>
     <FxCopReport Version="1.36" />
    </FxCopProject>
    

    【讨论】:

    • 我在寻找更深入的规则过滤。例如,可以忽略 Microsoft.Design 规则集中的规则 CA1014“使用 CLSCompliantAttribute 标记程序集”。我实际上是在寻找可以从每个默认 FxCop 规则集中忽略的规则列表,这应该会导致开发社区通常使用的规则列表。
    【解决方案2】:

    不,没有这样的野兽。即使有,你怎么能确定创建列表的人所做的决定确实适合你的情况?

    只有 200 条左右的规则。为什么不坐一两个小时来弄清楚你认为哪些是重要的呢?您甚至可以走捷径,只查看当前给您违规的那些。这可能会使筛查工作量减少到每小时不到 1/2。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多