Skip to content

Commit e4ebaca

Browse files
committed
restricted SelfAssignedDeclarationInspection to non-ValueType variables with a specified type
1 parent d30906f commit e4ebaca

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

RetailCoder.VBE/Inspections/SelfAssignedDeclarationInspection.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.Linq;
3+
using Rubberduck.Parsing.Grammar;
34
using Rubberduck.Parsing.VBA;
45
using Rubberduck.Parsing.Symbols;
56

@@ -16,10 +17,27 @@ public SelfAssignedDeclarationInspection(RubberduckParserState state)
1617
public override string Description { get { return InspectionsUI.SelfAssignedDeclarationInspectionResultFormat; } }
1718
public override CodeInspectionType InspectionType { get { return CodeInspectionType.CodeQualityIssues; } }
1819

20+
private static readonly IEnumerable<string> ValueTypes = new[]
21+
{
22+
Tokens.Boolean,
23+
Tokens.Byte,
24+
Tokens.Currency,
25+
Tokens.Date,
26+
Tokens.Decimal,
27+
Tokens.Double,
28+
Tokens.Integer,
29+
Tokens.Long,
30+
Tokens.LongLong,
31+
Tokens.Single,
32+
Tokens.String
33+
};
34+
1935
public override IEnumerable<InspectionResultBase> GetInspectionResults()
2036
{
2137
return UserDeclarations
2238
.Where(declaration => declaration.IsSelfAssigned
39+
&& declaration.IsTypeSpecified()
40+
&& !ValueTypes.Contains(declaration.AsTypeName)
2341
&& declaration.DeclarationType == DeclarationType.Variable
2442
&& declaration.ParentScope == declaration.QualifiedName.QualifiedModuleName.ToString()
2543
&& declaration.ParentDeclaration != null

0 commit comments

Comments
 (0)