Simian – code similarity comparision tool

Simian is a relatively cheap code analysis tool.  It performs simularity analysis on a whole range of files.  It is great for detecting cut and paste code that really needs to be refactored. It costs $450 per project for commercial use.  I am unsure of how the costs scale up for the enterprise version.

I found this as one of the cruise control options.

Cruise Control

A recent dotnet rocks defined Cruise Control.NET as:

10 Get and build all files under version control if any file has changed

20 GOTO 10

It is a little more powerful than that. It is a generalised scheduling program that can run tasks on a timed schedule or once a polled event occours.  I am sure that a number of major end-user applications could be built around this (scheduled reports, model integrity checks).

I now have two of the four C# projects at my work built under cruise control.

I am using PVCS which does not integrate very cleanly as it’s pcli tool is frankly a little cranky.

I have managed to put together a batch file that pulls all of the files from a project with a given promotion group. This gets called as a prebuild task.  I then use the msbuild task to build the project and the nunit task to test the project.  The build script is set to run three times per day: just before I start for the day, at lunchtime and just after I leave.  This is not quite the intended instant feedback but is a hell of a lot better than finding the build is broken when you are just about to apply an important critical fix.

The web application that can be used to monitor CC is very good.  It allows drill down to the times that individual tests took to run!  It also permits a build to be run on demand. 

The only problem I have at the moment is that the CC.net website is down so I can’t get the source…

Using a class in an exe in Boo

Boo is great for lightweight experiments:

===  myclass.boo ===

namespace foo

class myclass:
    def foo():
        print(“Hello”)

c = myclass()
c.foo()

===============

=== myclass2.boo ===

import foo from “myclass.exe”

c = myclass()
c.foo()

=================

Create the two above files.

Compile both with the booc compiler. 

 run myclass2.exe

This shows how easy it is to extend a .net app in Boo. 

Boo Podcast Client

# Podcatcher.boo
#
# (C) Chris Eyre 2007

# This is released under the BSD licence.

#
# This is the start of a podcast download script.
# I have been unable to find a suitable podcast client to replace iPodder under Ubuntu 7.4
# so there was a need to write one.
#
# Required features:
# Download a podcast to a defined directory.
# Easy reload.
# No excessive configuration.
#
# Todo:
# Scheduler
# UI
# bitorrent support.
# Currently it is portable between Mono and .Net

import System.IO
import System.Net
import System.Xml

# This reads a file structured:
# podcastlist
# podcast
# name
# url
# output
#
def ProcessFeeds(target as string):
x = XmlDocument();
x.Load(target)
for xnode as XmlNode in x.FirstChild.ChildNodes:
url = xnode.SelectSingleNode(“url”).InnerText
name = xnode.SelectSingleNode(“output”).InnerText
ProcessFeed( url, name)

#Decodes the RSS feed.
def ProcessFeed(uri as string, output as string):
w = WebClient()
x = XmlDocument()
x.Load(w.OpenRead(uri))
xnode = x.SelectSingleNode(“//channel”)
for itemnode as XmlNode in xnode.ChildNodes:
if itemnode.Name == “item”:
url = itemnode.SelectSingleNode(“enclosure/@url”).InnerText
print(url)
GetPodcast(url, output)

// Grabs the podcast if not already got.
// If the downloaded file is corrupt then delete it and it will be replaced on the next run.
def GetPodcast(podcast as string, output as string):
filename = output + “/” + NameFromUrl(podcast)
if not File.Exists(filename):
WebClient().DownloadFile(FixUrl(podcast), filename)

# another hack for .NetRocks
def FixUrl(url as string) as string:
if Path.GetExtension(url) == “.torrent”:
return Path.ChangeExtension(url,null)
else:
return url

def NameFromUrl(url as string) as string:
#HACK: This may work for dotnet rocks, but I am still working on a torrent client
if Path.GetExtension(url) == “.torrent”:
return Path.ChangeExtension(Path.GetFileName(url),null)
else:
return Path.GetFileName(url)

ProcessFeeds(“/home/chris/Projects/PodCatcher/list.xml”)
print(“done”)