code-analysis

VS2010 Code Analysis, any way to automatically fix certain warnings?

I must say I really like the new code analysis with VS 2010, I have a lot of areas in my code where I am not using CultureInfo.InvariantCultureand code analysis is warming me about this. I am pretty sure I want to use CultureInfo.InvariantCulturewhere ever code analysis has detected it is missing on Convert.ToString operations. Is th...

CA1034: Nested types should not be visible

Here's an explanation of the rule that that I am trying to understand. Here's the simplified code that the Code Analyzer was complaining about: Public Class CustomerSpeed Public Enum ProfitTypeEnum As Integer NotSpecified = 0 FlatAmount = 1 PercentOfProfit = 2 End Enum Private _ProfitTypeEnum As Pro...

[GeneratedCodeAttribute] Attribute Missing from Generated WinForm Code

The method definitions in any winform's *.Designer.cs file created by Visual Studio are not decorated with [GeneratedCodeAttribute] attributes. As a result, the generated code is analyzed when I run code metrics or code analysis. Does any one know why the attribute is not provided (it is generated code after all)? Would it be safe to add...

Listing C/C++ functions (Code analysis in Unix)

Whether we're maintaining unfamiliar code or checking out the implementation details of an Apache module it can help if we can quickly traverse the code and build up an overview of what we're looking at. Grep serves most of my daily needs but there are some cases where it just wont do. Here's a common example of how it can help. To find...

/analyze flag in Visual Studio 2010 Professional

Running Visual Studio 2008 Professional it is possible to enable static code analysis using the /analyze flag (even though this is not supported for the Professional version according to the documentation). In Visual Studio 2010 Professional this no longer works. Instead there is a default /analyze- flag added (one I can't find a GUI se...

How to get all usages/references of control in DotNetNuke?

Sorry for lame question but I am literally starting with DNN. When you are in admin/design mode you can list all modules used, and when you click on module at the end you will see the list of controls used in this module with info about filename of the source. The problem I have is in reverse -- I already know the filename with source,...

SVN Attribution Plugin?

I'm using SVN with Google Code Project Hosting for a school project. As the codebase increases in size, I often find myself wondering questions like: "who originally checked in this line of code?" "who has been checking in the most code recently?" "Of the final product, how much of it was written by Person X?" "Which coder is best at a...

Enable code analysis in Visual Studio 2010 Professional

Hi I can see that we can enable code analysis in Visual Studio Team Systems. But i am using Visual Studio 2010 Professional. Do we have any option to enable code analysis in this version or can we integrate any tools like FxCop and StyleCop with this version for validating the code. I am expecting my code should analysied the momen...

Tools for finding possible problems in code

Is there any tools, that find and report possible problems (deadlocks/null pointers/etc) in a java code? Maybe an Eclipse plugin? ...

Visual Studio Code Analysis - Does Microsoft follow it themselves?

Did a quick search but could not find anything about this. I guess all of you know that the Visual Studio Code Analysis is quite nitpicking and gives warnings about a lot of things. Does anybody know how well Microsoft follow this themselves..? That is, if I were to run a code analysis on their assemblies, would the warnings be none or ...

Should I suppress CA1062: Validate arguments of public methods?

I've recently upgraded my project to Visual Studio 2010 from Visual Studio 2008. In Visual Studio 2008, this Code Analysis rule doesn't exist. Now I'm not sure if I should use this rule or not. I'm building an open source library so it seems important to keep people safe from doing mistakes. However, if all I'm going to do is throw Ar...

Why do I get CA1806 when I catch exception in C++/CLI?

I've recently upgraded my project from Visual Studio 2008 to Visual Studio 2010. By enabling Code Analysis and compiling in Release, I'm getting warning CA1806: Do not ignore method results. I've managed to reduce the code that produces the warning to this code: .h file: public ref class Foo { public: void Bar(); }; .cpp file: ...

Should I suppress CA2204: Literals should be spelled correctly?

I've recently upgraded my project from Visual Studio 2008 to Visual Studio 2010. By enabling Code Analysis, I'm getting a lot of warnings resulted in rule CA2204: Literals should be spelled correctly. EDIT: Let's say I have a method called GetResult(), and in it I want to throw an exception for some reason. I want the exception to say...

Why do I get CA1811 when I call a private method from a public method in C++/CLI?

I've recently upgraded my project from Visual Studio 2008 to Visual Studio 2010. By enabling Code Analysis and building on Release, I'm getting warning CA1811: Avoid uncalled private code. I've managed to reduce the code to this: .h file: public ref class Foo { public: virtual System::String^ ToString() override; private: st...

Why do I get Code Analysis CA1062 on an out parameter in this code?

I have a very simple code (simplified from the original code - so I know it's not a very clever code) that when I compile in Visual Studio 2010 with Code Analysis gives me warning CA1062: Validate arguments of public methods. public class Foo { protected static void Bar(out int[] x) { x = new int[1]; for (int i =...

Can PMD be customized to fully support a new language?

Can PMD be customized to fully support a new language, in a reasonable amount of time. I mean I know that technically almost anything can be done, but im wondering if this can be done in a reasonable amount of time? E.g. < 2 weeks This page mentions how to write a CPD parser http://pmd.sourceforge.net/cpd-parser-howto.html But is this...

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

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? ...

Disable Code analysis warnings .NET

In visual studios i can run code analysis on my .NET project. I am running basic correctness and have 85 warnings. Which is a little much. Also majority of them are in external code. How do i disable specific warnings so i can focus on the more important warnings? I tried the below but it does not recognize code analysis warnings. (I fi...

Where does that randomness come from ?

I'm working on a data mining research project and use code from a big svn. Apparently one of the methods I use from that svn uses randomness somewhere without asking for a seed, which makes 2 calls to my program return different results. That's annoying for what I want to do, so I'm trying to locate that "uncontrolled" randomness. Sinc...

Can one make Code Analysis understand Code Contracts?

Hi all, When using Code Analysis and Code Contracts in combination, I get a lot of warnings like warning : CA1062 : Microsoft.Design : In externally visible method 'Foo.Bar(Log)', validate parameter 'log' before using it. In Foo.Bar, I have a Contract that validates 'log'. public Bar(Log log){ Contract.Requires(log != null); lo...