Skip to content

Commit ac2e8be

Browse files
committed
Settings for experimental inspections will not be displayed
1 parent b4926c7 commit ac2e8be

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

RetailCoder.VBE/Settings/CodeInspectionConfigProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public CodeInspectionConfigProvider(IPersistanceService<CodeInspectionSettings>
1717
_persister = persister;
1818
_foundInspectionNames = inspectionProvider.Inspections.Select(inspection => inspection.Name).ToHashSet();
1919
_defaultSettings = new DefaultSettings<CodeInspectionSettings>().Default;
20+
// Ignore settings for unknown inpections, for example when using the Experimental attribute
21+
_defaultSettings.CodeInspections = _defaultSettings.CodeInspections.Where(setting => _foundInspectionNames.Contains(setting.Name)).ToHashSet();
2022

2123
var defaultNames = _defaultSettings.CodeInspections.Select(x => x.Name);
2224
var nonDefaultInspections = inspectionProvider.Inspections.Where(inspection => !defaultNames.Contains(inspection.Name));

RubberduckTests/Settings/CodeInspectionConfigProviderTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ public void UserSettingsAreCombinedWithDefaultSettings()
6060
[Test]
6161
public void UserSettingsAreNotDuplicatedWithDefaultSettings()
6262
{
63+
var inspectionMock = new Mock<IInspection>();
64+
inspectionMock.Setup(inspection => inspection.Name).Returns("Foo");
6365
var inspectionProviderMock = new Mock<IInspectionProvider>();
64-
inspectionProviderMock.Setup(provider => provider.Inspections).Returns(Enumerable.Empty<IInspection>());
65-
66-
var defaultSettings = new CodeInspectionConfigProvider(null, inspectionProviderMock.Object).CreateDefaults().CodeInspections;
67-
var defaultSetting = defaultSettings.First();
66+
inspectionProviderMock.Setup(provider => provider.Inspections).Returns(new[] { inspectionMock.Object });
6867

69-
var userSetting = new CodeInspectionSetting(defaultSetting.Name, defaultSetting.InspectionType);
68+
var userSetting = new CodeInspectionSetting(inspectionMock.Object.Name, inspectionMock.Object.InspectionType);
7069
var userSettings = new CodeInspectionSettings
7170
{
7271
CodeInspections = new HashSet<CodeInspectionSetting>(new[] { userSetting })
@@ -76,11 +75,9 @@ public void UserSettingsAreNotDuplicatedWithDefaultSettings()
7675
persisterMock.Setup(persister => persister.Load(It.IsAny<CodeInspectionSettings>())).Returns(userSettings);
7776

7877
var configProvider = new CodeInspectionConfigProvider(persisterMock.Object, inspectionProviderMock.Object);
79-
8078
var settings = configProvider.Create().CodeInspections;
8179

82-
Assert.AreEqual(defaultSettings.Count, settings.Count);
83-
Assert.Contains(userSetting, settings.ToArray());
80+
Assert.AreEqual(configProvider.CreateDefaults().CodeInspections.Count, settings.Count);
8481
}
8582

8683

0 commit comments

Comments
 (0)