code-analysis

TFS 2010: how to reject gated checkin based on code duplication metric?

I'm running Microsoft Team Foundation Server 2010, and using it to build a .NET 4.0 Solution. I have enabled gated checkins, and we run our tests as part of the build, so the server rejects any checkin that causes the tests to break. However, I want to take this a step further and reject checkins that contain more than a certain prop...

__DataBind__control found by FxCop code analysis in ASP.NET

Hi, I use Visual Studio 2008 Team Suite in a website project and want to use the built-in code analysis feature (FxCop). When checking the naming rules, I get this error: CA1709: Microsoft.Naming: Korrigieren Sie die Schreibweise von "control" im Membernamen "'module_readPost_ascx.__DataBinding__control15(Object, EventArgs)'" m...

Python analyze method calls from other classes/modules

I've got a Codebase of around 5,3k LOC with around 30 different classe. The code is already very well formatted and I want to improve it further by prefixing methods that are only called in the module that were defined in with a "_", in order to indicate that. Yes it would have been a good idea to do that from the beginning on but now it...

How to properly rewrite ASSERT code to pass /analyze in msvc?

Visual Studio added code analysis (/analyze) for C/C++ in order to help identify bad code. This is quite a nice feature but when you deal with and old project you may be overwhelmed by the number of warnings. Most of the problems are generating because the old code is doing some ASSERT at the beginning of the method or function. I thin...

Need to analyze C# code to find unreferenced classes

Hi, I have legacy C# code and I am using Visual Studio 2008. I am looking for a tool, sort of code-analyzer that would say to me which class are not used and also some other useful information that might useful for code optimization. If there is exact duplicate please specify. Thank you. ...

Enforcing a coding template in the getters of a class in java

Hello, I want to make sure all getters of the classes in a certain package follow a given template. For example, all getters must be of the form: XXX getYYY(){ classLock.lock(); return YYY; finally{ classLock.unlock(); } } Basically, I want that my project will not compile/run unless all getters are of tha...

Javascript source code analysis ( specifically duplication checking )

Partial duplicate of this Notes: I already use JSLint extensively via a tool I wrote that scans in intervals my current project directory for recently updated/created .js files. It's drastically improved productivity for me and I doubt there is anything as good as JSLint for the price (it's free). That said, is there any analysis tool...

Static analysis framework for eclipse?

i just wanted to use eclipse tptp, a framework for static code analysis but the support for code analysis ended with tptp 4.5.0. 1. it seems that this version can not be integrated into the current eclipse galileo. am i right? 2. which language independant framework for eclipse would you use as an alternative for tptp static analysis w...

VS2010 / Code Analysis: Turn off a rule for a project without custom ruleset....

...any change? The scenario is this: For our company we develop a standard how code should look. This will be the MS full rule set as it looks now. For some specific projects we may want to turn off specific rules. Simply because for a specific project this is a "known exception". Example? CA1026 - while perfectly ok in most cases, th...

Filtering code elements when analyzing source code.

Hi everybody, Currently I am making a survey about source code analysis and the thing that puzzles me greatly is what is it that project managers and developers would like to filter when analyzing source code (especially when applying OOP metrics - e.g. skpping insignificant methods and classes during analysis or filtering context-bas...

C++ Code Analysis - how to add custom dictionary?

;) Yeah. I also have C++ in my solution. How do I add a custom dictionary there? There is no tool for an includes file, as well as no way to tell it the type is CustomDictionary. THe advice and approach shown in http://msdn.microsoft.com/en-us/library/bb514188(v=VS.100).aspx is not usable for C++ projects. ...

C++/CLI: CA2123: Requires SecurityCriticalAttribute?

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

VS2010 doesn't show project's CodeAnalysis page

When I try to open a project's CodeAnalysis page I get the error "An error occurred trying to load the page. Only TrueType fonts are supported. This is not a TrueType font." I also get a very simmilar ExceptionBox when I want to open the solution's propertywindow: "Only TrueType fonts are supported. This is not a TrueType font." Has...

CA2000 passing object reference to base constructor in C#

I receive a warning when I run some code through Visual Studio's Code Analysis utility which I'm not sure how to resolve. Perhaps someone here has come across a similar issue, resolved it, and is willing to share their insight. I'm programming a custom-painted cell used in a DataGridView control. The code resembles: public class DataGr...

Code Analysis for CSS, HTML and javascript

Can anybody point me in the direction of software similar to StyleCop for C# which can analyse CSS, HTML and javascript against sets of predefined rules / custom rules. For Example, css - to ensure camel case is used for class names html - to ensure inline sytles are not used javascript - not sure yet :P Ideally, tools which can ...

SQL Server - Schema/Code Analysis Rules - What would your rules include?

We're using Visual Studio Database Edition (DBPro) to manage our schema. This is a great tool that, among the many things it can do, can analyse our schema and T-SQL code based on rules (much like what FxCop does with C# code), and flag certain things as warnings and errors. Some example rules might be that every table must have a prima...

making graph/map of functions/methods calls in c# code (visual studio 2008)

I have some c# projects in visual studio 2008, and I want to get graph (map? table?) of all methods calls. I want it static, not runtime (like "call stack"); any function - who calls it, and how many times, etc. I can Find All References method after method, and copy each call to table or Graphviz file, but it will take few hours. Is th...

Cut and Paste Code Reuse - JavaScript and C#

What is the best tool(s) for tracking down "cut and paste reuse" of code in JavaScript and C#? I've inherited a really big project and the amount of code that is repeated throughout the app is 'epic'. I need some help getting handle on all the stuff that can be refactored to base classes, reusable js libs, etc... If it can plug into Vis...

FxCop CA2227 warning and ReadOnlyCollection<T>

In my VS2008 SP1, .NET 3.5 SP1 project, I have different classes that contain different properties. I use C#3.0 auto properties a lot. Some of these properties need to be collections. Since I want to make it simple, I use ReadOnlyCollection<T> for these properties. I don't want to use IEnumerable<T> since I want random access to the el...

Getters and Setters are bad OO design?

Getters and Setters are bad Briefly reading over the above article I find that getters and setters are bad OO design and should be avoided as they go against Encapsulation and Data Hiding. As this is the case how can it be avoided when creating objects and how can one model objects to take this into account. In cases where a getter or ...