Skip to content

Commit b99aa13

Browse files
authored
Merge pull request #4399 from Hosch250/issue753
Module without folder annotation
2 parents 935944b + 7b23f19 commit b99aa13

File tree

13 files changed

+138
-4
lines changed

13 files changed

+138
-4
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Rubberduck.Inspections.Abstract;
4+
using Rubberduck.Inspections.Results;
5+
using Rubberduck.Parsing.Inspections.Abstract;
6+
using Rubberduck.Resources.Inspections;
7+
using Rubberduck.Parsing.VBA;
8+
using Rubberduck.Parsing.Annotations;
9+
10+
namespace Rubberduck.Inspections.Concrete
11+
{
12+
public sealed class ModuleWithoutFolderInspection : InspectionBase
13+
{
14+
public ModuleWithoutFolderInspection(RubberduckParserState state)
15+
: base(state)
16+
{
17+
}
18+
19+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
20+
{
21+
var modulesWithoutFolderAnnotation = State.DeclarationFinder.UserDeclarations(Parsing.Symbols.DeclarationType.Module)
22+
.Where(w => w.Annotations.All(a => a.AnnotationType != AnnotationType.Folder))
23+
.ToList();
24+
25+
return modulesWithoutFolderAnnotation.Select(declaration =>
26+
new DeclarationInspectionResult(this, string.Format(InspectionResults.ModuleWithoutFolderInspection, declaration.IdentifierName), declaration));
27+
}
28+
}
29+
}

Rubberduck.CodeAnalysis/Rubberduck.CodeAnalysis.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<Compile Include="Inspections\Concrete\EmptyForEachBlockInspection.cs" />
8282
<Compile Include="Inspections\Concrete\EmptyForLoopBlockInspection.cs" />
8383
<Compile Include="Inspections\Concrete\BooleanAssignedInIfElseInspection.cs" />
84+
<Compile Include="Inspections\Concrete\ModuleWithoutFolderInspection.cs" />
8485
<Compile Include="Inspections\Concrete\EmptyWhileWendBlockInspection.cs" />
8586
<Compile Include="Inspections\Concrete\ObsoleteCallingConventionInspection.cs" />
8687
<Compile Include="Inspections\Concrete\ObsoleteErrorSyntaxInspection.cs" />

Rubberduck.Core/Properties/Settings.Designer.cs

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Core/Properties/Settings.settings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@
279279
&lt;CodeInspection Name="ObsoleteMemberUsageInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /&gt;
280280
&lt;CodeInspection Name="ObsoleteCallingConventionInspection" Severity="Warning" InspectionType="CodeQualityIssues" /&gt;
281281
&lt;CodeInspection Name="DuplicatedAnnotationInspection" Severity="Error" InspectionType="RubberduckOpportunities" /&gt;
282+
&lt;CodeInspection Name="ModuleWithoutFolderInspection" Severity="Suggestion" InspectionType="RubberduckOpportunities" /&gt;
282283
&lt;/CodeInspections&gt;
283284
&lt;WhitelistedIdentifiers /&gt;
284285
&lt;RunInspectionsOnSuccessfulParse&gt;true&lt;/RunInspectionsOnSuccessfulParse&gt;

Rubberduck.Core/app.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@
402402
InspectionType="CodeQualityIssues" />
403403
<CodeInspection Name="DuplicatedAnnotationInspection" Severity="Error"
404404
InspectionType="RubberduckOpportunities" />
405+
<CodeInspection Name="ModuleWithoutFolderInspection" Severity="Suggestion"
406+
InspectionType="RubberduckOpportunities" />
405407
</CodeInspections>
406408
<WhitelistedIdentifiers />
407409
<RunInspectionsOnSuccessfulParse>true</RunInspectionsOnSuccessfulParse>

Rubberduck.Resources/Inspections/InspectionInfo.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/Inspections/InspectionInfo.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,7 @@ If the parameter can be null, ignore this inspection result; passing a null valu
334334
<data name="DuplicatedAnnotationInspection" xml:space="preserve">
335335
<value>An annotation is specified multiple times, but is intended to be specified only once.</value>
336336
</data>
337+
<data name="ModuleWithoutFolderInspection" xml:space="preserve">
338+
<value>Modules without the '@Folder' annotation cannot receive custom groupings in the Code Explorer. </value>
339+
</data>
337340
</root>

Rubberduck.Resources/Inspections/InspectionNames.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/Inspections/InspectionNames.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,7 @@
333333
<data name="DuplicatedAnnotationInspection" xml:space="preserve">
334334
<value>Annotation is duplicated</value>
335335
</data>
336+
<data name="ModuleWithoutFolderInspection" xml:space="preserve">
337+
<value>Module without '@Folder' annotation</value>
338+
</data>
336339
</root>

Rubberduck.Resources/Inspections/InspectionResults.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)