Skip to content

Commit e445640

Browse files
committed
fixed broken tests
1 parent 047ddf0 commit e445640

9 files changed

+59
-25
lines changed

Rubberduck.Inspections/Concrete/MultilineParameterInspection.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ namespace Rubberduck.Inspections.Concrete
1717
public sealed class MultilineParameterInspection : ParseTreeInspectionBase
1818
{
1919
public MultilineParameterInspection(RubberduckParserState state)
20-
: base(state, CodeInspectionSeverity.Suggestion) { }
20+
: base(state, CodeInspectionSeverity.Suggestion)
21+
{
22+
Listener = new ParameterListener();
23+
}
2124

2225
public override CodeInspectionType InspectionType => CodeInspectionType.MaintainabilityAndReadabilityIssues;
2326

24-
public override IInspectionListener Listener => new ParameterListener();
27+
public override IInspectionListener Listener { get; }
2528

2629
public override IEnumerable<IInspectionResult> GetInspectionResults()
2730
{
@@ -37,7 +40,9 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
3740

3841
public class ParameterListener : VBAParserBaseListener, IInspectionListener
3942
{
40-
private readonly List<QualifiedContext<ParserRuleContext>> _contexts = new List<QualifiedContext<ParserRuleContext>>();
43+
private readonly List<QualifiedContext<ParserRuleContext>> _contexts
44+
= new List<QualifiedContext<ParserRuleContext>>();
45+
4146
public IReadOnlyList<QualifiedContext<ParserRuleContext>> Contexts => _contexts;
4247

4348
public QualifiedModuleName CurrentModuleName { get; set; }

Rubberduck.Inspections/Concrete/ObsoleteCallStatementInspection.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ namespace Rubberduck.Inspections.Concrete
1515
public sealed class ObsoleteCallStatementInspection : ParseTreeInspectionBase
1616
{
1717
public ObsoleteCallStatementInspection(RubberduckParserState state)
18-
: base(state, CodeInspectionSeverity.Suggestion) { }
18+
: base(state, CodeInspectionSeverity.Suggestion)
19+
{
20+
Listener = new ObsoleteCallStatementListener();
21+
}
1922

2023
public override CodeInspectionType InspectionType => CodeInspectionType.LanguageOpportunities;
21-
public override IInspectionListener Listener => new ObsoleteCallStatementListener();
24+
public override IInspectionListener Listener { get; }
2225

2326
public override IEnumerable<IInspectionResult> GetInspectionResults()
2427
{

Rubberduck.Inspections/Concrete/ObsoleteCommentSyntaxInspection.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ namespace Rubberduck.Inspections.Concrete
1414
{
1515
public sealed class ObsoleteCommentSyntaxInspection : ParseTreeInspectionBase
1616
{
17-
public ObsoleteCommentSyntaxInspection(RubberduckParserState state) : base(state, CodeInspectionSeverity.Suggestion) { }
17+
public ObsoleteCommentSyntaxInspection(RubberduckParserState state)
18+
: base(state, CodeInspectionSeverity.Suggestion)
19+
{
20+
Listener = new ObsoleteCommentSyntaxListener();
21+
}
1822

1923
public override CodeInspectionType InspectionType => CodeInspectionType.LanguageOpportunities;
20-
public override IInspectionListener Listener => new ObsoleteCommentSyntaxListener();
24+
public override IInspectionListener Listener { get; }
2125

2226
public override IEnumerable<IInspectionResult> GetInspectionResults()
2327
{

Rubberduck.Inspections/Concrete/ObsoleteLetStatementInspection.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ namespace Rubberduck.Inspections.Concrete
1515
public sealed class ObsoleteLetStatementInspection : ParseTreeInspectionBase
1616
{
1717
public ObsoleteLetStatementInspection(RubberduckParserState state)
18-
: base(state, CodeInspectionSeverity.Suggestion) { }
18+
: base(state, CodeInspectionSeverity.Suggestion)
19+
{
20+
Listener = new ObsoleteLetStatementListener();
21+
}
1922

2023
public override CodeInspectionType InspectionType => CodeInspectionType.LanguageOpportunities;
21-
public override IInspectionListener Listener => new ObsoleteLetStatementListener();
24+
public override IInspectionListener Listener { get; }
2225

2326
public override IEnumerable<IInspectionResult> GetInspectionResults()
2427
{

Rubberduck.Inspections/Concrete/OptionBaseInspection.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ namespace Rubberduck.Inspections.Concrete
1515
public sealed class OptionBaseInspection : ParseTreeInspectionBase
1616
{
1717
public OptionBaseInspection(RubberduckParserState state)
18-
: base(state, CodeInspectionSeverity.Hint) { }
18+
: base(state, CodeInspectionSeverity.Hint)
19+
{
20+
Listener = new OptionBaseStatementListener();
21+
}
1922

2023
public override CodeInspectionType InspectionType => CodeInspectionType.MaintainabilityAndReadabilityIssues;
21-
public override IInspectionListener Listener => new OptionBaseStatementListener();
24+
public override IInspectionListener Listener { get; }
2225

2326
public override IEnumerable<IInspectionResult> GetInspectionResults()
2427
{

Rubberduck.Inspections/Concrete/OptionExplicitInspection.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ namespace Rubberduck.Inspections.Concrete
1616
public sealed class OptionExplicitInspection : ParseTreeInspectionBase
1717
{
1818
public OptionExplicitInspection(RubberduckParserState state)
19-
: base(state, CodeInspectionSeverity.Error) { }
19+
: base(state, CodeInspectionSeverity.Error)
20+
{
21+
Listener = new MissingOptionExplicitListener();
22+
}
2023

2124
public override CodeInspectionType InspectionType => CodeInspectionType.CodeQualityIssues;
2225

23-
public override IInspectionListener Listener => new MissingOptionExplicitListener();
26+
public override IInspectionListener Listener { get; }
2427

2528
public override IEnumerable<IInspectionResult> GetInspectionResults()
2629
{

Rubberduck.Inspections/Concrete/ProcedureCanBeWrittenAsFunctionInspection.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ public sealed class ProcedureCanBeWrittenAsFunctionInspection : ParseTreeInspect
2020
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2121

2222
public ProcedureCanBeWrittenAsFunctionInspection(RubberduckParserState state)
23-
: base(state, CodeInspectionSeverity.Suggestion) { }
23+
: base(state, CodeInspectionSeverity.Suggestion)
24+
{
25+
Listener = new SingleByRefParamArgListListener();
26+
}
2427

2528
public override CodeInspectionType InspectionType => CodeInspectionType.LanguageOpportunities;
26-
public override IInspectionListener Listener => new SingleByRefParamArgListListener();
29+
public override IInspectionListener Listener { get; }
2730

2831
public override IEnumerable<IInspectionResult> GetInspectionResults()
2932
{

Rubberduck.Inspections/Concrete/RedundantOptionInspection.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ namespace Rubberduck.Inspections.Concrete
1515
public sealed class RedundantOptionInspection : ParseTreeInspectionBase
1616
{
1717
public RedundantOptionInspection(RubberduckParserState state)
18-
: base(state, CodeInspectionSeverity.Hint) { }
18+
: base(state, CodeInspectionSeverity.Hint)
19+
{
20+
Listener = new RedundantModuleOptionListener();
21+
}
1922

2023
public override string Meta => InspectionsUI.RedundantOptionInspectionMeta;
2124
public override string Description => InspectionsUI.RedundantOptionInspectionName;
2225
public override CodeInspectionType InspectionType => CodeInspectionType.LanguageOpportunities;
2326

24-
public override IInspectionListener Listener => new RedundantModuleOptionListener();
27+
public override IInspectionListener Listener { get; }
2528

2629
public override IEnumerable<IInspectionResult> GetInspectionResults()
2730
{

Rubberduck.Inspections/Inspector.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,21 @@ public async Task<IEnumerable<IInspectionResult>> FindIssuesAsync(RubberduckPars
6161
}
6262

6363
state.OnStatusMessageUpdate(RubberduckUI.CodeInspections_Inspecting);
64+
var allIssues = new ConcurrentBag<IInspectionResult>();
6465

6566
var config = _configService.LoadConfiguration();
6667
UpdateInspectionSeverity(config);
6768

68-
var allIssues = new ConcurrentBag<IInspectionResult>();
69-
70-
var parseTreeInspections = _inspections.OfType<IParseTreeInspection>().ToArray();
69+
var parseTreeInspections = _inspections
70+
.Where(inspection => inspection.Severity != CodeInspectionSeverity.DoNotShow)
71+
.OfType<IParseTreeInspection>()
72+
.ToArray();
7173

74+
foreach(var listener in parseTreeInspections.Select(inspection => inspection.Listener))
75+
{
76+
listener.ClearContexts();
77+
}
78+
7279
// Prepare ParseTreeWalker based inspections
7380
var passes = Enum.GetValues(typeof (ParsePass)).Cast<ParsePass>();
7481
foreach (var parsePass in passes)
@@ -133,6 +140,11 @@ private void WalkTrees(CodeInspectionSettings settings, RubberduckParserState st
133140
.Select(inspection => inspection.Listener)
134141
.ToList();
135142

143+
if (!listeners.Any())
144+
{
145+
return;
146+
}
147+
136148
List<KeyValuePair<QualifiedModuleName, IParseTree>> trees;
137149
switch (pass)
138150
{
@@ -146,11 +158,6 @@ private void WalkTrees(CodeInspectionSettings settings, RubberduckParserState st
146158
throw new ArgumentOutOfRangeException(nameof(pass), pass, null);
147159
}
148160

149-
foreach (var listener in listeners)
150-
{
151-
listener.ClearContexts();
152-
}
153-
154161
foreach (var componentTreePair in trees)
155162
{
156163
foreach (var listener in listeners)

0 commit comments

Comments
 (0)