Skip to content

Commit ae1a780

Browse files
authored
Merge pull request #2576 from retailcoder/next
inspection fixes
2 parents 693b349 + 459e7f4 commit ae1a780

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-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/ProcedureNotUsedInspection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
4141
var handlers = State.DeclarationFinder.UserDeclarations(DeclarationType.Control)
4242
.SelectMany(control => declarations.FindEventHandlers(control)).ToList();
4343

44+
var builtInHandlers = State.AllDeclarations.FindBuiltInEventHandlers();
45+
handlers.AddRange(builtInHandlers);
46+
4447
var withEventFields = State.DeclarationFinder.UserDeclarations(DeclarationType.Variable).Where(item => item.IsWithEvents).ToList();
4548
var withHanders = withEventFields
4649
.SelectMany(field => State.DeclarationFinder.FindHandlersForWithEventsField(field))

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)