Skip to content

Commit ca8b310

Browse files
author
Wolfgang Janz
committed
feature(): Add MethodNameNotMeaningful inspection to vb.net
1 parent 4484a1e commit ca8b310

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

CleanCode/src/CleanCode/CleanCode.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
<Compile Include="Features\HollowNames\HollowNamesCheckVb.cs" />
177177
<Compile Include="Features\HollowNames\HollowTypeNameHighlighting.cs" />
178178
<Compile Include="Features\HollowNames\HollowNamesCheck.cs" />
179+
<Compile Include="Features\MethodNameNotMeaningful\MethodNameNotMeaningfulCheckVb.cs" />
179180
<Compile Include="Features\MethodNameNotMeaningful\MethodNameNotMeaningfulHighlighting.cs" />
180181
<Compile Include="Features\MethodNameNotMeaningful\MethodNameNotMeaningfulCheck.cs" />
181182
<Compile Include="Features\MethodTooLong\MethodTooLongCheckVb.cs" />
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using CleanCode.Settings;
2+
using JetBrains.Application.Settings;
3+
using JetBrains.ReSharper.Daemon.Stages.Dispatcher;
4+
using JetBrains.ReSharper.Feature.Services.Daemon;
5+
using JetBrains.ReSharper.Psi.VB.Tree;
6+
using JetBrains.ReSharper.Psi.Tree;
7+
8+
namespace CleanCode.Features.MethodNameNotMeaningful
9+
{
10+
[ElementProblemAnalyzer(typeof(IMethodDeclaration), HighlightingTypes = new []
11+
{
12+
typeof(MethodNameNotMeaningfulHighlighting)
13+
})]
14+
public class MethodNameNotMeaningfulCheckVb : ElementProblemAnalyzer<IMethodDeclaration>
15+
{
16+
protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
17+
{
18+
if (element.Name == null)
19+
return;
20+
21+
var minimumMethodNameLength = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MinimumMeaningfulMethodNameLength);
22+
23+
var name = element.Name.GetText();
24+
var methodNameLength = name.Length;
25+
if (methodNameLength < minimumMethodNameLength)
26+
{
27+
var documentRange = element.GetNameDocumentRange();
28+
var highlighting = new MethodNameNotMeaningfulHighlighting(documentRange);
29+
consumer.AddHighlighting(highlighting);
30+
}
31+
}
32+
}
33+
}

CleanCode/src/CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulHighlighting.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using JetBrains.DocumentModel;
55
using JetBrains.ReSharper.Feature.Services.Daemon;
66
using JetBrains.ReSharper.Psi.CSharp;
7+
using JetBrains.ReSharper.Psi.VB;
78

89
[assembly: RegisterConfigurableSeverity(MethodNameNotMeaningfulHighlighting.SeverityID, null,
910
CleanCodeHighlightingGroupIds.CleanCode, "Method name not meaningful",
@@ -12,7 +13,7 @@
1213

1314
namespace CleanCode.Features.MethodNameNotMeaningful
1415
{
15-
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name)]
16+
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
1617
public class MethodNameNotMeaningfulHighlighting : IHighlighting
1718
{
1819
internal const string SeverityID = "MethodNameNotMeaningful";

0 commit comments

Comments
 (0)