Skip to content

Commit

Permalink
Rubberduck.Inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
IvenBach committed Nov 27, 2017
1 parent 26d3dfb commit 499ad93
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Rubberduck.Inspections/Inspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Inspector : IInspector

private readonly IGeneralConfigService _configService;
private readonly List<IInspection> _inspections;
private readonly int AGGREGATION_THRESHOLD = 128;
private const int AGGREGATION_THRESHOLD = 128;

public Inspector(IGeneralConfigService configService, IEnumerable<IInspection> inspections)
{
Expand Down
6 changes: 4 additions & 2 deletions Rubberduck.Inspections/QuickFixProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public IEnumerable<IQuickFix> QuickFixes(IInspectionResult result)

return _quickFixes[result.Inspection.GetType()].Where(fix =>
{
string value;
if (!result.Properties.TryGetValue("DisableFixes", out value)) { return true; }
if (!result.Properties.TryGetValue("DisableFixes", out var value))
{
return true;
}
return !value.Split(',').Contains(fix.GetType().Name);
})
Expand Down
30 changes: 24 additions & 6 deletions Rubberduck.Inspections/VariableRequiresSetAssignmentEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ public static IEnumerable<Declaration> GetDeclarationsPotentiallyRequiringSetAss
public static bool RequiresSetAssignment(IdentifierReference reference, RubberduckParserState state)
{
//Not an assignment...definitely does not require a 'Set' assignment
if (!reference.IsAssignment) { return false; }
if (!reference.IsAssignment)
{
return false;
}

//We know for sure it DOES NOT use 'Set'
if (!MayRequireAssignmentUsingSet(reference.Declaration)) { return false; }
if (!MayRequireAssignmentUsingSet(reference.Declaration))
{
return false;
}

//We know for sure that it DOES use 'Set'
if (RequiresAssignmentUsingSet(reference.Declaration)) { return true; }
if (RequiresAssignmentUsingSet(reference.Declaration))
{
return true;
}

//We need to look everything to understand the RHS - the assigned reference is probably a Variant
var allInterestingDeclarations = GetDeclarationsPotentiallyRequiringSetAssignment(state.AllUserDeclarations);
Expand All @@ -38,11 +47,20 @@ public static bool RequiresSetAssignment(IdentifierReference reference, Rubberdu

private static bool MayRequireAssignmentUsingSet(Declaration declaration)
{
if (declaration.DeclarationType == DeclarationType.PropertyLet) { return false; }
if (declaration.DeclarationType == DeclarationType.PropertyLet)
{
return false;
}

if (declaration.AsTypeName == Tokens.Variant) { return true; }
if (declaration.AsTypeName == Tokens.Variant)
{
return true;
}

if (declaration.IsArray) { return false; }
if (declaration.IsArray)
{
return false;
}

if (declaration.AsTypeDeclaration != null)
{
Expand Down

0 comments on commit 499ad93

Please sign in to comment.