Skip to content

Commit

Permalink
feature(): Add ClassTooBig inspection to vb.net
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfgang Janz committed Sep 22, 2016
1 parent 5d76318 commit 3b7dc4d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions CleanCode/src/CleanCode/CleanCode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<Compile Include="CleanCodeHighlightingGroupIds.cs" />
<Compile Include="Features\ChainedReferences\MaximumChainedReferencesHighlighting.cs" />
<Compile Include="Features\ChainedReferences\ChainedReferencesCheck.cs" />
<Compile Include="Features\ClassTooBig\ClassTooBigCheckVb.cs" />
<Compile Include="Features\ClassTooBig\ClassTooBigHighlighting.cs" />
<Compile Include="Features\ExcessiveIndentation\ExcessiveIndentationCheck.cs" />
<Compile Include="Features\ComplexExpression\ComplexConditionExpressionHighlighting.cs" />
Expand Down
31 changes: 31 additions & 0 deletions CleanCode/src/CleanCode/Features/ClassTooBig/ClassTooBigCheckVb.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using CleanCode.Resources;
using CleanCode.Settings;
using JetBrains.Application.Settings;
using JetBrains.ReSharper.Daemon.Stages.Dispatcher;
using JetBrains.ReSharper.Feature.Services.Daemon;
using JetBrains.ReSharper.Psi.VB.Tree;
using JetBrains.ReSharper.Psi.Tree;

namespace CleanCode.Features.ClassTooBig
{
[ElementProblemAnalyzer(typeof(IClassDeclaration), HighlightingTypes = new []
{
typeof(ClassTooBigHighlighting)
})]
public class ClassTooBigCheckVb : ElementProblemAnalyzer<IClassDeclaration>
{
protected override void Run(IClassDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
{
var maxLength = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumMethodsInClass);

var statementCount = element.CountChildren<IMethodDeclaration>();
if (statementCount > maxLength)
{
var declarationIdentifier = element.Name;
var documentRange = declarationIdentifier.GetDocumentRange();
var highlighting = new ClassTooBigHighlighting(Warnings.ClassTooBig, documentRange);
consumer.AddHighlighting(highlighting);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
using JetBrains.DocumentModel;
using JetBrains.ReSharper.Feature.Services.Daemon;
using JetBrains.ReSharper.Psi.CSharp;
using JetBrains.ReSharper.Psi.VB;

[assembly: RegisterConfigurableSeverity(ClassTooBigHighlighting.SeverityID, null,
CleanCodeHighlightingGroupIds.CleanCode, "Class too big", "This class contains too many methods",
Severity.SUGGESTION, false)]

namespace CleanCode.Features.ClassTooBig
{
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name)]
{
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class ClassTooBigHighlighting : IHighlighting
{
internal const string SeverityID = "ClassTooBig";
Expand Down

0 comments on commit 3b7dc4d

Please sign in to comment.