code-analysis

How to quickly inspect and analyse code for bugs (C++)

Let suppose you've just written some big code, it compiles and everything's fine...But in the end, the result is not the expected or the code simply crashes. There's some bug in the code, and you have to look for it in ALL (nearly) the lines... One way is to just put cout/printf after each loop/important function so to see how the varia...

Refactoring method with many conditional return statements

Hi, I have a method for validation that has many conditional statements. Basically it goes If Check1 = false return false If Check2 = false return false etc FxCop complains that the cyclomatic complexity is too high. I know that it is not best practice to have return statements in the middle of functions, but at the same time...

Looking for free source code browser

I use sourceInsight at work however at home I do not want to pay the price of $250 for source code browser Can you recommend a good source code browser Thanks --Jatin ...

Static code Anaylysis tool for C and C++

Possible Duplicate: What open source C++ static analysis tools are available? I am Looking for a static code analysis tool for C and C++ on a Unix platform. Can you please recommend one for me, that you have used your self or know about. ...

Do tools exist which automatically find copy-and-paste code?

Hello! Are there tools out there which could automatically find copy-and-paste code among a set of files? I was thinking of writing a script for this, which would just search for equal strings, but such script would find mostly irrelevant equalities. (Such as private final static ...). ...

Critiquing PHP-code / PerlCritic for PHP?

I'm looking for an equivalent of PerlCritic for PHP. PerlCritc is a static source code analyzer that qritiques code and warns about everything from unused variables, to unsafe ways to handle data to almost anything. Is there such a thing for PHP that could (preferably) be run outside of an IDE, so that source code analysis could be auto...

Code analysis: Global project/assembly suppression

I have several CA1704:IdentifiersShouldBeSpelledCorrectly warnings that I want to suppress. Basically they refer to the company name which is deemed to be spelled incorrectly. The company name is part of several namespaces in my project, and in order to suppress all the warnings I need to add a lot of suppressions to the GlobalSuppressio...

Is there a way to circumvent CA1726:UsePreferredTerms?

I have a problem with the code analysis rule CA1726:UsePreferredTerms. Our business domain has two crucial concepts named Case and Flag. According to CA, it's apparently a deadly sin to use these names, however I really don't care since, as I said, they are crucial concepts in our domain model. CA complains not only about the type declar...

CA: Suppress results from generated code not working in VS2010 beta 2

I'm trying to run codeanalysis on an assembly that contains an entity model (edmx file). In project properties I have checked the "Suppress results from generated code" option, but I am still getting a lot of CA errors pertaining to the auto-generated EF code. Has anyone experienced this? And is there a work-around? ...

Is CA1001: TypesThatOwnDisposableFieldsShouldBeDisposable Valid?

If I have the following code: public class Foo { public void Bar() { var someTypeWithAnEvent = new SomeTypeWithAnEvent(); using (var signal = new ManualResetEvent(false)) { someTypeWithAnEvent.Begun += (sender, e) => signal.Set(); someTypeWithAnEvent.Begin(); s...

VS2010 Custom Code Analysis Rule

I'm trying to write a custom fxcop rule for mstest projects VS2010. I'd like to debug it but keep getting an exception when it tries to load the dll for the mstest project it fails stating that it can't find referenced assembly: Microsoft.FxCop.Common.AssemblyLoadException Could not load C:\Users\Administrator\Documents\Visu...

Using FxCop to analyse only the latest changes

I am trying to get FxCop to work in a way that it analyses only the incremental changes in the exe/dll that it analyses and not the entire thing as it has anlaysed that part already.... any thoughts how one could achieve this?? ... thanks in advance... Regards, ASV... ...

Is there any way to find unreferenced code in Flex Builder?

We've got several Flex projects, one of which has just been refactored. I'm wondering if there's an easy way to tell which classes and functions (if any) aren't being used any more? I've discovered that we've definitely got some unused code, because running ASDoc on the entire project reports some compilation errors which don't get rep...

C++ function call routes resolver

Hi! I'm looking for a tool that will tell/resolve for every function all the call paths (call it "routes") to it. For example: void deeper(int *pNumber) { *pNumber++; } void gateA(int *pNumber) { deeper(pNumber); } void gateB(int *pNumber) { gateA(pNumber); } void main() { int x = 123; gateA(&x); gateB(&x); } See? I need a to...

Code Usage Analysis Tool

Is there any available (free) too to scan a bunch of C++ code and output a listing of all the classes and methods used? I don't need it to do anything advanced, or compile it, I just want any easy way to generate a basic list of classes/methods, so that I can compare that list to a similar codebase and see what is used in both. ...

Having trouble running code analysis from command prompt with msbuild

I'm using VS2010 RC while targeting .NET 3.5. I can run code analysis via Visual Studio without a problem. However, when I try to run code analysis on our CI server it isn't getting executed. When I attempt to build using msbuild 4.0 I get the following exception: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalys...

The "Why" behind PMD's rules.

Is there a good resource which describes the "why" behind PMD rule sets? PMD's site has the "what" - what each rule does - but it doesn't describe why PMD has that rule and why ignoring that rule can get you in trouble in the real world. In particular, I'm interested in knowing why PMD has the AvoidInstantiatingObjectsInLoops and OnlyOne...

CA2122: Do not indirectly expose methods with link demands. How to fix it in my code

CA2122: Do not indirectly expose methods with link demands. My code is as follows: public void LoadPage(Uri url) { webBrowser1.Url = url; //webBrowser1 is an object of WebBrowser webBrowser1.Refresh(); } Fxcop produced the warning "CA2122: Do not indirectly expose methods with link demands." Why this...

How to temporarily disable code analysis locally?

Here, we run a set of Visual Studio 2008's CA rules both locally and on the build server. In order to check in, our CA rules must match the servers policy. However, I work on a large solution with several projects. Building the project in release mode takes a long time with the CA rules enabled, but this is necessary when creating or ...

Preventing multiple reporting of the same rule violation in FxCop -- What is Id?

FxCop is currently reporting the same rule violation for a particular method -- it has two out parameters, because I want to return two values to the caller without creating a struct for it. I wonder if anonymous types would solve my problem, but I didn't know about them at the time I had written the method. Anyhow, I'm getting CheckId...