InspectCode 10.0.2 presents different results than Resharper 10.0.2 inside Visual Studio

 Hi,

I want to get exactly the same results using code analysis from InspectCode and Resharper but I get different results.

Today I have downloaded the latest versions of the Inspect Code 10.0.2 and the R# 10.0.2. I prepared some small solution with just few classes. I compared code analysis results using the following approaches:

  1. I executed inspection from Visual Studio 2015 using the following command: Resharper -> Inspect -> “Code issues in solution”. After that I saved result into xml file.
  2. I executed InspectCode with output parameter to save result in the xml file.

At the end I compared both results and everything was OK. I decided to check how it works with some bigger solution so I downloaded source code of the EntityFramework from github (master branch) and removed EntityFramework.sln.DotSettings file. I generated the results as I described with previous solution but results are completely different. I tried to execute code analysis with and without solution-wide analysis but it doesn't work. Below is the list of issues I got in each run.

  • R# with solution-wide analysis: 31106 issues found
  • R# without solution-wide analysis: 19287 issues found
  • InspectCode with solution-wide analysis: 41553 issues found
  • InspectCode without solution-wide analysis: 24272 issues found

Why doesn't it work?

6
9 comments
Avatar
Permanently deleted user

This deserves a response.

We use InspectCode as part of a SonarQube analysis run. We get a large number of issues incorrectly raised on the source code e.g. 'Using directive is not required...' warnings in large solutions is very common but removing them means the code no longer compiles.

These spurious warnings cause credibility issues when trying to get developers and management to address more important technical debt and we are seriously considering dropping InspectCode which could have a knock-on effect on our ReSharper licensing.

1
Avatar
Permanently deleted user

We are introducing R# and were happy to see that there is a TFS plugin. But as long as InspectCode returns different results that R# it is pretty useless.

0
Avatar
Permanently deleted user

Hi again,

i did now run inspectcode and R# on the same solution and i can say the output is completely different:

R# has no warnings, but a lot of hints and issues

inspect has warnings and less hints

i am only using team settings, do have only .sln.DotSettings file

update: i was able to get rid of most of the warnigs with turning off the solution-wide-inspections, but the results between the two tools still do differ

 

1
Avatar
Permanently deleted user

I came here to post about this exact same problem and found this thread. It's 2018 and I guess this still hasn't been addressed.

I even created a brand new UWP Solution, removed all the issues from code, then added this line of code:

string test = "tmp"; 

So naturally I get only these 2 issues:

  1. Use 'var' (built-in types)
  2. Local variable 'test' is only assigned but its value is never used

So then I run the CLI tool without setting a severity, and I get only the second issue, which is understandable because the default severity is Suggestion and up, so naturally the first issue (a Hint) wouldn't show up.

Ok, so let's add /s=HINT so we can see the first issue as well, and the result is the same as above, except now we have a third issue:

  • Inconsistent modifiers style: missing 'internal' modifier

Where did that come from? I have all the filters checked in Visual Studio but it never shows up, and when I go to the class with the issue, there is no indication about this issue.

We would like to use the CLI tool in our build process but the results are really inconsistent. Would it be possible to at-least use the CLI tool in Visual Studio somehow?

Thank you.

0
Avatar
Permanently deleted user

Some bugs were fixed in Resharper in 2018.x version, I suggest updating and trying again!

0

Faced with the same issue. Today update ReSharper and today install command-line tool to make experiment fair. And if I didn't trap into today's Friday release, then InspectCode and ReSharper have different results even on small projects. 

 

As Shahin Dohan kindly recommend I have JetBrains ReSharper Ultimate 2019.2.2 version.

 

Here's the project that I created for test proposes to be on the same page https://github.com/Anton-somecharsforuniqueness/CSharpProjectForInspectCode.

And here are results of the analysis.

For ReSharper:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by JetBrains ReSharper Ultimate 2019.2.2 -->
<Report ToolsVersion="192.0.20190828.114715">
<Information>
<Solution>StaticToolAnalysisTest.sln</Solution>
<InspectionScope>
<Element>Solution</Element>
</InspectionScope>
</Information>
<IssueTypes<name />
<IssueType Id="IdentifierTypo" Category="Spelling issues" CategoryId="Spelling" Description="Typo in identifier" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=IdentifierTypo" />
<IssueType Id="InconsistentNaming" Category="Constraints Violations" CategoryId="ConstraintViolation" Description="Inconsistent Naming" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=InconsistentNaming" />
<IssueType Id="NotAccessedVariable.Compiler" Category="Compiler Warnings" CategoryId="CompilerWarnings" Description="Non-accessed local variable" Severity="WARNING" />
<IssueType Id="RedundantUsingDirective" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant using directive" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantUsingDirective" />
<IssueType Id="UnusedParameter.Local" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" SubCategory="Unused parameter" Description="Unused parameter: Private accessibility" Severity="WARNING" />
</IssueTypes>
<Issues>
<Project Name="StaticToolAnalysisTest">
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="15-48" Line="2" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="50-68" Line="3" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="70-88" Line="4" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="90-119" Line="5" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="InconsistentNaming" File="StaticToolAnalysisTest\Program.cs" Offset="361-365" Line="18" Message="Name 'Main' does not match rule 'Private method name'. Suggested name is 'main'." />
<Issue TypeId="UnusedParameter.Local" File="StaticToolAnalysisTest\Program.cs" Offset="375-379" Line="18" Message="Parameter 'args' is never used" />
<Issue TypeId="NotAccessedVariable.Compiler" File="StaticToolAnalysisTest\Program.cs" Offset="412-418" Line="20" Message="Local variable 'unused' is only assigned but its value is never used" />
<Issue TypeId="IdentifierTypo" File="StaticToolAnalysisTest\Program.cs" Offset="673-681" Line="27" Message="Typo in identifier: &quot;comparre&quot;" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Properties\AssemblyInfo.cs" Offset="26-64" Line="2" Message="Using directive is not required by the code and can be safely removed" />
</Project>
</Issues>
</Report>

 

