Painless Code Analysis–Introduction

Lately, I have been working on a several systems to enhance the continuous integration process for builds.  One of the big areas for improvement was around the centralization of code analysis.  If done right, it is a painless process, done wrong and everyone is upset.

I will explore how to implement code analysis in several painless steps as a blueprint to get code analysis off the ground effectively.  I will start here with a summary of the posts that I will create for this topic. Read more…

Enhancing String.Format The CodeRush Way

The project I have currently has code analysis rules turned on that check to make sure the format provider is set for every String.Format statement.  For the most part, I will pass CultureInfo.InvariantCulture as the first argument to String.Format.  CodeRush allows me to do a String.Format by typing in s.f as a template in a code block. Read more…

Quick Hit – Solution Files are Sensitive

I have been creating a solution file (sln) from scratch as part of a custom MSBuild task. After hours of not understanding why it wasn’t working, I spent the time to format exactly like a sample solution. Still no luck.  In the end, I found out that I was only putting a line feed \n, instead of \r\n.

It now works fine.

The Five W’s of Writing a Code Review


The Code Review you are going to write is going to be for your colleague,  a teammate, possibly even your friend.  What ever goes into the code review should be done with sensitivity for the work the person is asking for a critique on.  Keep in mind they might do your next code review.

You also have an external audience you are doing the code review for.  There may be other reviewers.  Managers may take a look also, so be professional.  Don’t add commentary on policies, rules, or architecture that give the appearance of negativity. Read more…

Checking off on Code Reviews

In my last post Code Reviews are for wimps I discussed some of the processes and tools of a great code review.  I thought I would share how I do a code review from top to bottom to provide value.  I don’t wish to treat code reviews as a rubber stamp to the next stage.  This requires diligence, discipline and practice.  Here are some 5 questions that could be on your team checklist.  Read more…

Code Reviews are for Wimps

“Let’s get Mikey the tester, he catches everything”

“I don’t make any mistakes in my code. go check on the junior developer”

“What’s wrong with a 200 line method? I mean that’s being pretty picky don’t you think?”

“Code Review? Seriously, I have too much work to get done.  I am going to have to work till 3am just to get this feature working?”

I have rarely seen code reviews taken seriously.  Despite extensive research and findings that demonstrate the value of code reviews, very seldom is it a core competency that developers have achieved.  Most developers, PMs, and managers have heard these statements in some fashion and have done little or nothing about it. Below are my opinions on how to do a successful code review.

Read more…

Implement Code Analysis on Legacy Solutions

One of the hardest build processes to implement on existing .Net solutions is Code Analysis.  The main reason for this is the seemingly impossible task of fixing the issues that are flagged when turning analysis on for the first time.  At the end of the day, a rigorous code review and check in policies that run specified rules will be give the code a more consistent and maintainable state. Here is how I implemented Code Analysis for a Solution that has 150+ projects of varying types. Read more…