Does anyone know of a production worthy package commercial or OSS that can detect which lines of code have been executed or not?
We're looking around for some tools that can help us detect dead code in a production environment, running Ruby On Rails 1.8.7
-daniel
The quickest way to find dead code is to use a good IDE. Delete unused code and unneeded files. In the case of an unnecessary class, Inline Class or Collapse Hierarchy can be applied if a subclass or superclass is used. To remove unneeded parameters, use Remove Parameter.
Polyspace tools help you identify dead or unreachable code in your software. This saves time and reduces the cost associated with testing activities geared for robustness and complete code coverage.
Removing dead code that eats up runtime and memory is the easiest way to improve performance because it can be deleted and the application's functionality won't be impacted. Dead code also makes your source code unnecessarily complex. This makes the code harder to maintain and build upon.
Dead code can arise for different reasons: A developer may have forgotten to delete superfluous lines of code. Or the developer has decided not to delete because the code is mixed with functional code. Or the code is intentionally not removed, so it can be reactivated at a later time.
In Ruby 1.9.2 you could simply measure coverage without a significant impact on performance. In 1.8.7, however, this would slow down things way too much. Instead you could get an overview of what's used using perftools.rb (with the CPUPROFILE_METHODS=1 option). As far as I know it has virtually no impact on application performance and it would allow you to see what methods have been called, although you would not get any information about the different code paths (ifs and loops and whatnot).
The Code Metrics category in Ruby Toolbox mentions code coverage programs such as rcov, but that only covers code that you test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With