Skip to content

Commit 6a23b64

Browse files
committed
Merge branch 'next' into CacheUserComProjects
2 parents 61ba7dd + bdef13f commit 6a23b64

File tree

115 files changed

+7407
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+7407
-166
lines changed

Rubberduck.CodeAnalysis/Inspections/Abstract/IsMissingInspectionBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected IReadOnlyList<Declaration> IsMissingDeclarations
3131

3232
if (isMissing.Count == 0)
3333
{
34-
_logger.Trace("No 'IsMissing' Declarations were not found in IsMissingInspectionBase.");
34+
_logger.Trace("No 'IsMissing' Declarations were found in IsMissingInspectionBase.");
3535
}
3636

3737
return isMissing;

Rubberduck.CodeAnalysis/Inspections/Concrete/AssignedByValParameterInspection.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@
1010

1111
namespace Rubberduck.Inspections.Concrete
1212
{
13+
/// <summary>
14+
/// Warns about parameters passed by value being assigned a new value in the body of a procedure.
15+
/// </summary>
16+
/// <why>
17+
/// Debugging is easier if the procedure's initial state is preserved and accessible anywhere within its scope.
18+
/// Mutating the inputs destroys the initial state, and makes the intent ambiguous: if the calling code is meant
19+
/// to be able to access the modified values, then the parameter should be passed ByRef; the ByVal modifier might be a bug.
20+
/// </why>
21+
/// <example>
22+
/// <![CDATA[
23+
/// Public Sub DoSomething(ByVal foo As Long)
24+
/// foo = foo + 1 ' is the caller supposed to see the updated value?
25+
/// Debug.Print foo
26+
/// End Sub
27+
/// ]]>
28+
/// </example>
29+
/// <example>
30+
/// <![CDATA[
31+
/// Public Sub DoSomething(ByVal foo As Long)
32+
/// Dim bar As Long
33+
/// bar = foo
34+
/// bar = bar + 1 ' clearly a local copy of the original value.
35+
/// Debug.Print bar
36+
/// End Sub
37+
/// ]]>
38+
/// </example>
1339
public sealed class AssignedByValParameterInspection : InspectionBase
1440
{
1541
public AssignedByValParameterInspection(RubberduckParserState state)

Rubberduck.CodeAnalysis/Inspections/Concrete/AssignmentNotUsedInspection.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@
1212

1313
namespace Rubberduck.Inspections.Concrete
1414
{
15+
/// <summary>
16+
/// Warns about a variable that is assigned, and then re-assigned before the first assignment is read.
17+
/// </summary>
18+
/// <why>
19+
/// The first assignment is likely redundant, since it is being overwritten by the second.
20+
/// </why>
21+
/// <example>
22+
/// <![CDATA[
23+
/// Public Sub DoSomething()
24+
/// Dim foo As Long
25+
/// foo = 12 ' assignment is redundant
26+
/// foo = 34
27+
/// End Sub
28+
/// ]]>
29+
/// </example>
30+
/// <example>
31+
/// <![CDATA[
32+
/// Public Sub DoSomething(ByVal foo As Long)
33+
/// Dim bar As Long
34+
/// bar = 12
35+
/// bar = bar + foo ' variable is re-assigned, but the prior assigned value is read at least once first.
36+
/// End Sub
37+
/// ]]>
38+
/// </example>
1539
public sealed class AssignmentNotUsedInspection : InspectionBase
1640
{
1741
private readonly Walker _walker;

Rubberduck.CodeAnalysis/Inspections/Concrete/AttributeValueOutOfSyncInspection.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@
1313

1414
namespace Rubberduck.Inspections.Concrete
1515
{
16+
/// <summary>
17+
/// Indicates that the value of a hidden VB attribute is out of sync with the corresponding Rubberduck annotation comment.
18+
/// </summary>
19+
/// <why>
20+
/// Keeping Rubberduck annotation comments in sync with the hidden VB attribute values, surfaces these hidden attributes in the VBE code panes;
21+
/// Rubberduck can rewrite the attributes to match the corresponding annotation comment.
22+
/// </why>
23+
/// <example>
24+
/// <![CDATA[
25+
/// '@Description("foo")
26+
/// Public Sub DoSomething()
27+
/// Attribute VB_Description = "bar"
28+
/// ' ...
29+
/// End Sub
30+
/// ]]>
31+
/// </example>
32+
/// <example>
33+
/// <![CDATA[
34+
/// '@Description("foo")
35+
/// Public Sub DoSomething()
36+
/// Attribute VB_Description = "foo"
37+
/// ' ...
38+
/// End Sub
39+
/// ]]>
40+
/// </example>
1641
[CannotAnnotate]
1742
public sealed class AttributeValueOutOfSyncInspection : InspectionBase
1843
{

Rubberduck.CodeAnalysis/Inspections/Concrete/BooleanAssignedInIfElseInspection.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@
1313

1414
namespace Rubberduck.Inspections.Concrete
1515
{
16+
/// <summary>
17+
/// Identifies redundant Boolean expressions in conditionals.
18+
/// </summary>
19+
/// <why>
20+
/// A Boolean expression never needs to be compared to a Boolean literal in a conditional expression.
21+
/// </why>
22+
/// <example>
23+
/// <![CDATA[
24+
/// Public Sub DoSomething(ByVal foo As Boolean)
25+
/// If foo = True Then ' foo is known to already be a Boolean value.
26+
/// ' ...
27+
/// End If
28+
/// End Sub
29+
/// ]]>
30+
/// </example>
31+
/// <example>
32+
/// <![CDATA[
33+
/// Public Sub DoSomething(ByVal foo As Boolean)
34+
/// If foo Then
35+
/// ' ...
36+
/// End If
37+
/// End Sub
38+
/// ]]>
39+
/// </example>
1640
public sealed class BooleanAssignedInIfElseInspection : ParseTreeInspectionBase
1741
{
1842
public BooleanAssignedInIfElseInspection(RubberduckParserState state)

Rubberduck.CodeAnalysis/Inspections/Concrete/ConstantNotUsedInspection.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@
1313

1414
namespace Rubberduck.Inspections.Concrete
1515
{
16+
/// <summary>
17+
/// Locates 'Const' declarations that are never referenced.
18+
/// </summary>
19+
/// <why>
20+
/// Declarations that are never used should be removed.
21+
/// </why>
22+
/// <example>
23+
/// <![CDATA[
24+
/// Private Const foo As Long = 42
25+
///
26+
/// Public Sub DoSomething()
27+
/// ' no reference to 'foo' anywhere...
28+
/// End Sub
29+
/// ]]>
30+
/// </example>
31+
/// <example>
32+
/// <![CDATA[
33+
/// Private Const foo As Long = 42
34+
///
35+
/// Public Sub DoSomething()
36+
/// Debug.Print foo
37+
/// End Sub
38+
/// ]]>
39+
/// </example>
1640
public sealed class ConstantNotUsedInspection : InspectionBase
1741
{
1842
public ConstantNotUsedInspection(RubberduckParserState state)

Rubberduck.CodeAnalysis/Inspections/Concrete/DefTypeStatementInspection.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414

1515
namespace Rubberduck.Inspections.Concrete
1616
{
17+
/// <summary>
18+
/// Warns about Def[Type] statements.
19+
/// </summary>
20+
/// <why>
21+
/// These declarative statements make the first letter of identifiers determine the data type.
22+
/// </why>
23+
/// <example>
24+
/// <![CDATA[
25+
/// DefBool B
26+
/// DefDbl D
27+
///
28+
/// Public Sub DoSomething()
29+
/// Dim bar ' implicit Boolean
30+
/// ' ...
31+
/// End Sub
32+
/// ]]>
33+
/// </example>
1734
public sealed class DefTypeStatementInspection : ParseTreeInspectionBase
1835
{
1936
public DefTypeStatementInspection(RubberduckParserState state)

Rubberduck.CodeAnalysis/Inspections/Concrete/DefaultProjectNameInspection.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
namespace Rubberduck.Inspections.Concrete
1111
{
12+
/// <summary>
13+
/// This inspection means to indicate when the project has not been renamed.
14+
/// </summary>
15+
/// <why>
16+
/// VBA projects should be meaningfully named, to avoid namespace clashes when referencing other VBA projects.
17+
/// </why>
1218
[CannotAnnotate]
1319
public sealed class DefaultProjectNameInspection : InspectionBase
1420
{

Rubberduck.CodeAnalysis/Inspections/Concrete/DuplicatedAnnotationInspection.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@
88

99
namespace Rubberduck.Inspections.Concrete
1010
{
11+
/// <summary>
12+
/// Warns about duplicated annotations.
13+
/// </summary>
14+
/// <why>
15+
/// Rubberduck annotations should not be specified more than once for a given module, member, variable, or expression.
16+
/// </why>
17+
/// <example>
18+
/// <![CDATA[
19+
/// '@Folder("Bar")
20+
/// '@Folder("Foo")
21+
///
22+
/// Public Sub DoSomething()
23+
/// ' ...
24+
/// End Sub
25+
/// ]]>
26+
/// </example>
27+
/// <example>
28+
/// <![CDATA[
29+
/// '@Folder("Foo.Bar")
30+
///
31+
/// Public Sub DoSomething()
32+
/// ' ...
33+
/// End Sub
34+
/// ]]>
35+
/// </example>
1136
public sealed class DuplicatedAnnotationInspection : InspectionBase
1237
{
1338
public DuplicatedAnnotationInspection(RubberduckParserState state) : base(state)
@@ -27,12 +52,9 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2752
issues.AddRange(duplicateAnnotations.Select(duplicate =>
2853
{
2954
var result = new DeclarationInspectionResult(
30-
this,
31-
string.Format(InspectionResults.DuplicatedAnnotationInspection, duplicate.Key.ToString()),
32-
declaration);
55+
this, string.Format(InspectionResults.DuplicatedAnnotationInspection, duplicate.Key.ToString()), declaration);
3356

3457
result.Properties.AnnotationType = duplicate.Key;
35-
3658
return result;
3759
}));
3860
}

Rubberduck.CodeAnalysis/Inspections/Concrete/EmptyCaseBlockInspection.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@
1313

1414
namespace Rubberduck.Inspections.Concrete
1515
{
16+
/// <summary>
17+
/// Identifies empty 'Case' blocks that can be safely removed.
18+
/// </summary>
19+
/// <why>
20+
/// Case blocks in VBA do not "fall through"; an empty 'Case' block might be hiding a bug.
21+
/// </why>
22+
/// <example>
23+
/// <![CDATA[
24+
/// Public Sub DoSomething(ByVal foo As Long)
25+
/// Select Case foo
26+
/// Case 0 ' empty block
27+
/// Case Is > 0
28+
/// Debug.Print foo ' does not run if foo is 0.
29+
/// End Select
30+
/// End Sub
31+
/// ]]>
32+
/// </example>
33+
/// <example>
34+
/// <![CDATA[
35+
/// Public Sub DoSomething(ByVal foo As Long)
36+
/// Select Case foo
37+
/// Case 0
38+
/// '...code...
39+
/// Case Is > 0
40+
/// '...code...
41+
/// End Select
42+
/// End Sub
43+
/// ]]>
44+
/// </example>
1645
[Experimental(nameof(ExperimentalNames.EmptyBlockInspections))]
1746
internal class EmptyCaseBlockInspection : ParseTreeInspectionBase
1847
{

0 commit comments

Comments
 (0)