For InspectCode:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by JetBrains Inspect Code 2019.2.2 -->
<Report ToolsVersion="192.0.20190828.152317">
<Information>
<Solution>..\..\..\StaticToolAnalysisTest.sln</Solution>
<InspectionScope>
<Element>Solution</Element>
</InspectionScope>
</Information>
<IssueTypes>
<IssueType Id="ClassNeverInstantiated.Global" Category="Potential Code Quality Issues" CategoryId="CodeSmell" SubCategory="Class is never instantiated" Description="Class is never instantiated: Non-private accessibility" Severity="SUGGESTION" Global="True" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ClassNeverInstantiated.Global" />
<IssueType Id="InconsistentNaming" Category="Constraints Violations" CategoryId="ConstraintViolation" Description="Inconsistent Naming" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=InconsistentNaming" />
<IssueType Id="NotAccessedVariable.Compiler" Category="Compiler Warnings" CategoryId="CompilerWarnings" Description="Non-accessed local variable" Severity="WARNING" />
<IssueType Id="RedundantUsingDirective" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant using directive" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantUsingDirective" />
<IssueType Id="UnusedParameter.Local" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" SubCategory="Unused parameter" Description="Unused parameter: Private accessibility" Severity="WARNING" />
</IssueTypes>
<Issues>
<Project Name="StaticToolAnalysisTest">
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="15-48" Line="2" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="50-68" Line="3" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="70-88" Line="4" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Program.cs" Offset="90-119" Line="5" Message="Using directive is not required by the code and can be safely removed" />
<Issue TypeId="ClassNeverInstantiated.Global" File="StaticToolAnalysisTest\Program.cs" Offset="325-332" Line="16" Message="Class 'Program' is never instantiated" />
<Issue TypeId="InconsistentNaming" File="StaticToolAnalysisTest\Program.cs" Offset="361-365" Line="18" Message="Name 'Main' does not match rule 'Private method name'. Suggested name is 'main'." />
<Issue TypeId="UnusedParameter.Local" File="StaticToolAnalysisTest\Program.cs" Offset="375-379" Line="18" Message="Parameter 'args' is never used" />
<Issue TypeId="NotAccessedVariable.Compiler" File="StaticToolAnalysisTest\Program.cs" Offset="412-418" Line="20" Message="Local variable 'unused' is only assigned but its value is never used" />
<Issue TypeId="RedundantUsingDirective" File="StaticToolAnalysisTest\Properties\AssemblyInfo.cs" Offset="26-64" Line="2" Message="Using directive is not required by the code and can be safely removed" />
</Project>
</Issues>
</Report>

 

Flags --swea and --profile had no effect on this result.

 

Will be thankful for how to fix it suggestions.

Anton.

0

Faced with the same issue as the others here. We have tried to use R# code inspection in our CI with the command line tool.

The problem is, that we get different results if we use the command line tool or if we use the code inspection from resharper in visual studio. We did try everything mentioned on https://www.jetbrains.com/help/resharper/InspectCode.html#using-extensions-with-inspectcode but had no success.

We have now 2021, i hope there exists a solution for this problem and i would be thankful for a hint how to fix it.

Markus

0

Hello Adam,

 

There could be the following reasons for different results of InspectCode tool and ReSharper in VS:

1. Solution-wide analysis could be turned off in ReSharper, while InspectCode by default considers it as enabled.

2. Spelling issues in ReSharper not shown in InspectCode results, here's a corresponding request - https://youtrack.jetbrains.com/issue/RSRP-471421

If you experience different results in other cases please submit a request via the form at the top of the page. Please attach:

* result.xml for InspectCode* xml/screenshot for ReSharper inspection results

* dotSettings files for each layer via ReSharper | Manage Options | right-click on each layer | Export to file.

Thank you.

0

Hello Angelina

We did overlook the solution wide analysis option. After enabling it we had the same results.

Thanks for your help.

0

Please sign in to leave a comment.