Skip to content

Commit

Permalink
Method too long only uses declarations in body
Browse files Browse the repository at this point in the history
Fixes #12
  • Loading branch information
citizenmatt committed Sep 6, 2016
1 parent 843d323 commit 4bad621
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CleanCode/src/CleanCode.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>CleanCode.CleanCode</id>
<version>5.0.1</version>
<version>5.0.2</version>
<title>Clean Code</title>
<authors>Hadi Hariri, Matt Ellis, SuperJMN</authors>
<owners>Hadi Hariri, Matt Ellis</owners>
Expand All @@ -12,6 +12,9 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Automates some of the concepts in Uncle Bob's Clean Code book</description>
<releaseNotes>
&#8226; Method parameter and type parameter declarations mistakenly used for "method too long" check (#12)

From 5.0.1:
&#8226; Updated to ReSharper 2016.2
&#8226; Fix minor installer issue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ protected override void Run(IMethodDeclaration element, ElementProblemAnalyzerDa
var statementCount = element.CountChildren<IStatement>();
if (statementCount <= maxStatements)
{
var declarationCount = element.CountChildren<IDeclaration>();
// 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<IDeclaration>();
if (declarationCount <= maxDeclarations)
return;
}
Expand Down
4 changes: 2 additions & 2 deletions CleanCode/src/CleanCode/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
[assembly: ComVisible(false)]
[assembly: Guid("97927FF9-8C9C-4DC5-A309-29C23F41DA47")]

[assembly: AssemblyVersion("5.0.1.0")]
[assembly: AssemblyFileVersion("5.0.1.0")]
[assembly: AssemblyVersion("5.0.2.0")]
[assembly: AssemblyFileVersion("5.0.2.0")]

0 comments on commit 4bad621

Please sign in to comment.