-
Notifications
You must be signed in to change notification settings - Fork 509
Expand file tree
/
Copy pathSA1631DocumentationMustMeetCharacterPercentage.cs
More file actions
75 lines (69 loc) · 4.14 KB
/
SA1631DocumentationMustMeetCharacterPercentage.cs
File metadata and controls
75 lines (69 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#nullable disable
namespace StyleCop.Analyzers.DocumentationRules
{
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
/// <summary>
/// A section of the XML header documentation for a C# element does not contain enough alphabetic characters.
/// </summary>
/// <remarks>
/// <para>This diagnostic is not implemented in StyleCopAnalyzers.</para>
///
/// <para>C# syntax provides a mechanism for inserting documentation for classes and elements directly into the
/// code, through the use of XML documentation headers.</para>
///
/// <para>A violation of this rule occurs when part of the documentation does contain enough characters. This rule
/// is calculated by counting the number of alphabetic characters and numbers within the documentation text, and
/// comparing it against the number of symbols and other non-alphabetic characters. If the percentage of
/// non-alphabetic characters is too high, this generally indicates poorly formatted documentation which will be
/// difficult to read. For example, consider the follow summary documentation:</para>
///
/// <code>
/// /// <summary>
/// /// @)$(*A name--------
/// /// </summary>
/// public class Name
/// {
/// ...
/// }
/// </code>
/// </remarks>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
[NoDiagnostic("This diagnostic was determined to be too subjective and/or misleading to developers.")]
[NoCodeFix("Cannot generate documentation")]
internal class SA1631DocumentationMustMeetCharacterPercentage : DiagnosticAnalyzer
{
/// <summary>
/// The ID for diagnostics produced by the <see cref="SA1631DocumentationMustMeetCharacterPercentage"/>
/// analyzer.
/// </summary>
public const string DiagnosticId = "SA1631";
private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1631.md";
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1631Title), DocumentationResources.ResourceManager, typeof(DocumentationResources));
private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1631MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources));
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1631Description), DocumentationResources.ResourceManager, typeof(DocumentationResources));
private static readonly DiagnosticDescriptor Descriptor =
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release.
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable);
#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release.
#pragma warning restore IDE0079 // Remove unnecessary suppression
/// <inheritdoc/>
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create(Descriptor);
/// <inheritdoc/>
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
#pragma warning restore RS1026 // Enable concurrent execution
#pragma warning restore RS1025 // Configure generated code analysis
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
// This diagnostic is not implemented (by design) in StyleCopAnalyzers.
}
}
}