code-analysis

custom threshold for CA1502 in visual studio 2013 ultimate

匆匆过客 提交于 2019-12-24 02:59:05
问题 This question: Custom threshold for CA1502 discusses how to set up custom thresholds for code metrics rules in code analysis. I have the same problem, but think that the old question is out of date. To repeat: In particular, we would like our Build to fail when a method has a code complexity of more than 20. Unfortunately, rule CA1502 has a threshold of 25: The rule reports a violation when the cyclomatic complexity is more than 25. Can we somehow change this? The accepted answer is to edit

CA0001: Object reference not set to an instance of an object

丶灬走出姿态 提交于 2019-12-23 21:48:13
问题 Please read the question first, before flagging it as duplicate for "Object reference not set to an instance of an object" I run a build with SonarQube. I get the following error: CA0001 : Rule=Microsoft.Design#CA1011, Target=Company.Project.Service.Report.Wrappers.Helper.ReportPrintingOrderDriver`2.#DrivePrintingProcess(Company.Product.Service.Contracts.Report.CommonExportReportRequest,Company.Project.Common.Containers.LIHierarchy`3<!0,!1,System.Int32>,Company.Project.Service.Report.Wrappers

Resolving parameter type in Roslyn

早过忘川 提交于 2019-12-23 20:29:52
问题 I'm using Roslyn to implement custom business rules. At the moment, I'm a bit stuck, I have to validate the type of a parameter when a method is being invoked. There are no issues validating that the method is being invoked or that is contains parameters. I have resolve an IdentifierNameSyntax by using GetSymbolInfo to get the symbol of my current syntax. It's not null and has the information I'm looking for such as the following : CandidateReason: None CandidateSymbols: Length = 0 Symbol:

Do you recommend Enabling Code Analysis for C/C++ on Build?

依然范特西╮ 提交于 2019-12-23 16:14:10
问题 I'm using Visual Studio 2010, and in my C++/CLI project there are two Code Analysis settings: Enable Code Analysis on Build Enable Code Analysis for C/C++ on Build My question is about the second setting. I've enabled it and it takes a long time to run and it doesn't find much. Do you recommend enabling this feature? Why? 回答1: Never did anything for me. In theory, it's supposed to help catch logical errors, but I've never found it to report anything. 回答2: The two options you specify control

Any alternative to Coverity on Jenkins? [closed]

拥有回忆 提交于 2019-12-23 12:29:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm running jenkins in my ubuntu desktop. I need a static code analysis report before pushing my c++ code. I found that coverity is expensive. I'm looking for free analysis tool. Is there any alternatives to Coverity? 回答1: I recommend SONAR (or SonarQube as it is now called) , you can use it with multipule

Collection properties should be read only - Loophole?

只愿长相守 提交于 2019-12-22 08:59:13
问题 In the process of adhering to code analysis errors, I'm changing my properties to have private setters. Then I started trying to understand why a bit more. From some research, MS says this: A writable collection property allows a user to replace the collection with a completely different collection. And the answer, here, states: Adding a public setter on a List<T> object is dangerous. But the reason why it's dangerous is not listed. And that's the part where I'm curious. If we have this

Visual Studio: Code analyzer to determine what exceptions a method can throw?

这一生的挚爱 提交于 2019-12-22 08:01:09
问题 One nice thing about Java, which was also a curse, is that you always knew what exceptions a method could throw. Is there a static code analysis tool that can determine what exceptions a method can throw? It would be great to be able to type /// and have the xml documentation declaration section fill in the <exceptions> block automatically 回答1: If you use Resharper, you can use this plugin: http://code.google.com/p/agentjohnsonplugin/ 来源: https://stackoverflow.com/questions/4359465/visual

C++/CLI: CA2123: Requires SecurityCriticalAttribute?

风格不统一 提交于 2019-12-22 05:29:21
问题 I am a little lost on erros like that: Warning 7 CA2123 : Microsoft.Security : Add the following security attribute to 'RithmicConnector::Connect(String^)' in order to match a LinkDemand on base method 'IConnector::Connect(String^)': 'SecurityCriticalAttribute'. c:\work\nettecture\tradex\source\tradex.connectivity.rithmic\rithmicconnector.cpp 52 Tradex.Connectivity.Rithmic Where do I add the SecurityCriticalAttribute? I tried on the header file - but the error does not disappear. I have one

Code Analysis CA1060 Fix

北城余情 提交于 2019-12-22 05:11:39
问题 I have the following code in my application: [DllImport("user32.dll")] private static extern int GetWindowLong(IntPtr hwnd, int index); [DllImport("user32.dll")] private static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle); [DllImport("user32.dll")] private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags); [DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wParam

C# lock and code analysis warning CA2002

六月ゝ 毕业季﹏ 提交于 2019-12-22 04:51:27
问题 In my application I have a form that starts synchronization process and for number of reasons I want to allow only one synchronization to run at a time. So I've added a static bool field to my form indicating whether sync is in progress and added a lock to set this field to true if it wasn't already set so that first thread could start synchronization but when it's running every other thread that will try to start it will terminate. My code is something like this: internal partial class