Skip to content

Commit 6ac2b02

Browse files
committed
fixes #2446
1 parent e5eb310 commit 6ac2b02

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

RetailCoder.VBE/Inspections/EncapsulatePublicFieldInspection.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ public EncapsulatePublicFieldInspection(RubberduckParserState state, IIndenter i
2626

2727
public override IEnumerable<InspectionResultBase> GetInspectionResults()
2828
{
29+
// we're creating a public field for every control on a form, needs to be ignored.
30+
var msForms = State.DeclarationFinder.FindProject("MSForms");
31+
Declaration control = null;
32+
if (msForms != null)
33+
{
34+
control = State.DeclarationFinder.FindClassModule("Control", msForms, true);
35+
}
36+
2937
var fields = State.DeclarationFinder.UserDeclarations(DeclarationType.Variable)
3038
.Where(item => !IsIgnoringInspectionResultFor(item, AnnotationName)
31-
&& item.Accessibility == Accessibility.Public)
39+
&& item.Accessibility == Accessibility.Public
40+
&& (control == null || !Equals(item.AsTypeDeclaration, control)))
3241
.ToList();
3342

3443
return fields

RetailCoder.VBE/Inspections/UseMeaningfulNameInspection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using Castle.Core.Internal;
45
using Rubberduck.Common;
56
using Rubberduck.Inspections.Abstract;
67
using Rubberduck.Inspections.Resources;
@@ -44,7 +45,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
4445
var handlers = Declarations.FindBuiltInEventHandlers();
4546

4647
var issues = UserDeclarations
47-
.Where(declaration =>
48+
.Where(declaration => !string.IsNullOrEmpty(declaration.IdentifierName) &&
4849
!IgnoreDeclarationTypes.Contains(declaration.DeclarationType) &&
4950
(declaration.ParentDeclaration == null ||
5051
!IgnoreDeclarationTypes.Contains(declaration.ParentDeclaration.DeclarationType) &&

Rubberduck.Parsing/Symbols/SquareBracketedNameComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public int GetHashCode(string obj)
2424

2525
private string ApplyBrackets(string value)
2626
{
27-
if (value == null) return null;
27+
if (string.IsNullOrEmpty(value)) return string.Empty;
2828

2929
return value[0] == '[' && value[value.Length - 1] == ']'
3030
? value

0 commit comments

Comments
 (0)