Skip to content

Commit a48cdfe

Browse files
committed
Address PR comments
1 parent ed11591 commit a48cdfe

7 files changed

Lines changed: 24 additions & 24 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1300UnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task TestAllowedLowerCaseNamespaceIsNotReportedAsync()
5151
{
5252
""settings"": {
5353
""namingRules"": {
54-
""allowedNamespaceComponentTerms"": [ ""eBay"" ]
54+
""allowedNamespaceComponents"": [ ""eBay"" ]
5555
}
5656
}
5757
}
@@ -99,7 +99,7 @@ public async Task TestAllowedLowerCaseComplicatedNamespaceIsNotReportedAsync()
9999
{
100100
""settings"": {
101101
""namingRules"": {
102-
""allowedNamespaceComponentTerms"": [ ""iPod"" ]
102+
""allowedNamespaceComponents"": [ ""iPod"" ]
103103
}
104104
}
105105
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsUnitTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void VerifySettingsDefaults()
2929
Assert.Equal("Copyright (c) PlaceholderCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
3030
Assert.True(styleCopSettings.NamingRules.AllowCommonHungarianPrefixes);
3131
Assert.Empty(styleCopSettings.NamingRules.AllowedHungarianPrefixes);
32-
Assert.Empty(styleCopSettings.NamingRules.AllowedNamespaceComponentTerms);
32+
Assert.Empty(styleCopSettings.NamingRules.AllowedNamespaceComponents);
3333

3434
Assert.NotNull(styleCopSettings.OrderingRules);
3535
Assert.Equal(UsingDirectivesPlacement.InsideNamespace, styleCopSettings.OrderingRules.UsingDirectivesPlacement);
@@ -62,7 +62,7 @@ public async Task VerifySettingsAreReadCorrectlyAsync()
6262
""namingRules"": {
6363
""allowCommonHungarianPrefixes"": false,
6464
""allowedHungarianPrefixes"": [""a"", ""ab"", ""ignoredTooLong""],
65-
""allowedNamespaceComponentTerms"": [""eBay"", ""iMac""],
65+
""allowedNamespaceComponents"": [""eBay"", ""iMac""],
6666
""unrecognizedValue"": 3
6767
},
6868
""layoutRules"": {
@@ -95,7 +95,7 @@ public async Task VerifySettingsAreReadCorrectlyAsync()
9595
Assert.Equal("ru-RU", styleCopSettings.DocumentationRules.DocumentationCulture);
9696
Assert.False(styleCopSettings.NamingRules.AllowCommonHungarianPrefixes);
9797
Assert.Equal(new[] { "a", "ab" }, styleCopSettings.NamingRules.AllowedHungarianPrefixes);
98-
Assert.Equal(new[] { "eBay", "iMac" }, styleCopSettings.NamingRules.AllowedNamespaceComponentTerms);
98+
Assert.Equal(new[] { "eBay", "iMac" }, styleCopSettings.NamingRules.AllowedNamespaceComponents);
9999

100100
Assert.NotNull(styleCopSettings.LayoutRules);
101101
Assert.Equal(OptionSetting.Require, styleCopSettings.LayoutRules.NewlineAtEndOfFile);

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace StyleCop.Analyzers.NamingRules
3232
/// within a <c>NativeMethods</c> class.</para>
3333
///
3434
/// <para>For namespace components that begin with a small letter, due to branding issues or other reasons, add the
35-
/// term to the <c>allowedNamespaceComponentTerms</c> list.</para>
35+
/// term to the <c>allowedNamespaceComponents</c> list.</para>
3636
/// </remarks>
3737
[DiagnosticAnalyzer(LanguageNames.CSharp)]
3838
internal class SA1300ElementMustBeginWithUpperCaseLetter : DiagnosticAnalyzer
@@ -89,10 +89,10 @@ public override void Initialize(AnalysisContext context)
8989
private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings)
9090
{
9191
NameSyntax nameSyntax = ((NamespaceDeclarationSyntax)context.Node).Name;
92-
CheckNameSyntax(context, nameSyntax, settings);
92+
CheckNamespaceNameSyntax(context, nameSyntax, settings);
9393
}
9494

95-
private static void CheckNameSyntax(SyntaxNodeAnalysisContext context, NameSyntax nameSyntax, StyleCopSettings settings)
95+
private static void CheckNamespaceNameSyntax(SyntaxNodeAnalysisContext context, NameSyntax nameSyntax, StyleCopSettings settings)
9696
{
9797
if (nameSyntax == null || nameSyntax.IsMissing)
9898
{
@@ -101,13 +101,13 @@ private static void CheckNameSyntax(SyntaxNodeAnalysisContext context, NameSynta
101101

102102
if (nameSyntax is QualifiedNameSyntax qualifiedNameSyntax)
103103
{
104-
CheckNameSyntax(context, qualifiedNameSyntax.Left, settings);
105-
CheckNameSyntax(context, qualifiedNameSyntax.Right, settings);
104+
CheckNamespaceNameSyntax(context, qualifiedNameSyntax.Left, settings);
105+
CheckNamespaceNameSyntax(context, qualifiedNameSyntax.Right, settings);
106106
return;
107107
}
108108

109109
if (nameSyntax is SimpleNameSyntax simpleNameSyntax &&
110-
!settings.NamingRules.AllowedNamespaceComponentTerms.Contains(simpleNameSyntax.Identifier.ValueText))
110+
!settings.NamingRules.AllowedNamespaceComponents.Contains(simpleNameSyntax.Identifier.ValueText))
111111
{
112112
CheckElementNameToken(context, simpleNameSyntax.Identifier);
113113
return;

StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/NamingSettings.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ internal class NamingSettings
1717
private readonly ImmutableArray<string>.Builder allowedHungarianPrefixes;
1818

1919
/// <summary>
20-
/// This is the backing field for the <see cref="AllowedNamespaceComponentTerms"/> property.
20+
/// This is the backing field for the <see cref="AllowedNamespaceComponents"/> property.
2121
/// </summary>
22-
private readonly ImmutableArray<string>.Builder allowedNamespaceComponentTerms;
22+
private readonly ImmutableArray<string>.Builder allowedNamespaceComponents;
2323

2424
/// <summary>
2525
/// Initializes a new instance of the <see cref="NamingSettings"/> class.
@@ -28,7 +28,7 @@ protected internal NamingSettings()
2828
{
2929
this.AllowCommonHungarianPrefixes = true;
3030
this.allowedHungarianPrefixes = ImmutableArray.CreateBuilder<string>();
31-
this.allowedNamespaceComponentTerms = ImmutableArray.CreateBuilder<string>();
31+
this.allowedNamespaceComponents = ImmutableArray.CreateBuilder<string>();
3232

3333
this.IncludeInferredTupleElementNames = false;
3434
this.TupleElementNameCasing = TupleElementNameCase.CamelCase;
@@ -65,9 +65,9 @@ protected internal NamingSettings(JsonObject namingSettingsObject)
6565

6666
break;
6767

68-
case "allowedNamespaceComponentTerms":
68+
case "allowedNamespaceComponents":
6969
kvp.AssertIsArray();
70-
this.allowedNamespaceComponentTerms.AddRange(kvp.Value.AsJsonArray.Select(x => x.ToStringValue(kvp.Key)));
70+
this.allowedNamespaceComponents.AddRange(kvp.Value.AsJsonArray.Select(x => x.ToStringValue(kvp.Key)));
7171
break;
7272

7373
case "includeInferredTupleElementNames":
@@ -89,8 +89,8 @@ protected internal NamingSettings(JsonObject namingSettingsObject)
8989
public ImmutableArray<string> AllowedHungarianPrefixes
9090
=> this.allowedHungarianPrefixes.ToImmutable();
9191

92-
public ImmutableArray<string> AllowedNamespaceComponentTerms
93-
=> this.allowedNamespaceComponentTerms.ToImmutable();
92+
public ImmutableArray<string> AllowedNamespaceComponents
93+
=> this.allowedNamespaceComponents.ToImmutable();
9494

9595
public bool IncludeInferredTupleElementNames { get; }
9696

StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@
128128
"uniqueItems": true
129129
}
130130
},
131-
"allowedNamespaceComponentTerms": {
131+
"allowedNamespaceComponents": {
132132
"type": "array",
133-
"description": "Allowed namespace component terms, such as ones beginning with a lowercase letter.",
133+
"description": "Allowed namespace components, such as ones beginning with a lowercase letter.",
134134
"default": [],
135135
"items": {
136136
"type": "string",

documentation/Configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ The following property is used to configure allowable namespace component terms
320320

321321
| Property | Default Value | Minimum Version | Summary |
322322
| --- | --- | --- | --- |
323-
| `allowedNamespaceComponentTerms` | `[ ]` | 1.2.0 | Specifies namespace component terms that are allowed to be used. See the example below for more information. |
323+
| `allowedNamespaceComponents` | `[ ]` | 1.2.0 | Specifies namespace component terms that are allowed to be used. See the example below for more information. |
324324

325325
The following example shows a settings file which allows namespaces such as `eBay` or `Apple.iPod`.
326326

327327
```json
328328
{
329329
"settings": {
330330
"namingRules": {
331-
"allowedNamespaceComponentTerms": [
331+
"allowedNamespaceComponents": [
332332
"eBay",
333333
"iPod"
334334
]

documentation/SA1300.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class is any class which contains a name ending in `NativeMethods`, and is inten
4343
wrappers. StyleCop will ignore this violation if the item is placed within a `NativeMethods` class.
4444

4545
For namespace components that begin with a small letter, due to branding issues or other reasons, add the appropriate
46-
term to the `allowedNamespaceComponentTerms` list.
46+
term to the `allowedNamespaceComponents` list.
4747

4848
## How to fix violations
4949

5050
To fix a violation of this rule, change the name of the element so that it begins with an upper-case letter, place
51-
the item within a `NativeMethods` class if appropriate, or add it to the `allowedNamespaceComponentTerms` list if
51+
the item within a `NativeMethods` class if appropriate, or add it to the `allowedNamespaceComponents` list if
5252
it is a namespace component.
5353

5454
## How to suppress violations

0 commit comments

Comments
 (0)