diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644
index 0000000..96b59af
--- /dev/null
+++ b/.config/dotnet-tools.json
@@ -0,0 +1,12 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "csharpier": {
+ "version": "1.0.1",
+ "commands": [
+ "csharpier"
+ ]
+ }
+ }
+}
diff --git a/global.json b/global.json
index 969172a..4d5cd63 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "6.0.100",
+ "version": "8.0.100",
"rollForward": "latestMinor"
}
}
diff --git a/gradle.properties b/gradle.properties
index 9e6cab0..85ea832 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -16,7 +16,7 @@ PublishToken="_PLACEHOLDER_"
# EAP: 2020.3-EAP2-SNAPSHOT
# Nightly: 2020.3-SNAPSHOT
ProductVersion=2025.1
-PluginVersion=2025.1.0
+PluginVersion=2025.1.1
# Kotlin 1.4 will bundle the stdlib dependency by default, causing problems with the version bundled with the IDE
# https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-rc-released/#stdlib-default
diff --git a/src/dotnet/Directory.Build.props b/src/dotnet/Directory.Build.props
index e389508..7f9dc40 100644
--- a/src/dotnet/Directory.Build.props
+++ b/src/dotnet/Directory.Build.props
@@ -1,30 +1,23 @@
-
Latest
true
false
None
-
obj\$(MSBuildProjectName)\
$(DefaultItemExcludes);obj\**
bin\$(MSBuildProjectName)\$(Configuration)\
-
TRACE;DEBUG;JET_MODE_ASSERT
-
-
$(SdkVersion.Substring(2,2))$(SdkVersion.Substring(5,1)).0.0
-
JetResourceGenerator
-
diff --git a/src/dotnet/MO.CleanCode/CleanCodeHighlightingGroupIds.cs b/src/dotnet/MO.CleanCode/CleanCodeHighlightingGroupIds.cs
index 0e3f2c9..3a21f3c 100644
--- a/src/dotnet/MO.CleanCode/CleanCodeHighlightingGroupIds.cs
+++ b/src/dotnet/MO.CleanCode/CleanCodeHighlightingGroupIds.cs
@@ -7,4 +7,4 @@ public static class CleanCodeHighlightingGroupIds
{
public const string CleanCode = "CleanCode";
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Extension/ExpressionExt.cs b/src/dotnet/MO.CleanCode/Extension/ExpressionExt.cs
index cd82f34..2a1e96b 100644
--- a/src/dotnet/MO.CleanCode/Extension/ExpressionExt.cs
+++ b/src/dotnet/MO.CleanCode/Extension/ExpressionExt.cs
@@ -6,6 +6,7 @@ namespace CleanCode.Extension
{
public static class ExpressionExt
{
- public static int GetExpressionCount(this IExpression expression) where T : ITreeNode => expression.GetChildrenRecursive().Count();
+ public static int GetExpressionCount(this IExpression expression)
+ where T : ITreeNode => expression.GetChildrenRecursive().Count();
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheck.cs b/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheck.cs
index 272d20e..3ee5c9d 100644
--- a/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheck.cs
+++ b/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheck.cs
@@ -8,7 +8,11 @@ namespace CleanCode.Features.ChainedReferences;
public abstract class ChainedReferencesCheck : ElementProblemAnalyzer
{
- protected static void HighlightMethodChainsThatAreTooLong(ITreeNode statement, IHighlightingConsumer consumer, int threshold)
+ protected static void HighlightMethodChainsThatAreTooLong(
+ ITreeNode statement,
+ IHighlightingConsumer consumer,
+ int threshold
+ )
{
var children = statement.Children();
@@ -25,7 +29,11 @@ protected static void HighlightMethodChainsThatAreTooLong(ITreeNode statement, I
}
}
- private static void HighlightReferenceExpressionIfNeeded(IReferenceExpression referenceExpression, IHighlightingConsumer consumer, int threshold)
+ private static void HighlightReferenceExpressionIfNeeded(
+ IReferenceExpression referenceExpression,
+ IHighlightingConsumer consumer,
+ int threshold
+ )
{
var types = new HashSet();
@@ -34,7 +42,9 @@ private static void HighlightReferenceExpressionIfNeeded(IReferenceExpression re
while (nextReferenceExpression != null)
{
- var childReturnType = ExtensionMethodsCsharp.TryGetClosedReturnTypeFrom(nextReferenceExpression);
+ var childReturnType = ExtensionMethodsCsharp.TryGetClosedReturnTypeFrom(
+ nextReferenceExpression
+ );
if (childReturnType != null)
{
@@ -42,7 +52,9 @@ private static void HighlightReferenceExpressionIfNeeded(IReferenceExpression re
chainLength++;
}
- nextReferenceExpression = ExtensionMethodsVb.TryGetFirstReferenceExpression(nextReferenceExpression);
+ nextReferenceExpression = ExtensionMethodsVb.TryGetFirstReferenceExpression(
+ nextReferenceExpression
+ );
}
var isFluentChain = types.Count == 1;
@@ -52,11 +64,20 @@ private static void HighlightReferenceExpressionIfNeeded(IReferenceExpression re
}
}
- private static void AddHighlighting(IReferenceExpression reference, IHighlightingConsumer consumer, int threshold, int currentValue)
+ private static void AddHighlighting(
+ IReferenceExpression reference,
+ IHighlightingConsumer consumer,
+ int threshold,
+ int currentValue
+ )
{
var nameIdentifier = reference.NameIdentifier;
var documentRange = nameIdentifier.GetDocumentRange();
- var highlighting = new MaximumChainedReferencesHighlighting(documentRange, threshold, currentValue);
+ var highlighting = new MaximumChainedReferencesHighlighting(
+ documentRange,
+ threshold,
+ currentValue
+ );
consumer.AddHighlighting(highlighting);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckCs.cs b/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckCs.cs
index 6866541..bad9371 100644
--- a/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckCs.cs
@@ -4,18 +4,25 @@
namespace CleanCode.Features.ChainedReferences
{
- [ElementProblemAnalyzer(typeof(ICSharpStatement), HighlightingTypes = new[]
- {
- typeof(MaximumChainedReferencesHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(ICSharpStatement),
+ HighlightingTypes = new[] { typeof(MaximumChainedReferencesHighlighting) }
+ )]
public class ChainedReferencesCheckCs : ChainedReferencesCheck
{
- protected override void Run(ICSharpStatement element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ ICSharpStatement element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- if (element.CanBeEmbedded) return;
-
- var threshold = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumChainedReferences);
+ if (element.CanBeEmbedded)
+ return;
+
+ var threshold = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumChainedReferences
+ );
HighlightMethodChainsThatAreTooLong(element, consumer, threshold);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckVb.cs b/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckVb.cs
index 5b9bc37..38a963e 100644
--- a/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/ChainedReferences/ChainedReferencesCheckVb.cs
@@ -4,16 +4,22 @@
namespace CleanCode.Features.ChainedReferences
{
- [ElementProblemAnalyzer(typeof(IVBStatement), HighlightingTypes = new[]
- {
- typeof(MaximumChainedReferencesHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IVBStatement),
+ HighlightingTypes = new[] { typeof(MaximumChainedReferencesHighlighting) }
+ )]
public class ChainedReferencesCheckVb : ChainedReferencesCheck
{
- protected override void Run(IVBStatement element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IVBStatement element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- var threshold = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumChainedReferences);
+ var threshold = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumChainedReferences
+ );
HighlightMethodChainsThatAreTooLong(element, consumer, threshold);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ChainedReferences/MaximumChainedReferencesHighlighting.cs b/src/dotnet/MO.CleanCode/Features/ChainedReferences/MaximumChainedReferencesHighlighting.cs
index a0f429c..d52819d 100644
--- a/src/dotnet/MO.CleanCode/Features/ChainedReferences/MaximumChainedReferencesHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/ChainedReferences/MaximumChainedReferencesHighlighting.cs
@@ -7,12 +7,14 @@
namespace CleanCode.Features.ChainedReferences
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Too many chained references",
"Too many chained references can break the Law of Demeter.",
- Severity.WARNING)]
+ Severity.WARNING
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class MaximumChainedReferencesHighlighting : IHighlighting
{
@@ -20,12 +22,18 @@ public class MaximumChainedReferencesHighlighting : IHighlighting
private readonly DocumentRange _documentRange;
- public MaximumChainedReferencesHighlighting(DocumentRange documentRange, int threshold, int currentValue)
+ public MaximumChainedReferencesHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
{
- ToolTip = string.Format(CultureInfo.CurrentCulture,
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
Warnings.ChainedReferences,
currentValue,
- threshold);
+ threshold
+ );
_documentRange = documentRange;
}
@@ -38,4 +46,4 @@ public MaximumChainedReferencesHighlighting(DocumentRange documentRange, int thr
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheck.cs b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheck.cs
index 92406c2..576fc48 100644
--- a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheck.cs
+++ b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheck.cs
@@ -6,19 +6,24 @@ namespace CleanCode.Features.ClassTooBig;
public abstract class ClassTooBigCheck : ElementProblemAnalyzer
{
- protected static void CheckIfClassIsTooBig(ITreeNode declaration,
+ protected static void CheckIfClassIsTooBig(
+ ITreeNode declaration,
ITreeNode element,
- ElementProblemAnalyzerData data,
- IHighlightingConsumer consumer)
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
where TMethodDeclaration : ITreeNode
{
- var maxLength = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumMethodsInClass);
+ var maxLength = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumMethodsInClass
+ );
var statementCount = element.CountChildren();
- if (statementCount <= maxLength) return;
-
+ if (statementCount <= maxLength)
+ return;
+
var documentRange = declaration.GetDocumentRange();
var highlighting = new ClassTooBigHighlighting(documentRange, maxLength, statementCount);
consumer.AddHighlighting(highlighting);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckCs.cs b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckCs.cs
index 7c0b2bb..8a4eaba 100644
--- a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckCs.cs
@@ -3,15 +3,24 @@
namespace CleanCode.Features.ClassTooBig
{
- [ElementProblemAnalyzer(typeof(IClassDeclaration), HighlightingTypes = new[]
- {
- typeof(ClassTooBigHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IClassDeclaration),
+ HighlightingTypes = new[] { typeof(ClassTooBigHighlighting) }
+ )]
public class ClassTooBigCheckCs : ClassTooBigCheck
{
- protected override void Run(IClassDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IClassDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- CheckIfClassIsTooBig(element.NameIdentifier, element, data, consumer);
+ CheckIfClassIsTooBig(
+ element.NameIdentifier,
+ element,
+ data,
+ consumer
+ );
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckVb.cs b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckVb.cs
index d095b22..375ed51 100644
--- a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigCheckVb.cs
@@ -3,15 +3,19 @@
namespace CleanCode.Features.ClassTooBig
{
- [ElementProblemAnalyzer(typeof(IClassDeclaration), HighlightingTypes = new[]
- {
- typeof(ClassTooBigHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IClassDeclaration),
+ HighlightingTypes = new[] { typeof(ClassTooBigHighlighting) }
+ )]
public class ClassTooBigCheckVb : ClassTooBigCheck
{
- protected override void Run(IClassDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IClassDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
CheckIfClassIsTooBig(element.Name, element, data, consumer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigHighlighting.cs b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigHighlighting.cs
index c6ede07..377a1d1 100644
--- a/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/ClassTooBig/ClassTooBigHighlighting.cs
@@ -7,12 +7,14 @@
namespace CleanCode.Features.ClassTooBig
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Class too big",
"This class contains too many methods",
- Severity.SUGGESTION)]
+ Severity.SUGGESTION
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class ClassTooBigHighlighting : IHighlighting
{
@@ -22,7 +24,12 @@ public class ClassTooBigHighlighting : IHighlighting
public ClassTooBigHighlighting(DocumentRange documentRange, int threshold, int currentValue)
{
- ToolTip = string.Format(CultureInfo.CurrentCulture, Warnings.ClassTooBig, currentValue, threshold);
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ Warnings.ClassTooBig,
+ currentValue,
+ threshold
+ );
_documentRange = documentRange;
}
@@ -34,4 +41,4 @@ public ClassTooBigHighlighting(DocumentRange documentRange, int threshold, int c
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckCs.cs b/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckCs.cs
index 369007c..12f70a5 100644
--- a/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckCs.cs
@@ -6,19 +6,21 @@
namespace CleanCode.Features.ComplexExpression
{
- [ElementProblemAnalyzer(typeof(IIfStatement),
+ [ElementProblemAnalyzer(
+ typeof(IIfStatement),
typeof(ILoopWithConditionStatement),
typeof(IConditionalTernaryExpression),
typeof(IAssignmentExpression),
typeof(IExpressionInitializer),
- HighlightingTypes = new[]
- {
- typeof(ComplexConditionExpressionHighlighting)
- })]
+ HighlightingTypes = new[] { typeof(ComplexConditionExpressionHighlighting) }
+ )]
public class ComplexConditionExpressionCheckCs : ElementProblemAnalyzer
{
- protected override void Run(ICSharpTreeNode element, ElementProblemAnalyzerData data,
- IHighlightingConsumer consumer)
+ protected override void Run(
+ ICSharpTreeNode element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
var expression = GetExpression(element);
if (expression != null)
@@ -29,27 +31,42 @@ private static IExpression GetExpression(ITreeNode node)
{
switch (node)
{
- case ILoopWithConditionStatement loopWithConditionStatement: return loopWithConditionStatement.Condition;
- case IIfStatement ifStatement: return ifStatement.Condition;
- case IConditionalTernaryExpression conditionalTernaryExpression: return conditionalTernaryExpression.ConditionOperand;
- case IAssignmentExpression assignmentExpression: return assignmentExpression.Source;
- case IExpressionInitializer expressionInitializer: return expressionInitializer.Value;
+ case ILoopWithConditionStatement loopWithConditionStatement:
+ return loopWithConditionStatement.Condition;
+ case IIfStatement ifStatement:
+ return ifStatement.Condition;
+ case IConditionalTernaryExpression conditionalTernaryExpression:
+ return conditionalTernaryExpression.ConditionOperand;
+ case IAssignmentExpression assignmentExpression:
+ return assignmentExpression.Source;
+ case IExpressionInitializer expressionInitializer:
+ return expressionInitializer.Value;
default:
return null;
}
}
- private static void CheckExpression(IExpression expression, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ private static void CheckExpression(
+ IExpression expression,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- var maxExpressions = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumExpressionsInCondition);
+ var maxExpressions = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumExpressionsInCondition
+ );
var expressionCount = expression.GetChildrenRecursive().Count();
if (expressionCount > maxExpressions)
{
var documentRange = expression.GetDocumentRange();
- var highlighting = new ComplexConditionExpressionHighlighting(documentRange, maxExpressions, expressionCount);
+ var highlighting = new ComplexConditionExpressionHighlighting(
+ documentRange,
+ maxExpressions,
+ expressionCount
+ );
consumer.AddHighlighting(highlighting);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckVb.cs b/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckVb.cs
index c89fa0d..6bd11f1 100644
--- a/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionCheckVb.cs
@@ -6,7 +6,8 @@
namespace CleanCode.Features.ComplexExpression
{
- [ElementProblemAnalyzer(typeof(IBlockIfStatement),
+ [ElementProblemAnalyzer(
+ typeof(IBlockIfStatement),
typeof(IElseIfStatement),
typeof(IWhileStatement),
typeof(IForEachStatement),
@@ -14,14 +15,15 @@ namespace CleanCode.Features.ComplexExpression
typeof(IConditionalExpression),
typeof(IExpressionStatement),
typeof(ILineIfStatement),
- HighlightingTypes = new[]
- {
- typeof(ComplexConditionExpressionHighlighting)
- })]
+ HighlightingTypes = new[] { typeof(ComplexConditionExpressionHighlighting) }
+ )]
public class ComplexConditionExpressionCheckVb : ElementProblemAnalyzer
{
- protected override void Run(IVBTreeNode element, ElementProblemAnalyzerData data,
- IHighlightingConsumer consumer)
+ protected override void Run(
+ IVBTreeNode element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
var expression = GetExpression(element);
if (expression != null)
@@ -32,37 +34,55 @@ private static IExpression GetExpression(ITreeNode node)
{
switch (node)
{
- case IBlockIfStatement blockIfStatement: return blockIfStatement.Expression;
- case IElseIfStatement elseIfStatement: return elseIfStatement.Expression;
- case IWhileStatement whileStatement: return whileStatement.Expression;
- case IForEachStatement forEachStatement: return forEachStatement.Expression;
- case IForStatement forStatement: return forStatement.StepExpression;
- case IConditionalExpression conditionalExpression: return conditionalExpression.Condition;
- case IExpressionStatement expressionStatement: return expressionStatement.Expression;
- case ILineIfStatement lineIfStatement: return lineIfStatement.Expression;
+ case IBlockIfStatement blockIfStatement:
+ return blockIfStatement.Expression;
+ case IElseIfStatement elseIfStatement:
+ return elseIfStatement.Expression;
+ case IWhileStatement whileStatement:
+ return whileStatement.Expression;
+ case IForEachStatement forEachStatement:
+ return forEachStatement.Expression;
+ case IForStatement forStatement:
+ return forStatement.StepExpression;
+ case IConditionalExpression conditionalExpression:
+ return conditionalExpression.Condition;
+ case IExpressionStatement expressionStatement:
+ return expressionStatement.Expression;
+ case ILineIfStatement lineIfStatement:
+ return lineIfStatement.Expression;
default:
return null;
}
}
- private static void CheckExpression(IExpression expression, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ private static void CheckExpression(
+ IExpression expression,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- var maxExpressions = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumExpressionsInCondition);
+ var maxExpressions = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumExpressionsInCondition
+ );
var expressionCount = GetExpressionCount(expression);
if (expressionCount > maxExpressions)
{
var documentRange = expression.GetDocumentRange();
- var highlighting = new ComplexConditionExpressionHighlighting(documentRange, maxExpressions, expressionCount);
+ var highlighting = new ComplexConditionExpressionHighlighting(
+ documentRange,
+ maxExpressions,
+ expressionCount
+ );
consumer.AddHighlighting(highlighting);
}
}
private static int GetExpressionCount(IExpression expression)
{
- return expression.GetExpressionCount() +
- expression.GetExpressionCount() +
- expression.GetExpressionCount();
+ return expression.GetExpressionCount()
+ + expression.GetExpressionCount()
+ + expression.GetExpressionCount();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionHighlighting.cs b/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionHighlighting.cs
index 2a8000c..8fa0191 100644
--- a/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/ComplexExpression/ComplexConditionExpressionHighlighting.cs
@@ -7,12 +7,14 @@
namespace CleanCode.Features.ComplexExpression
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Condition expression too complex",
"The expression in the condition is too complex.",
- Severity.WARNING)]
+ Severity.WARNING
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class ComplexConditionExpressionHighlighting : IHighlighting
{
@@ -20,9 +22,18 @@ public class ComplexConditionExpressionHighlighting : IHighlighting
private readonly DocumentRange _documentRange;
- public ComplexConditionExpressionHighlighting(DocumentRange documentRange, int threshold, int currentValue)
+ public ComplexConditionExpressionHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
{
- ToolTip = string.Format(CultureInfo.CurrentCulture, Warnings.ExpressionTooComplex, currentValue, threshold);
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ Warnings.ExpressionTooComplex,
+ currentValue,
+ threshold
+ );
_documentRange = documentRange;
}
@@ -34,4 +45,4 @@ public ComplexConditionExpressionHighlighting(DocumentRange documentRange, int t
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentHighlighting.cs b/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentHighlighting.cs
index 9c5886b..88cb767 100644
--- a/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentHighlighting.cs
@@ -6,21 +6,32 @@
namespace CleanCode.Features.ExcessiveIndentation
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Excessive indentation",
"The nesting in this method is excessive.",
- Severity.WARNING)]
+ Severity.WARNING
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name)]
public class ExcessiveIndentHighlighting : IHighlighting
{
internal const string SeverityID = "ExcessiveIndentation";
private readonly DocumentRange _documentRange;
- public ExcessiveIndentHighlighting(DocumentRange documentRange, int threshold, int currentValue)
+ public ExcessiveIndentHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
{
- ToolTip = string.Format(CultureInfo.CurrentCulture, Warnings.ExcessiveDepth, currentValue, threshold);
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ Warnings.ExcessiveDepth,
+ currentValue,
+ threshold
+ );
_documentRange = documentRange;
}
@@ -32,4 +43,4 @@ public ExcessiveIndentHighlighting(DocumentRange documentRange, int threshold, i
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentationCheckCs.cs b/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentationCheckCs.cs
index 291a9a8..20f9214 100644
--- a/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentationCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/ExcessiveIndentation/ExcessiveIndentationCheckCs.cs
@@ -5,24 +5,33 @@
namespace CleanCode.Features.ExcessiveIndentation
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration),
- HighlightingTypes = new[]
- {
- typeof(ExcessiveIndentHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(ExcessiveIndentHighlighting) }
+ )]
public class ExcessiveIndentationCheckCs : ElementProblemAnalyzer
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- var maxIndentation = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumIndentationDepth);
+ var maxIndentation = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumIndentationDepth
+ );
var childrenDepth = element.GetChildrenDepth();
if (childrenDepth > maxIndentation)
{
var documentRange = element.GetNameDocumentRange();
- var highlighting = new ExcessiveIndentHighlighting(documentRange, maxIndentation, childrenDepth);
+ var highlighting = new ExcessiveIndentHighlighting(
+ documentRange,
+ maxIndentation,
+ childrenDepth
+ );
consumer.AddHighlighting(highlighting);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ExtensionMethodsCsharp.cs b/src/dotnet/MO.CleanCode/Features/ExtensionMethodsCsharp.cs
index 1780755..c858688 100644
--- a/src/dotnet/MO.CleanCode/Features/ExtensionMethodsCsharp.cs
+++ b/src/dotnet/MO.CleanCode/Features/ExtensionMethodsCsharp.cs
@@ -11,7 +11,8 @@ namespace CleanCode.Features
{
public static class ExtensionMethodsCsharp
{
- public static int CountChildren(this ITreeNode node) where T : ITreeNode
+ public static int CountChildren(this ITreeNode node)
+ where T : ITreeNode
{
var treeNodes = node.Children().ToList();
@@ -25,7 +26,6 @@ public static int CountChildren(this ITreeNode node) where T : ITreeNode
return count;
}
-
public static int GetChildrenDepth(this ITreeNode node)
{
var childrenDepth = 0;
@@ -43,7 +43,8 @@ public static int GetChildrenDepth(this ITreeNode node)
return childrenDepth;
}
- public static IEnumerable GetFlattenedHierarchyOfType(this ITreeNode root) where T : class, ITreeNode
+ public static IEnumerable GetFlattenedHierarchyOfType(this ITreeNode root)
+ where T : class, ITreeNode
{
var list = new List();
if (root is T rootAsType)
@@ -54,7 +55,8 @@ public static IEnumerable GetFlattenedHierarchyOfType(this ITreeNode root)
return list;
}
- public static IEnumerable GetChildrenRecursive(this ITreeNode node) where T : ITreeNode
+ public static IEnumerable GetChildrenRecursive(this ITreeNode node)
+ where T : ITreeNode
{
var nodeChildren = node.Children().ToList();
@@ -97,7 +99,8 @@ public static IType TryGetClosedReturnTypeFrom(ITreeNode treeNode)
return TryGetClosedReturnTypeFromReference(reference.Reference);
case IInvocationExpression invocationExpression:
return TryGetClosedReturnTypeFromReference(invocationExpression.Reference);
- default: return null;
+ default:
+ return null;
}
}
@@ -109,8 +112,8 @@ public static IReferenceExpression TryGetFirstReferenceExpression(ITreeNode curr
if (firstChildNode == null)
return null;
- return firstChildNode as IReferenceExpression ??
- TryGetFirstReferenceExpression(firstChildNode);
+ return firstChildNode as IReferenceExpression
+ ?? TryGetFirstReferenceExpression(firstChildNode);
}
private static IType TryGetClosedReturnTypeFromReference(IReference reference)
@@ -121,13 +124,18 @@ private static IType TryGetClosedReturnTypeFromReference(IReference reference)
if (declaredElement is IParametersOwner parametersOwner)
{
var returnType = parametersOwner.ReturnType;
- return returnType.IsOpenType ? GetClosedType(resolveResultWithInfo, returnType) : returnType;
+ return returnType.IsOpenType
+ ? GetClosedType(resolveResultWithInfo, returnType)
+ : returnType;
}
return null;
}
- private static IType GetClosedType(ResolveResultWithInfo resolveResultWithInfo, IType returnType)
+ private static IType GetClosedType(
+ ResolveResultWithInfo resolveResultWithInfo,
+ IType returnType
+ )
{
return resolveResultWithInfo.Result.Substitution.Apply(returnType);
}
@@ -137,4 +145,4 @@ public static ResolveResultWithInfo GetResolveResult(this IReference reference)
return reference.Resolve();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/ExtensionMethodsVb.cs b/src/dotnet/MO.CleanCode/Features/ExtensionMethodsVb.cs
index 86a47f3..c8f6608 100644
--- a/src/dotnet/MO.CleanCode/Features/ExtensionMethodsVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/ExtensionMethodsVb.cs
@@ -1,6 +1,6 @@
using System.Linq;
-using JetBrains.ReSharper.Psi.VB.Tree;
using JetBrains.ReSharper.Psi.Tree;
+using JetBrains.ReSharper.Psi.VB.Tree;
namespace CleanCode.Features
{
@@ -14,8 +14,8 @@ public static IReferenceExpression TryGetFirstReferenceExpression(ITreeNode curr
if (firstChildNode == null)
return null;
- return firstChildNode as IReferenceExpression ??
- TryGetFirstReferenceExpression(firstChildNode);
+ return firstChildNode as IReferenceExpression
+ ?? TryGetFirstReferenceExpression(firstChildNode);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsCheckCs.cs b/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsCheckCs.cs
index 22e695c..6e0e738 100644
--- a/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsCheckCs.cs
@@ -9,30 +9,39 @@
namespace CleanCode.Features.FlagArguments
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration),
- HighlightingTypes = new[]
- {
- typeof(FlagArgumentsHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(FlagArgumentsHighlighting) }
+ )]
public class FlagArgumentsCheckCs : ElementProblemAnalyzer
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data,
- IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- var isFlagAnalysisEnabled = data.SettingsStore.GetValue((CleanCodeSettings s) => s.IsFlagAnalysisEnabled);
- if (!isFlagAnalysisEnabled) return;
+ var isFlagAnalysisEnabled = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.IsFlagAnalysisEnabled
+ );
+ if (!isFlagAnalysisEnabled)
+ return;
var parameterDeclarations = element.ParameterDeclarations.Where(parameterDeclaration =>
- IsFlagArgument(parameterDeclaration, element.Body));
+ IsFlagArgument(parameterDeclaration, element.Body)
+ );
foreach (var parameterDeclaration in parameterDeclarations)
AddHighlighting(consumer, parameterDeclaration);
}
- private static bool IsFlagArgument(ITypeOwnerDeclaration typeOwnerDeclaration, ITreeNode node)
+ private static bool IsFlagArgument(
+ ITypeOwnerDeclaration typeOwnerDeclaration,
+ ITreeNode node
+ )
{
- return IsOfTypeThatCanBeUsedAsFlag(typeOwnerDeclaration) &&
- GetReferencesTo(typeOwnerDeclaration.DeclaredElement, node).Any();
+ return IsOfTypeThatCanBeUsedAsFlag(typeOwnerDeclaration)
+ && GetReferencesTo(typeOwnerDeclaration.DeclaredElement, node).Any();
}
private static bool IsOfTypeThatCanBeUsedAsFlag(ITypeOwnerDeclaration arg)
@@ -41,25 +50,34 @@ private static bool IsOfTypeThatCanBeUsedAsFlag(ITypeOwnerDeclaration arg)
return type.IsBool() || type.IsEnumType();
}
- private static IEnumerable GetReferencesTo(IDeclaredElement declaredElement,
- ITreeNode body)
+ private static IEnumerable GetReferencesTo(
+ IDeclaredElement declaredElement,
+ ITreeNode body
+ )
{
var ifStatements = body.GetChildrenRecursive();
var allConditions = ifStatements.Select(statement => statement.Condition);
var allReferencesInConditions = allConditions.SelectMany(expression =>
- expression.GetFlattenedHierarchyOfType());
+ expression.GetFlattenedHierarchyOfType()
+ );
return GetReferencesToArgument(allReferencesInConditions, declaredElement);
}
private static IEnumerable GetReferencesToArgument(
- IEnumerable allReferencesInConditions, IDeclaredElement declaredElementInArgument)
+ IEnumerable allReferencesInConditions,
+ IDeclaredElement declaredElementInArgument
+ )
{
return allReferencesInConditions.Where(reference =>
- IsReferenceToArgument(reference, declaredElementInArgument));
+ IsReferenceToArgument(reference, declaredElementInArgument)
+ );
}
- private static bool IsReferenceToArgument(IReferenceExpression referenceExpression, IDeclaredElement toFind)
+ private static bool IsReferenceToArgument(
+ IReferenceExpression referenceExpression,
+ IDeclaredElement toFind
+ )
{
if (referenceExpression == null)
{
@@ -72,12 +90,14 @@ private static bool IsReferenceToArgument(IReferenceExpression referenceExpressi
return declaredElement != null && declaredElement.ShortName == toFind.ShortName;
}
- private static void AddHighlighting(IHighlightingConsumer consumer,
- ICSharpParameterDeclaration parameterDeclaration)
+ private static void AddHighlighting(
+ IHighlightingConsumer consumer,
+ ICSharpParameterDeclaration parameterDeclaration
+ )
{
var documentRange = parameterDeclaration.GetDocumentRange();
var highlighting = new FlagArgumentsHighlighting(documentRange);
consumer.AddHighlighting(highlighting);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsHighlighting.cs b/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsHighlighting.cs
index 2a2e141..52c5775 100644
--- a/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/FlagArguments/FlagArgumentsHighlighting.cs
@@ -5,12 +5,14 @@
namespace CleanCode.Features.FlagArguments
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Flag argument",
"An argument that is used as a flag.",
- Severity.WARNING)]
+ Severity.WARNING
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name)]
public class FlagArgumentsHighlighting : IHighlighting
{
@@ -30,4 +32,4 @@ public FlagArgumentsHighlighting(DocumentRange documentRange)
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheck.cs b/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheck.cs
index 79f6e98..32149ca 100644
--- a/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheck.cs
+++ b/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheck.cs
@@ -14,7 +14,11 @@ public abstract class HollowNamesCheck : ElementProblemAnalyzer
{
private static readonly string[] Separator = { "," };
- protected static void CheckAndAddHighlighting(IDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected static void CheckAndAddHighlighting(
+ IDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
var suffixes = GetSuffixes(data.SettingsStore);
@@ -22,10 +26,12 @@ protected static void CheckAndAddHighlighting(IDeclaration element, ElementProbl
if (match != null)
AddHighlighting(match, consumer, element);
}
-
+
private static string[] GetSuffixes(IContextBoundSettingsStore dataSettingsStore)
{
- var suffixes = dataSettingsStore.GetValue((CleanCodeSettings s) => s.MeaninglessClassNameSuffixes);
+ var suffixes = dataSettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MeaninglessClassNameSuffixes
+ );
return suffixes.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
}
@@ -34,11 +40,19 @@ private static string GetFirstMatchOrDefault(string declaredName, IEnumerable
{
- protected override void Run(IClassDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IClassDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
CheckAndAddHighlighting(element, data, consumer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheckVb.cs b/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheckVb.cs
index 10aa898..ddccc5a 100644
--- a/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/HollowNames/HollowNamesCheckVb.cs
@@ -3,17 +3,19 @@
namespace CleanCode.Features.HollowNames
{
- [ElementProblemAnalyzer(typeof(IClassDeclaration),
- HighlightingTypes = new[]
- {
- typeof(HollowTypeNameHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IClassDeclaration),
+ HighlightingTypes = new[] { typeof(HollowTypeNameHighlighting) }
+ )]
public class HollowNamesCheckVb : HollowNamesCheck
{
-
- protected override void Run(IClassDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IClassDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
CheckAndAddHighlighting(element, data, consumer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/HollowNames/HollowTypeNameHighlighting.cs b/src/dotnet/MO.CleanCode/Features/HollowNames/HollowTypeNameHighlighting.cs
index 44f234b..37eb39f 100644
--- a/src/dotnet/MO.CleanCode/Features/HollowNames/HollowTypeNameHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/HollowNames/HollowTypeNameHighlighting.cs
@@ -5,12 +5,14 @@
namespace CleanCode.Features.HollowNames
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Hollow type name",
"This type has a name that doesn't express its intent.",
- Severity.SUGGESTION)]
+ Severity.SUGGESTION
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class HollowTypeNameHighlighting : IHighlighting
{
@@ -31,4 +33,4 @@ public HollowTypeNameHighlighting(string toolTip, DocumentRange documentRange)
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheck.cs b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheck.cs
index cb80e27..26a035a 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheck.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheck.cs
@@ -6,19 +6,25 @@ namespace CleanCode.Features.MethodNameNotMeaningful;
public abstract class MethodNameNotMeaningfulCheck : ElementProblemAnalyzer
{
- protected static void CheckAndAddHighlighting(IDeclaration element, ElementProblemAnalyzerData data,
- IHighlightingConsumer consumer)
+ protected static void CheckAndAddHighlighting(
+ IDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
if (element == null)
return;
- var minimumMethodNameLength = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MinimumMeaningfulMethodNameLength);
+ var minimumMethodNameLength = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MinimumMeaningfulMethodNameLength
+ );
var name = element.GetText();
- if (name.Length >= minimumMethodNameLength) return;
-
+ if (name.Length >= minimumMethodNameLength)
+ return;
+
var documentRange = element.GetNameDocumentRange();
var highlighting = new MethodNameNotMeaningfulHighlighting(documentRange);
consumer.AddHighlighting(highlighting);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckCs.cs b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckCs.cs
index adc9a76..6ed7b31 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckCs.cs
@@ -3,15 +3,19 @@
namespace CleanCode.Features.MethodNameNotMeaningful
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration), HighlightingTypes = new[]
- {
- typeof(MethodNameNotMeaningfulHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(MethodNameNotMeaningfulHighlighting) }
+ )]
public class MethodNameNotMeaningfulCheckCs : MethodNameNotMeaningfulCheck
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
CheckAndAddHighlighting(element, data, consumer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckVb.cs b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckVb.cs
index 0511d65..23f258f 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulCheckVb.cs
@@ -3,15 +3,19 @@
namespace CleanCode.Features.MethodNameNotMeaningful
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration), HighlightingTypes = new[]
- {
- typeof(MethodNameNotMeaningfulHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(MethodNameNotMeaningfulHighlighting) }
+ )]
public class MethodNameNotMeaningfulCheckVb : MethodNameNotMeaningfulCheck
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
CheckAndAddHighlighting(element, data, consumer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulHighlighting.cs b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulHighlighting.cs
index 593ccf0..1ee2a19 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodNameNotMeaningful/MethodNameNotMeaningfulHighlighting.cs
@@ -6,12 +6,14 @@
namespace CleanCode.Features.MethodNameNotMeaningful
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Method name not meaningful",
"This method name is too short to be meaningful.",
- Severity.WARNING)]
+ Severity.WARNING
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class MethodNameNotMeaningfulHighlighting : IHighlighting
{
@@ -31,4 +33,4 @@ public MethodNameNotMeaningfulHighlighting(DocumentRange documentRange)
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheck.cs b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheck.cs
index e89d11a..b34de01 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheck.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheck.cs
@@ -8,63 +8,98 @@ namespace CleanCode.Features.MethodTooLong;
public abstract class MethodTooLongCheck : ElementProblemAnalyzer
{
- protected static void CheckAndAddHighlight(TMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected static void CheckAndAddHighlight(
+ TMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
where TMethodDeclaration : IDeclaration
{
var highlighting = GetHighlighting(element, data);
if (highlighting != null)
consumer.AddHighlighting(highlighting);
}
-
- private static IHighlighting GetHighlighting(TMethodDeclaration element, ElementProblemAnalyzerData data)
+
+ private static IHighlighting GetHighlighting(
+ TMethodDeclaration element,
+ ElementProblemAnalyzerData data
+ )
where TMethodDeclaration : IDeclaration
{
- var maxStatements = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumMethodStatements);
- var maxDeclarations = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumDeclarationsInMethod);
+ var maxStatements = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumMethodStatements
+ );
+ var maxDeclarations = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumDeclarationsInMethod
+ );
var highlight = CheckStatementCount(element, maxStatements);
- if (highlight != null) return highlight;
+ if (highlight != null)
+ return highlight;
return element switch
{
- JetBrains.ReSharper.Psi.CSharp.Tree.IMethodDeclaration declaration => CheckDeclarationCount(declaration,
- maxDeclarations),
- JetBrains.ReSharper.Psi.VB.Tree.IMethodDeclaration declaration => CheckDeclarationCount(declaration,
- maxDeclarations),
- _ => throw new ArgumentOutOfRangeException(nameof(element), element, null)
+ JetBrains.ReSharper.Psi.CSharp.Tree.IMethodDeclaration declaration =>
+ CheckDeclarationCount(declaration, maxDeclarations),
+ JetBrains.ReSharper.Psi.VB.Tree.IMethodDeclaration declaration => CheckDeclarationCount(
+ declaration,
+ maxDeclarations
+ ),
+ _ => throw new ArgumentOutOfRangeException(nameof(element), element, null),
};
}
[CanBeNull]
- private static MethodTooLongHighlighting CheckStatementCount(IDeclaration element, int maxStatements)
+ private static MethodTooLongHighlighting CheckStatementCount(
+ IDeclaration element,
+ int maxStatements
+ )
{
var statementCount = element.CountChildren();
- return statementCount > maxStatements
- ? new MethodTooLongHighlighting(element.GetNameDocumentRange(), maxStatements, statementCount)
+ return statementCount > maxStatements
+ ? new MethodTooLongHighlighting(
+ element.GetNameDocumentRange(),
+ maxStatements,
+ statementCount
+ )
: null;
}
[CanBeNull]
- private static MethodTooManyDeclarationsHighlighting CheckDeclarationCount(JetBrains.ReSharper.Psi.CSharp.Tree.IMethodDeclaration element, int maxDeclarations)
+ private static MethodTooManyDeclarationsHighlighting CheckDeclarationCount(
+ JetBrains.ReSharper.Psi.CSharp.Tree.IMethodDeclaration element,
+ int maxDeclarations
+ )
{
// Only look in the method body for declarations, otherwise we see
// parameters + type parameters. We can ignore arrow expressions, as
// they must be a single expression and won't have declarations
var declarationCount = element.Body?.CountChildren() ?? 0;
- return declarationCount > maxDeclarations
- ? new MethodTooManyDeclarationsHighlighting(element.GetNameDocumentRange(), maxDeclarations, declarationCount)
+ return declarationCount > maxDeclarations
+ ? new MethodTooManyDeclarationsHighlighting(
+ element.GetNameDocumentRange(),
+ maxDeclarations,
+ declarationCount
+ )
: null;
}
-
+
[CanBeNull]
- private static MethodTooManyDeclarationsHighlighting CheckDeclarationCount(JetBrains.ReSharper.Psi.VB.Tree.IMethodDeclaration element, int maxDeclarations)
+ private static MethodTooManyDeclarationsHighlighting CheckDeclarationCount(
+ JetBrains.ReSharper.Psi.VB.Tree.IMethodDeclaration element,
+ int maxDeclarations
+ )
{
// Only look in the method body for declarations, otherwise we see
// parameters + type parameters. We can ignore arrow expressions, as
// they must be a single expression and won't have declarations
var declarationCount = element.Block?.CountChildren() ?? 0;
- return declarationCount > maxDeclarations
- ? new MethodTooManyDeclarationsHighlighting(element.GetNameDocumentRange(), maxDeclarations, declarationCount)
+ return declarationCount > maxDeclarations
+ ? new MethodTooManyDeclarationsHighlighting(
+ element.GetNameDocumentRange(),
+ maxDeclarations,
+ declarationCount
+ )
: null;
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckCs.cs b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckCs.cs
index d84fcd9..43f532e 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckCs.cs
@@ -3,15 +3,19 @@
namespace CleanCode.Features.MethodTooLong
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration), HighlightingTypes = new[]
- {
- typeof(MethodTooLongHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(MethodTooLongHighlighting) }
+ )]
public class MethodTooLongCheckCs : MethodTooLongCheck
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
CheckAndAddHighlight(element, data, consumer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckVb.cs b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckVb.cs
index e0d1a6c..a06fcba 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongCheckVb.cs
@@ -3,12 +3,19 @@
namespace CleanCode.Features.MethodTooLong
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration), HighlightingTypes = new[] { typeof(MethodTooLongHighlighting) })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(MethodTooLongHighlighting) }
+ )]
public class MethodTooLongCheckVb : MethodTooLongCheck
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
CheckAndAddHighlight(element, data, consumer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongHighlighting.cs b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongHighlighting.cs
index 197143d..87e5e89 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooLongHighlighting.cs
@@ -7,21 +7,32 @@
namespace CleanCode.Features.MethodTooLong
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Method too long",
"The method is bigger than it should be.",
- Severity.SUGGESTION)]
+ Severity.SUGGESTION
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class MethodTooLongHighlighting : IHighlighting
{
internal const string SeverityID = "MethodTooLong";
private readonly DocumentRange _documentRange;
- public MethodTooLongHighlighting(DocumentRange documentRange, int threshold, int currentValue)
+ public MethodTooLongHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
{
- ToolTip = string.Format(CultureInfo.CurrentCulture, Warnings.MethodTooLong, currentValue, threshold);
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ Warnings.MethodTooLong,
+ currentValue,
+ threshold
+ );
_documentRange = documentRange;
}
@@ -33,4 +44,4 @@ public MethodTooLongHighlighting(DocumentRange documentRange, int threshold, int
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooManyDeclarationsHighlighting.cs b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooManyDeclarationsHighlighting.cs
index 7f13ac2..04a9143 100644
--- a/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooManyDeclarationsHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/MethodTooLong/MethodTooManyDeclarationsHighlighting.cs
@@ -7,21 +7,32 @@
namespace CleanCode.Features.MethodTooLong
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Too many Declarations",
"The method has more declarations than there should be.",
- Severity.SUGGESTION)]
+ Severity.SUGGESTION
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class MethodTooManyDeclarationsHighlighting : IHighlighting
{
internal const string SeverityID = "TooManyDeclarations";
private readonly DocumentRange _documentRange;
- public MethodTooManyDeclarationsHighlighting(DocumentRange documentRange, int threshold, int currentValue)
+ public MethodTooManyDeclarationsHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
{
- ToolTip = string.Format(CultureInfo.CurrentCulture, Warnings.TooManyDeclarations, currentValue, threshold);
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ Warnings.TooManyDeclarations,
+ currentValue,
+ threshold
+ );
_documentRange = documentRange;
}
@@ -33,4 +44,4 @@ public MethodTooManyDeclarationsHighlighting(DocumentRange documentRange, int th
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckCs.cs b/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckCs.cs
index 885e55a..ef18b4b 100644
--- a/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckCs.cs
@@ -7,23 +7,35 @@
namespace CleanCode.Features.TooManyDependencies
{
- [ElementProblemAnalyzer(typeof(IConstructorDeclaration), HighlightingTypes = new[]
- {
- typeof(TooManyDependenciesHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IConstructorDeclaration),
+ HighlightingTypes = new[] { typeof(TooManyDependenciesHighlighting) }
+ )]
public class TooManyDependenciesCheckCs : ElementProblemAnalyzer
{
- protected override void Run(IConstructorDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ 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?.Type).IsInterfaceType());
+ var maxDependencies = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumConstructorDependencies
+ );
+ var dependencies = element.ParameterDeclarations.Select(declaration =>
+ (declaration.DeclaredElement?.Type).IsInterfaceType()
+ );
var dependenciesCount = dependencies.Count();
if (dependenciesCount > maxDependencies)
{
- var highlighting = new TooManyDependenciesHighlighting(element.GetNameDocumentRange(), maxDependencies, dependenciesCount);
+ var highlighting = new TooManyDependenciesHighlighting(
+ element.GetNameDocumentRange(),
+ maxDependencies,
+ dependenciesCount
+ );
consumer.AddHighlighting(highlighting);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckVb.cs b/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckVb.cs
index 3f8016e..b746976 100644
--- a/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesCheckVb.cs
@@ -7,23 +7,35 @@
namespace CleanCode.Features.TooManyDependencies
{
- [ElementProblemAnalyzer(typeof(IConstructorDeclaration), HighlightingTypes = new[]
- {
- typeof(TooManyDependenciesHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IConstructorDeclaration),
+ HighlightingTypes = new[] { typeof(TooManyDependenciesHighlighting) }
+ )]
public class TooManyDependenciesCheckVb : ElementProblemAnalyzer
{
- protected override void Run(IConstructorDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ 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?.Type).IsInterfaceType());
+ var maxDependencies = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumConstructorDependencies
+ );
+ var dependencies = element.ParameterDeclarations.Select(declaration =>
+ (declaration.DeclaredElement?.Type).IsInterfaceType()
+ );
var dependenciesCount = dependencies.Count();
if (dependenciesCount > maxDependencies)
{
- var highlighting = new TooManyDependenciesHighlighting(element.GetNameDocumentRange(), maxDependencies, dependenciesCount);
+ var highlighting = new TooManyDependenciesHighlighting(
+ element.GetNameDocumentRange(),
+ maxDependencies,
+ dependenciesCount
+ );
consumer.AddHighlighting(highlighting);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesHighlighting.cs b/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesHighlighting.cs
index 3523eb0..8320eea 100644
--- a/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/TooManyDependencies/TooManyDependenciesHighlighting.cs
@@ -7,21 +7,32 @@
namespace CleanCode.Features.TooManyDependencies
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Too many dependencies",
"Too many dependencies passed into constructor.",
- Severity.WARNING)]
+ Severity.WARNING
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class TooManyDependenciesHighlighting : IHighlighting
{
internal const string SeverityID = "TooManyDependencies";
private readonly DocumentRange _documentRange;
- public TooManyDependenciesHighlighting(DocumentRange documentRange, int threshold, int currentValue)
+ public TooManyDependenciesHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
{
- ToolTip = string.Format(CultureInfo.CurrentCulture, Warnings.TooManyDependencies, currentValue, threshold);
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ Warnings.TooManyDependencies,
+ currentValue,
+ threshold
+ );
_documentRange = documentRange;
}
@@ -33,4 +44,4 @@ public TooManyDependenciesHighlighting(DocumentRange documentRange, int threshol
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyArgumentsHighlighting.cs b/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyArgumentsHighlighting.cs
index 35fc0a7..0e032bd 100644
--- a/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyArgumentsHighlighting.cs
+++ b/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyArgumentsHighlighting.cs
@@ -7,24 +7,32 @@
namespace CleanCode.Features.TooManyMethodArguments
{
- [RegisterConfigurableSeverity(SeverityID,
+ [RegisterConfigurableSeverity(
+ SeverityID,
null,
CleanCodeHighlightingGroupIds.CleanCode,
"Too many arguments",
"Too many arguments passed to a method.",
- Severity.WARNING)]
+ Severity.WARNING
+ )]
[ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
public class TooManyArgumentsHighlighting : IHighlighting
{
internal const string SeverityID = "TooManyArguments";
private readonly DocumentRange _documentRange;
- public TooManyArgumentsHighlighting(DocumentRange documentRange, int threshold, int currentValue)
+ public TooManyArgumentsHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
{
- ToolTip = string.Format(CultureInfo.CurrentCulture,
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
Warnings.TooManyMethodArguments,
currentValue,
- threshold);
+ threshold
+ );
_documentRange = documentRange;
}
@@ -37,4 +45,4 @@ public TooManyArgumentsHighlighting(DocumentRange documentRange, int threshold,
public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckCs.cs b/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckCs.cs
index 3733191..6350f34 100644
--- a/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckCs.cs
+++ b/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckCs.cs
@@ -5,23 +5,33 @@
namespace CleanCode.Features.TooManyMethodArguments
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration), HighlightingTypes = new[]
- {
- typeof(TooManyArgumentsHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(TooManyArgumentsHighlighting) }
+ )]
public class TooManyMethodArgumentsCheckCs : ElementProblemAnalyzer
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- var maxParameters = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumMethodParameters);
+ var maxParameters = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumMethodParameters
+ );
var parameterDeclarations = element.ParameterDeclarations;
var parameterCount = parameterDeclarations.Count;
if (parameterCount > maxParameters)
{
- var highlighting = new TooManyArgumentsHighlighting(element.GetNameDocumentRange(), maxParameters, parameterCount);
+ var highlighting = new TooManyArgumentsHighlighting(
+ element.GetNameDocumentRange(),
+ maxParameters,
+ parameterCount
+ );
consumer.AddHighlighting(highlighting);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckVb.cs b/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckVb.cs
index ed854b2..3de4473 100644
--- a/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckVb.cs
+++ b/src/dotnet/MO.CleanCode/Features/TooManyMethodArguments/TooManyMethodArgumentsCheckVb.cs
@@ -5,23 +5,33 @@
namespace CleanCode.Features.TooManyMethodArguments
{
- [ElementProblemAnalyzer(typeof(IMethodDeclaration), HighlightingTypes = new[]
- {
- typeof(TooManyArgumentsHighlighting)
- })]
+ [ElementProblemAnalyzer(
+ typeof(IMethodDeclaration),
+ HighlightingTypes = new[] { typeof(TooManyArgumentsHighlighting) }
+ )]
public class TooManyMethodArgumentsCheckVb : ElementProblemAnalyzer
{
- protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer)
+ protected override void Run(
+ IMethodDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
{
- var maxParameters = data.SettingsStore.GetValue((CleanCodeSettings s) => s.MaximumMethodParameters);
+ var maxParameters = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumMethodParameters
+ );
var parameterDeclarations = element.ParameterDeclarations;
var parameterCount = parameterDeclarations.Count;
if (parameterCount > maxParameters)
{
- var highlighting = new TooManyArgumentsHighlighting(element.GetNameDocumentRange(), maxParameters, parameterCount);
+ var highlighting = new TooManyArgumentsHighlighting(
+ element.GetNameDocumentRange(),
+ maxParameters,
+ parameterCount
+ );
consumer.AddHighlighting(highlighting);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheck.cs b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheck.cs
new file mode 100644
index 0000000..111dc03
--- /dev/null
+++ b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheck.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Linq;
+using CleanCode.Settings;
+using JetBrains.ReSharper.Feature.Services.Daemon;
+using JetBrains.ReSharper.Psi.Tree;
+
+namespace CleanCode.Features.TooManyPublicMethods
+{
+ public abstract class TooManyPublicMethodsCheck : ElementProblemAnalyzer
+ {
+ protected static void CheckIfClassHasTooManyPublicMethods(
+ ITreeNode declaration,
+ ITreeNode element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer,
+ Func isPublicMethod
+ )
+ where TMethodDeclaration : ITreeNode
+ {
+ var maxPublicMethods = data.SettingsStore.GetValue(
+ (CleanCodeSettings s) => s.MaximumPublicMethodsInClass
+ );
+
+ var publicMethodCount = element
+ .Children()
+ .OfType()
+ .Count(isPublicMethod);
+
+ if (publicMethodCount <= maxPublicMethods)
+ return;
+
+ var documentRange = declaration.GetDocumentRange();
+ var highlighting = new TooManyPublicMethodsHighlighting(
+ documentRange,
+ maxPublicMethods,
+ publicMethodCount
+ );
+ consumer.AddHighlighting(highlighting);
+ }
+ }
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheckCs.cs b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheckCs.cs
new file mode 100644
index 0000000..5bb5cd1
--- /dev/null
+++ b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheckCs.cs
@@ -0,0 +1,28 @@
+using JetBrains.ReSharper.Feature.Services.Daemon;
+using JetBrains.ReSharper.Psi;
+using JetBrains.ReSharper.Psi.CSharp.Tree;
+
+namespace CleanCode.Features.TooManyPublicMethods
+{
+ [ElementProblemAnalyzer(
+ typeof(IClassDeclaration),
+ HighlightingTypes = new[] { typeof(TooManyPublicMethodsHighlighting) }
+ )]
+ public class TooManyPublicMethodsCheckCs : TooManyPublicMethodsCheck
+ {
+ protected override void Run(
+ IClassDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
+ {
+ CheckIfClassHasTooManyPublicMethods(
+ element.NameIdentifier,
+ element,
+ data,
+ consumer,
+ method => method.GetAccessRights() == AccessRights.PUBLIC
+ );
+ }
+ }
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheckVb.cs b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheckVb.cs
new file mode 100644
index 0000000..2ed5ba7
--- /dev/null
+++ b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsCheckVb.cs
@@ -0,0 +1,28 @@
+using JetBrains.ReSharper.Feature.Services.Daemon;
+using JetBrains.ReSharper.Psi;
+using JetBrains.ReSharper.Psi.VB.Tree;
+
+namespace CleanCode.Features.TooManyPublicMethods
+{
+ [ElementProblemAnalyzer(
+ typeof(IClassDeclaration),
+ HighlightingTypes = new[] { typeof(TooManyPublicMethodsHighlighting) }
+ )]
+ public class TooManyPublicMethodsCheckVb : TooManyPublicMethodsCheck
+ {
+ protected override void Run(
+ IClassDeclaration element,
+ ElementProblemAnalyzerData data,
+ IHighlightingConsumer consumer
+ )
+ {
+ CheckIfClassHasTooManyPublicMethods(
+ element.Name,
+ element,
+ data,
+ consumer,
+ method => method.GetAccessRights() == AccessRights.PUBLIC
+ );
+ }
+ }
+}
diff --git a/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsHighlighting.cs b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsHighlighting.cs
new file mode 100644
index 0000000..cef72ca
--- /dev/null
+++ b/src/dotnet/MO.CleanCode/Features/TooManyPublicMethods/TooManyPublicMethodsHighlighting.cs
@@ -0,0 +1,48 @@
+using System.Globalization;
+using CleanCode.Resources;
+using JetBrains.DocumentModel;
+using JetBrains.ReSharper.Feature.Services.Daemon;
+using JetBrains.ReSharper.Psi.CSharp;
+using JetBrains.ReSharper.Psi.VB;
+
+namespace CleanCode.Features.TooManyPublicMethods
+{
+ [RegisterConfigurableSeverity(
+ SeverityID,
+ null,
+ CleanCodeHighlightingGroupIds.CleanCode,
+ "Too many public methods",
+ "This class exposes too many public methods",
+ Severity.SUGGESTION
+ )]
+ [ConfigurableSeverityHighlighting(SeverityID, CSharpLanguage.Name + "," + VBLanguage.Name)]
+ public class TooManyPublicMethodsHighlighting : IHighlighting
+ {
+ internal const string SeverityID = "TooManyPublicMethods";
+
+ private readonly DocumentRange _documentRange;
+
+ public TooManyPublicMethodsHighlighting(
+ DocumentRange documentRange,
+ int threshold,
+ int currentValue
+ )
+ {
+ ToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ Warnings.TooManyPublicMethods,
+ currentValue,
+ threshold
+ );
+ _documentRange = documentRange;
+ }
+
+ public DocumentRange CalculateRange() => _documentRange;
+
+ public string ToolTip { get; }
+
+ public string ErrorStripeToolTip => ToolTip;
+
+ public bool IsValid() => !string.IsNullOrWhiteSpace(ToolTip);
+ }
+}
diff --git a/src/dotnet/MO.CleanCode/InvalidateOnSettingsChange.cs b/src/dotnet/MO.CleanCode/InvalidateOnSettingsChange.cs
index c8f456c..191a9de 100644
--- a/src/dotnet/MO.CleanCode/InvalidateOnSettingsChange.cs
+++ b/src/dotnet/MO.CleanCode/InvalidateOnSettingsChange.cs
@@ -9,10 +9,18 @@ namespace CleanCode
[SolutionComponent(JetBrains.Application.Parts.Instantiation.DemandAnyThreadSafe)]
public class InvalidateOnSettingsChange
{
- public InvalidateOnSettingsChange(Lifetime lifetime, IDaemon daemon, ISettingsStore settingsStore)
+ public InvalidateOnSettingsChange(
+ Lifetime lifetime,
+ IDaemon daemon,
+ ISettingsStore settingsStore
+ )
{
var settingsKey = settingsStore.Schema.GetKey();
- settingsStore.AdviseChange(lifetime, settingsKey, () => daemon.Invalidate("settings have changed"));
+ settingsStore.AdviseChange(
+ lifetime,
+ settingsKey,
+ () => daemon.Invalidate("settings have changed")
+ );
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/MO.CleanCode.Rider.csproj b/src/dotnet/MO.CleanCode/MO.CleanCode.Rider.csproj
index 9746977..1886c62 100644
--- a/src/dotnet/MO.CleanCode/MO.CleanCode.Rider.csproj
+++ b/src/dotnet/MO.CleanCode/MO.CleanCode.Rider.csproj
@@ -1,62 +1,58 @@
-
-
- net472
- MO.CleanCode
- CleanCode
- false
- false
- CleanCode.ruleset
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Settings.resx
-
-
- True
- True
- Warnings.resx
-
-
-
-
-
- ResXFileCodeGenerator
- Settings.Designer.cs
-
-
- ResXFileCodeGenerator
- Warnings.Designer.cs
-
-
-
-
-
- Designer
- MSBuild:Compile
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+ net472
+ MO.CleanCode
+ CleanCode
+ false
+ false
+ CleanCode.ruleset
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Settings.resx
+
+
+ True
+ True
+ Warnings.resx
+
+
+
+
+ ResXFileCodeGenerator
+ Settings.Designer.cs
+
+
+ ResXFileCodeGenerator
+ Warnings.Designer.cs
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
+
diff --git a/src/dotnet/MO.CleanCode/MO.CleanCode.csproj b/src/dotnet/MO.CleanCode/MO.CleanCode.csproj
index 10124ec..325606c 100644
--- a/src/dotnet/MO.CleanCode/MO.CleanCode.csproj
+++ b/src/dotnet/MO.CleanCode/MO.CleanCode.csproj
@@ -1,63 +1,59 @@
-
-
- net472
- MO.CleanCode
- CleanCode
- false
- CleanCode.ruleset
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Settings.resx
-
-
- True
- True
- Warnings.resx
-
-
-
-
-
- ResXFileCodeGenerator
- Settings.Designer.cs
-
-
- ResXFileCodeGenerator
- Warnings.Designer.cs
-
-
-
-
-
- Designer
- MSBuild:Compile
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+ net472
+ MO.CleanCode
+ CleanCode
+ false
+ CleanCode.ruleset
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Settings.resx
+
+
+ True
+ True
+ Warnings.resx
+
+
+
+
+ ResXFileCodeGenerator
+ Settings.Designer.cs
+
+
+ ResXFileCodeGenerator
+ Warnings.Designer.cs
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
+
diff --git a/src/dotnet/MO.CleanCode/Properties/AssemblyInfo.cs b/src/dotnet/MO.CleanCode/Properties/AssemblyInfo.cs
index 43a2830..416c34e 100644
--- a/src/dotnet/MO.CleanCode/Properties/AssemblyInfo.cs
+++ b/src/dotnet/MO.CleanCode/Properties/AssemblyInfo.cs
@@ -13,4 +13,4 @@
[assembly: Guid("97927FF9-8C9C-4DC5-A309-29C23F41DA47")]
[assembly: AssemblyVersion("5.6.7.0")]
-[assembly: AssemblyFileVersion("5.6.7.0")]
\ No newline at end of file
+[assembly: AssemblyFileVersion("5.6.7.0")]
diff --git a/src/dotnet/MO.CleanCode/Resources/Settings.Designer.cs b/src/dotnet/MO.CleanCode/Resources/Settings.Designer.cs
index 09e92a4..1384232 100644
--- a/src/dotnet/MO.CleanCode/Resources/Settings.Designer.cs
+++ b/src/dotnet/MO.CleanCode/Resources/Settings.Designer.cs
@@ -131,16 +131,18 @@ internal static string MaximumMethodsPerClass {
return ResourceManager.GetString("MaximumMethodsPerClass", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Maximum statements per method.
///
- internal static string MaximumStatementsPerMethod {
- get {
+ internal static string MaximumStatementsPerMethod
+ {
+ get
+ {
return ResourceManager.GetString("MaximumStatementsPerMethod", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to List of meaningless suffixes.
///
@@ -149,7 +151,7 @@ internal static string MeaninglessNameSuffixes {
return ResourceManager.GetString("MeaninglessNameSuffixes", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Separate items with commas.
///
@@ -158,6 +160,17 @@ internal static string MeaninglessNameSuffixesTooltip {
return ResourceManager.GetString("MeaninglessNameSuffixesTooltip", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Maximum public methods per class.
+ ///
+ internal static string MaximumPublicMethodsPerClass
+ {
+ get
+ {
+ return ResourceManager.GetString("MaximumPublicMethodsPerClass", resourceCulture);
+ }
+ }
///
/// Looks up a localized string similar to Minimum method name length.
diff --git a/src/dotnet/MO.CleanCode/Resources/Settings.resx b/src/dotnet/MO.CleanCode/Resources/Settings.resx
index df9a0a3..20711ea 100644
--- a/src/dotnet/MO.CleanCode/Resources/Settings.resx
+++ b/src/dotnet/MO.CleanCode/Resources/Settings.resx
@@ -153,4 +153,7 @@
Is flag analysis active.
+
+ Maximum public methods per class
+
\ No newline at end of file
diff --git a/src/dotnet/MO.CleanCode/Resources/Warnings.Designer.cs b/src/dotnet/MO.CleanCode/Resources/Warnings.Designer.cs
index 51f7ae1..3d4d8fa 100644
--- a/src/dotnet/MO.CleanCode/Resources/Warnings.Designer.cs
+++ b/src/dotnet/MO.CleanCode/Resources/Warnings.Designer.cs
@@ -158,5 +158,14 @@ internal static string TooManyMethodArguments {
return ResourceManager.GetString("TooManyMethodArguments", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Class contains too many public methods. This might be violating the Single Responsibility Principle and exposing too much of its implementation. ({0} / {1}).
+ ///
+ internal static string TooManyPublicMethods {
+ get {
+ return ResourceManager.GetString("TooManyPublicMethods", resourceCulture);
+ }
+ }
}
}
diff --git a/src/dotnet/MO.CleanCode/Resources/Warnings.resx b/src/dotnet/MO.CleanCode/Resources/Warnings.resx
index 387deee..bd6bf36 100644
--- a/src/dotnet/MO.CleanCode/Resources/Warnings.resx
+++ b/src/dotnet/MO.CleanCode/Resources/Warnings.resx
@@ -150,4 +150,7 @@
This method has too many declarations. ({0} / {1})
+
+ Class contains too many public methods. This might be violating the Single Responsibility Principle and exposing too much of its implementation. ({0} / {1})
+
\ No newline at end of file
diff --git a/src/dotnet/MO.CleanCode/Settings/CleanCodeOptionsPage.cs b/src/dotnet/MO.CleanCode/Settings/CleanCodeOptionsPage.cs
index f948159..6c5d2dd 100644
--- a/src/dotnet/MO.CleanCode/Settings/CleanCodeOptionsPage.cs
+++ b/src/dotnet/MO.CleanCode/Settings/CleanCodeOptionsPage.cs
@@ -12,7 +12,12 @@
namespace CleanCode.Settings
{
- [OptionsPage(PageId, "Clean Code", typeof(SettingsThemedIcons.CleanCode), ParentId = CodeInspectionPage.PID)]
+ [OptionsPage(
+ PageId,
+ "Clean Code",
+ typeof(SettingsThemedIcons.CleanCode),
+ ParentId = CodeInspectionPage.PID
+ )]
public class CleanCodeOptionsPage : BeSimpleOptionsPage
{
private const string PageId = "CleanCodeAnalysisOptionsPage";
@@ -20,7 +25,8 @@ public class CleanCodeOptionsPage : BeSimpleOptionsPage
public CleanCodeOptionsPage(
Lifetime lifetime,
OptionsPageContext optionsPageContext,
- OptionsSettingsSmartContext optionsSettingsSmartContext)
+ OptionsSettingsSmartContext optionsSettingsSmartContext
+ )
: base(lifetime, optionsPageContext, optionsSettingsSmartContext)
{
CreateSettingsArea("Single Responsibility", CreateSingleResponsibilitySettings);
@@ -34,81 +40,125 @@ public CleanCodeOptionsPage(
private void CreateFooterArea()
{
AddSpacer();
- AddRichText(CreateItalicText(
- "Note: All references to Clean Code, including but not limited to the Clean Code icon are used with permission of Robert C. Martin (a.k.a. UncleBob)"));
+ AddRichText(
+ CreateItalicText(
+ "Note: All references to Clean Code, including but not limited to the Clean Code icon are used with permission of Robert C. Martin (a.k.a. UncleBob)"
+ )
+ );
}
- private static RichText CreateItalicText(string value) => new(value, new TextStyle(JetFontStyles.Italic));
+ private static RichText CreateItalicText(string value) =>
+ new(value, new TextStyle(JetFontStyles.Italic));
private void CreateComplexitySettingsArea()
{
AddText("Reduce complexity in individual statements.");
- AddIntOption((CleanCodeSettings s) => s.MaximumExpressionsInCondition,
- Resources.Settings.MaximumExpressionsInsideACondition);
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumExpressionsInCondition,
+ Resources.Settings.MaximumExpressionsInsideACondition
+ );
}
private void CreateLegibilitySettingsArea()
{
AddText("Names should be meaningful.");
- AddIntOption((CleanCodeSettings s) => s.MinimumMeaningfulMethodNameLength,
- Resources.Settings.MinimumMethodNameLength);
- AddStringOption((CleanCodeSettings s) => s.MeaninglessClassNameSuffixes,
- Resources.Settings.MeaninglessNameSuffixes);
+ AddIntOption(
+ (CleanCodeSettings s) => s.MinimumMeaningfulMethodNameLength,
+ Resources.Settings.MinimumMethodNameLength
+ );
+ AddStringOption(
+ (CleanCodeSettings s) => s.MeaninglessClassNameSuffixes,
+ Resources.Settings.MeaninglessNameSuffixes
+ );
}
private void CreateCouplingSettingsArea()
{
AddText("Avoid excessive coupling between classes.");
- AddIntOption((CleanCodeSettings s) => s.MaximumConstructorDependencies,
- Resources.Settings.MaximumConstructorDependencies);
- AddIntOption((CleanCodeSettings s) => s.MaximumChainedReferences,
- Resources.Settings.MaximumChainedReferences);
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumConstructorDependencies,
+ Resources.Settings.MaximumConstructorDependencies
+ );
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumChainedReferences,
+ Resources.Settings.MaximumChainedReferences
+ );
}
private void CreateSingleResponsibilitySettings()
{
- AddText("A class should only have a single responsibility. Do not do too much in a class or method.");
-
- AddIntOption((CleanCodeSettings s) => s.MaximumMethodsInClass,
- Resources.Settings.MaximumMethodsPerClass);
- AddIntOption((CleanCodeSettings s) => s.MaximumMethodParameters,
- Resources.Settings.MaximumMethodDeclarationParameters);
- AddIntOption((CleanCodeSettings s) => s.MaximumMethodStatements,
- Resources.Settings.MaximumStatementsPerMethod);
- AddIntOption((CleanCodeSettings s) => s.MaximumDeclarationsInMethod,
- Resources.Settings.DeclarationsMaximum);
- AddIntOption((CleanCodeSettings s) => s.MaximumIndentationDepth,
- Resources.Settings.MaximumLevelOfNestingInAMethod);
+ AddText(
+ "A class should only have a single responsibility. Do not do too much in a class or method."
+ );
+
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumMethodsInClass,
+ Resources.Settings.MaximumMethodsPerClass
+ );
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumPublicMethodsInClass,
+ Resources.Settings.MaximumPublicMethodsPerClass
+ );
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumMethodParameters,
+ Resources.Settings.MaximumMethodDeclarationParameters
+ );
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumMethodStatements,
+ Resources.Settings.MaximumStatementsPerMethod
+ );
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumDeclarationsInMethod,
+ Resources.Settings.DeclarationsMaximum
+ );
+ AddIntOption(
+ (CleanCodeSettings s) => s.MaximumIndentationDepth,
+ Resources.Settings.MaximumLevelOfNestingInAMethod
+ );
AddSpacer();
- AddBoolOption((CleanCodeSettings cleanCodeSettings) => cleanCodeSettings.IsFlagAnalysisEnabled,
- Resources.Settings.IsFlagAnalysisEnabled);
+ AddBoolOption(
+ (CleanCodeSettings cleanCodeSettings) => cleanCodeSettings.IsFlagAnalysisEnabled,
+ Resources.Settings.IsFlagAnalysisEnabled
+ );
}
private void CreateSettingsArea(string headerText, Action createSettingsArea)
{
AddHeader(headerText);
- using (Indent()) createSettingsArea();
+ using (Indent())
+ createSettingsArea();
}
- private void AddIntOption(Expression> expression, string description)
+ private void AddIntOption(
+ Expression> expression,
+ string description
+ )
{
var valueProperty = OptionsSettingsSmartContext.GetValueProperty(Lifetime, expression);
- AddControl(valueProperty.GetBeSpinner(Lifetime, 0, 1000).WithDescription(description, Lifetime));
+ AddControl(
+ valueProperty.GetBeSpinner(Lifetime, 0, 1000).WithDescription(description, Lifetime)
+ );
}
- private void AddStringOption(Expression> expression, string description)
+ private void AddStringOption(
+ Expression> expression,
+ string description
+ )
{
var valueProperty = OptionsSettingsSmartContext.GetValueProperty(Lifetime, expression);
AddControl(valueProperty.GetBeTextBox(Lifetime).WithDescription(description, Lifetime));
}
- private void AddBoolOption(Expression> expression, string description)
+ private void AddBoolOption(
+ Expression> expression,
+ string description
+ )
{
var valueProperty = OptionsSettingsSmartContext.GetValueProperty(Lifetime, expression);
AddControl(valueProperty.GetBeCheckBox(Lifetime, description));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/Settings/CleanCodeSettings.cs b/src/dotnet/MO.CleanCode/Settings/CleanCodeSettings.cs
index 854382f..1e07aca 100644
--- a/src/dotnet/MO.CleanCode/Settings/CleanCodeSettings.cs
+++ b/src/dotnet/MO.CleanCode/Settings/CleanCodeSettings.cs
@@ -30,7 +30,10 @@ public class CleanCodeSettings
[SettingsEntry(4, nameof(MinimumMeaningfulMethodNameLength))]
public int MinimumMeaningfulMethodNameLength { get; set; }
- [SettingsEntry("Handler,Manager,Processor,Controller,Helper", nameof(MeaninglessClassNameSuffixes))]
+ [SettingsEntry(
+ "Handler,Manager,Processor,Controller,Helper",
+ nameof(MeaninglessClassNameSuffixes)
+ )]
public string MeaninglessClassNameSuffixes { get; set; }
[SettingsEntry(1, nameof(MaximumExpressionsInCondition))]
@@ -38,5 +41,8 @@ public class CleanCodeSettings
[SettingsEntry(true, nameof(IsFlagAnalysisEnabled))]
public bool IsFlagAnalysisEnabled { get; set; }
+
+ [SettingsEntry(15, nameof(MaximumPublicMethodsInClass))]
+ public int MaximumPublicMethodsInClass { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/dotnet/MO.CleanCode/ZoneMarker.cs b/src/dotnet/MO.CleanCode/ZoneMarker.cs
index 4bafde4..a6e0a65 100644
--- a/src/dotnet/MO.CleanCode/ZoneMarker.cs
+++ b/src/dotnet/MO.CleanCode/ZoneMarker.cs
@@ -3,7 +3,5 @@
namespace CleanCode
{
[ZoneMarker]
- public class ZoneMarker
- {
- }
-}
\ No newline at end of file
+ public class ZoneMarker { }
+}
diff --git a/src/dotnet/Plugin.props b/src/dotnet/Plugin.props
index 6bbf85a..6cfb386 100644
--- a/src/dotnet/Plugin.props
+++ b/src/dotnet/Plugin.props
@@ -10,4 +10,4 @@
https://raw.github.com/MO2k4/CleanCode/master/license.txt
https://raw.githubusercontent.com/MO2k4/CleanCode/master/logo.png
-
\ No newline at end of file
+