Shannon Fang wrote:

/ ...

> In delphi, for example, such error is detected while compile, e.g. (a
> might
> not have been initialized).  I know Ruby works differently, but is there a
> way (or a project) exists, like a normal compiler, or something like FxCop
> for the C# language?

Basically, Ruby, unlike compiled languages, in many cases won't detect an
undefined entity until it encounters it at runtime. So you have several
options. You can test your program before releasing it (seems the
professional thing to do), or you can write a validator that checks for
orphan variable names. Such a validator would be fairly easy to write --
tear the source apart, filter out all the Ruby reserved words, and list
those words that appear only once -- some will be defined but unused, some
will be used but not defined.

This won't help you with scoping issues, of course, unless you traverse the
program's scopes. That begins to be more complex.

The first approach (exhaustive testing) is preferred. I would never release
a program that had not had every line executed in typical conditions.

Also, Ruby isn't that different from compiled languages. As to the latter, a
null pointer will in many cases go unnoticed until it creates a runtime
error when the code the pointer belongs to is executed, as you say, perhaps
years later.

-- 
Paul Lutus
http://www.arachnoid.com