Archive

Archive for the ‘Code Analysis’ Category

CodeRush Code Issues for interfaces

October 24th, 2011 Comments off

An interface is a code structure that has no concrete members and similar to an abstract class. An interface can contain public members such as methods, events, properties and indexers, but these members do not provide any functionality. Instead, they define items that must be made concrete within all classes that implement this interface. This means that an interface can be used to define what a class must do, but not how it will achieve it.

Read more…

CodeRush code issues specific to constructors

September 29th, 2011 Comments off

A constructor is a special class member that is executed when a new object is created. There are two types of constructors: instance constructors and static constructors. Instance constructors are used to create and initialize instances of classes or structures. A static constructor is used to initialize a class itself. A static constructor is called automatically to initialize the class before the first instance is created or any static members are invoked.

Read more…

Code Issues specific to partial methods

September 9th, 2011 Comments off

A partial method declaration has two parts: the declaration itself and an implementation. Both parts of a partial method can be located in a single class or in different parts of a partial class. You can use partial methods in the code and implement them later if required. If you do not supply an implementation for a partial method, its signature is removed by the compiler.

Read more…

Code Issues specific to operators

September 9th, 2011 Comments off

An operator is a member that defines the meaning of applying a particular expression operator to instances of a class or structure. Three kinds of operators can be defined: unary operators, binary operators, and conversion operators. All operators have must be declared according to the language specification.

Read more…

CodeRush code issues for overridden members

August 19th, 2011 Comments off

Overridden members (that include an ‘override‘ keyword) provide a new implementation of a virtual or an abstract member with the same signature. Compile-time errors occur when member override rules are violated. To declare an overridden member according to the language specification without violating its rules, CodeRush suggests several overridden-specific code issues.

Read more…

CodeRush code issues for abstract members

August 19th, 2011 Comments off

In addition to CodeRush code issues for virtual members, there are similar code issues for abstract members. An abstract member is similar to a virtual member but with no implementation, in other words, it has no body. In contrast to virtual members, abstract members must be implemented in a derived class if one is inherited from the class that contains an abstract member.

Read more…

CodeRush code issues for virtual members

August 19th, 2011 Comments off

As you probably know, if a member is declared with the ‘virtual‘ keyword, derived classes can override the implementation of this member. In a virtual member invocation, the run-time type of the instance for which that invocation takes place determines the actual member implementation to invoke: whether it is a base virtual member or an overridden member from a derived class. The virtual member is declared like an instance member with addition of a ‘virtual‘ keyword to its declaration.

Read more…

Code Issues – Complex Member

July 27th, 2011 Comments off

The Complex Member code issue of the smell type highlights complex members. A complex member is a member that may have too much code inside. The issue is based on a calculation of the Maintenance Complexity code metric. Maintenance complexity is a measure the structural complexity of a node (and its children), and represents how easy or challenging a method will be to understand and maintain. Scores closer to zero are simple. Small methods usually score below 150, while large/complex methods will exceed 500.

Read more…