Skip to content

feat: Enable project-level exceptions in ReferenceCop ruleset#60

Open
mfogliatto wants to merge 1 commit into
mainfrom
fix/issue-29
Open

feat: Enable project-level exceptions in ReferenceCop ruleset#60
mfogliatto wants to merge 1 commit into
mainfrom
fix/issue-29

Conversation

@mfogliatto
Copy link
Copy Markdown
Owner

Summary

Adds support for configuring project-level exceptions on rules in the ReferenceCop config file. Projects listed in a rule's <Exceptions> element are exempt from that rule.

Changes

  • ReferenceCopConfig.cs: Added ProjectException class and Exceptions list to Rule base class, with IsProjectExempt() method
  • AssemblyNameViolationDetector.cs: Accepts optional projectName parameter; checks exceptions before reporting violations
  • ProjectTagViolationDetector.cs: Checks exceptions using project file name
  • ProjectPathViolationDetector.cs: Checks exceptions using project file name
  • ReferenceCopAnalyzer.cs: Passes compilation.AssemblyName to the detector
  • ReferenceCopConfig.xsd: Updated schema with Exceptions element for all rule types
  • ProjectExceptionTests.cs: Unit tests for the new functionality

Usage

<Rules>
  <AssemblyName>
    <Name>NoSystemXml</Name>
    <Description>System.Xml is forbidden</Description>
    <Severity>Error</Severity>
    <Pattern>System.Xml</Pattern>
    <Exceptions>
      <Project Name="LegacyAdapter" />
      <Project Name="XmlTools" />
    </Exceptions>
  </AssemblyName>
</Rules>

Fixes #29

Add an Exceptions element to rules that allows specifying projects
that are exempt from a given rule. Each rule can now contain:

  <Exceptions>
    <Project Name="MyProject" />
  </Exceptions>

- Added ProjectException class and Exceptions list to Rule base class
- Added IsProjectExempt() method for checking exemptions
- Updated all three violation detectors to check exceptions
- Updated XSD schema with Exceptions element for all rule types
- Added unit tests for the new functionality

Fixes #29
@mfogliatto
Copy link
Copy Markdown
Owner Author

Pending on CI/CD change first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable configuration of exceptions for specific projects in ReferenceCop ruleset

1 participant