|
1 | | -using JetBrains.Annotations; |
| 1 | +using System; |
| 2 | +using JetBrains.Annotations; |
2 | 3 |
|
3 | 4 | namespace CSharpGuidelinesAnalyzer |
4 | 5 | { |
5 | 6 | internal sealed class AnalyzerCategory |
6 | 7 | { |
7 | | - private const string CommitHash = "7a66f7468da6ce1477753a02e416e04bc9a44e45"; |
| 8 | + private const string CommitHash = "4ad2ebe71296a1d6e70d2f22f7b997edcd9e257d"; |
8 | 9 |
|
9 | 10 | [NotNull] |
10 | | - public static readonly AnalyzerCategory ClassDesign = new AnalyzerCategory("Class Design", "1000_ClassDesignGuidelines.md"); |
| 11 | + public static readonly AnalyzerCategory ClassDesign = new AnalyzerCategory("Class Design"); |
11 | 12 |
|
12 | 13 | [NotNull] |
13 | | - public static readonly AnalyzerCategory MemberDesign = new AnalyzerCategory("Member Design", "1100_MemberDesignGuidelines.md"); |
| 14 | + public static readonly AnalyzerCategory MemberDesign = new AnalyzerCategory("Member Design"); |
14 | 15 |
|
15 | 16 | [NotNull] |
16 | | - public static readonly AnalyzerCategory MiscellaneousDesign = new AnalyzerCategory("Miscellaneous Design", "1200_MiscellaneousDesignGuidelines.md"); |
| 17 | + public static readonly AnalyzerCategory MiscellaneousDesign = new AnalyzerCategory("Miscellaneous Design"); |
17 | 18 |
|
18 | 19 | [NotNull] |
19 | | - public static readonly AnalyzerCategory Maintainability = new AnalyzerCategory("Maintainability", "1500_MaintainabilityGuidelines.md"); |
| 20 | + public static readonly AnalyzerCategory Maintainability = new AnalyzerCategory("Maintainability"); |
20 | 21 |
|
21 | 22 | [NotNull] |
22 | | - public static readonly AnalyzerCategory Naming = new AnalyzerCategory("Naming", "1700_NamingGuidelines.md"); |
| 23 | + public static readonly AnalyzerCategory Naming = new AnalyzerCategory("Naming"); |
23 | 24 |
|
24 | 25 | [NotNull] |
25 | | - public static readonly AnalyzerCategory Framework = new AnalyzerCategory("Framework", "2200_FrameworkGuidelines.md"); |
| 26 | + public static readonly AnalyzerCategory Framework = new AnalyzerCategory("Framework"); |
26 | 27 |
|
27 | 28 | [NotNull] |
28 | | - public static readonly AnalyzerCategory Documentation = new AnalyzerCategory("Documentation", "2300_DocumentationGuidelines.md"); |
| 29 | + public static readonly AnalyzerCategory Documentation = new AnalyzerCategory("Documentation"); |
29 | 30 |
|
30 | 31 | [NotNull] |
31 | | - public static readonly AnalyzerCategory Layout = new AnalyzerCategory("Layout", "2400_LayoutGuidelines.md"); |
32 | | - |
33 | | - [NotNull] |
34 | | - private readonly string helpCategoryUri; |
| 32 | + public static readonly AnalyzerCategory Layout = new AnalyzerCategory("Layout"); |
35 | 33 |
|
36 | 34 | [NotNull] |
37 | 35 | public string DisplayName { get; } |
38 | 36 |
|
39 | | - private AnalyzerCategory([NotNull] string displayName, [NotNull] string documentName) |
| 37 | + private AnalyzerCategory([NotNull] string displayName) |
40 | 38 | { |
41 | 39 | DisplayName = displayName; |
42 | | - helpCategoryUri = $"https://github.com/dennisdoomen/CSharpGuidelines/blob/{CommitHash}/_pages/{documentName}"; |
43 | 40 | } |
44 | 41 |
|
45 | 42 | [NotNull] |
46 | 43 | public string GetHelpLinkUri([NotNull] string ruleId) |
47 | 44 | { |
48 | 45 | Guard.NotNullNorWhiteSpace(ruleId, nameof(ruleId)); |
49 | 46 |
|
50 | | - return helpCategoryUri + "#" + ruleId.ToLowerInvariant(); |
| 47 | + if (!ruleId.StartsWith("AV", StringComparison.Ordinal) || ruleId.Length != 6) |
| 48 | + { |
| 49 | + throw new InvalidOperationException($"Rule '{ruleId}' does not match the format AVnnnn."); |
| 50 | + } |
| 51 | + |
| 52 | + string ruleNumber = ruleId.Substring(2); |
| 53 | + return $"https://github.com/dennisdoomen/CSharpGuidelines/blob/{CommitHash}/_rules/{ruleNumber}.md"; |
| 54 | + |
51 | 55 | } |
52 | 56 | } |
53 | 57 | } |
0 commit comments