nunit.analyzers icon indicating copy to clipboard operation
nunit.analyzers copied to clipboard

Refactoring suggestion for managing diagnostic metadata.

Open JohanLarsson opened this issue 6 years ago • 2 comments

I have found it to be nice to have classes like:

internal static class NUNIT17TestCaseSourceIsMissing
{
	public const string DiagnosticId = "NUNIT_17";

	internal static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(
            DiagnosticId ,
            "TestCaseSource argument does not specify an existing member.",
            "TestCaseSource argument does not specify an existing member.",
            Categories.Usage,
            DiagnosticSeverity.Error,
            true);
}

Reasons I like it is:

  • We group constants that belong together.
  • Enables easy scanning of what rule id's we use.

I'm not married to this idea, just thought I'd write an issue about it and see what you think.

JohanLarsson avatar Jan 19 '19 08:01 JohanLarsson

I think it makes sense to group the constants together that belong together. Now it is - in some cases - too easy to select the wrong constant by mistake, as most of them "lives" in a general namespace and in a general class, like TransformToConstraintModelDescription in NUnit.Analyzers.Constants.CodeFixConstants.

I find the current structuring less than ideal. The reason for why I have not created an issue for this, is that I have not had time to think about it in detail. TLDR I agree with the issue and thanks for reporting this.

mikkelbu avatar Jan 21 '19 22:01 mikkelbu

I'll write a PR with the refactoring then.

JohanLarsson avatar Jan 22 '19 17:01 JohanLarsson