-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(): Add TooManyDependencies inspection to vb.net
- Loading branch information
Wolfgang Janz
committed
Sep 26, 2016
1 parent
3b7dc4d
commit 013ae17
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
CleanCode/src/CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckVb.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Linq; | ||
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; | ||
using JetBrains.ReSharper.Psi.Util; | ||
|
||
namespace CleanCode.Features.TooManyDependencies | ||
{ | ||
[ElementProblemAnalyzer(typeof(IConstructorDeclaration), HighlightingTypes = new [] | ||
{ | ||
typeof(TooManyDependenciesHighlighting) | ||
})] | ||
public class TooManyDependenciesCheckVb : ElementProblemAnalyzer<IConstructorDeclaration> | ||
{ | ||
protected override void Run(IConstructorDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) | ||
{ | ||
var maxDependencies = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumConstructorDependencies); | ||
|
||
var dependencies = element.ParameterDeclarations.Select( | ||
declaration => declaration.DeclaredElement != null && | ||
declaration.DeclaredElement.Type.IsInterfaceType()); | ||
|
||
var dependenciesCount = dependencies.Count(); | ||
if (dependenciesCount > maxDependencies) | ||
{ | ||
var highlighting = new TooManyDependenciesHighlighting(element.GetNameDocumentRange()); | ||
consumer.AddHighlighting(highlighting); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters