Speed up Resharper Command Line - InspectCode

Hi everybody.

I want to use the R# command line tools (InspectCode) to check if devs introduced new issues to the codebase. I have setup a new build configuration in TeamCity using the "Inspections (Resharper)" and the scanning+reporting generally works. 

But I have the problem that the scanning of our whole codebase simply takes too long for us. Our 259k LOC codebase takes 20-30mins to be fully scanned by the tools. 

I would like to know how I can improve this situation. The TeamCity build step is using already caches by default but this seems not to help a lot. If I run multiple subsequent checks on the same codebase, it still takes more than 15mins to scan. 

Has anybody experience on making this kind of checks faster? 

The most reasonable thing for me is to simply scan only the files changed within the feature-branch. Existing issues on the develop branch are also a topic, but for the Pull-Request checking only the changes from the feature branch are relevant. I was hoping that the cache takes up this responsibility to only scan things that changed, but this seems not to be the case. 

From a git-perspective it should be easily possible to create a list of files that were changed in the branch. But I cannot see how I could tell InspectCode to only re-scan those and report issues for them. There is only a general exclusion of paths and porjects possible via DotSettings, nothing to "only include" certain files. 






Comment actions Permalink

Has anyone an update on this? Anybody from Jetbrains preferrable.

Even if the 20-30min are normal for InspectCode and cannot be improved with this size of solution, the scanning of only given files should be a feature.

In the R# and Rider UI you also can define some specific scopes of what to scan. A file-list scope for a command line tool sounds like a common case for me. Is this really not possible or only not documented? 

Update: I checked a bit the implementation of the InspectCode tool and it really seems there is only an "exclusion" feature and no "input file list" feature.

I see 2 workaround solutions to this problem: 

1. I wire up my own tool using the InspectCode assemblies that only scans the files of a given input list. For this I see the possibility to change the InspectCodeProductMain.CollectFilesToInspect method or the DaemonExcludedFilesManager to only include files that are in a given file list and skip all others. It might need some hacks to inject this behavior but should be do-able (technically).  

But I doubt that this is allowed by the Terms of Use and hence not a good way to go. 

2. Before invoking the scan, I generate a rewrite the .DotSettings file and add all files to the exclusion lists beside the ones I want to have scanned. Maybe some JetBrains dev can help me out here how to maybe generate such a config file that contains all excludes correctly. 

I am just not sure how I can get the correct "ID" of the file from a relative path. The setting seems to be: 

<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/={where to get this key from?}/@EntryIndexedValue">ExplicitlyExcluded</s:String>

But I fear to get this ID you need to have access to some JetBrains internals. I found some GetPersistentID() which seems related to this. But I doubt I can generate this on my own without reverse engineering the JetBrains Project model and again violate the terms of use. 


I will try to find a similar feature request in YouTrack and open a new one to have support for a custom file inclusion list. 


Comment actions Permalink

Hello Daniel,


Sorry for the delay in responding.

As the addition to the ticket you've already submitted please refer to the TeamCity request for running only incremental inspection.  - https://youtrack.jetbrains.com/issue/TW-20905

Thank you.

Comment actions Permalink

I know this is an old post, but I thought I'd add my 2 cents. We run TeamCity in a VM that only has access to an HDD. I installed an agent on one of the developer's machines that have fast SSDs and that made the builds and code inspections much faster.


Please sign in to leave a comment.