Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Stats can report negative numbers for LOC/M

#3772

This occurs when there when there are few lines of code and many methods. It ends up averaging to 0 or 1 LOC per method , but then it does -2 presumable for the original def ... end statement. We noticed various -2 showing up in the stats for projects on Caliper. This is a simple one line patch.

Reported by Dan Mayer · January 22nd, 2010 @ 09:17 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to Low

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    Preferably upload a sample app to Github or attach one here.

    October 9th, 2010 @ 03:11 AM

  2. Vijay Dev
    Vijay Dev

    Dan,

    Am I missing anything? Shouldn't the subtraction by 2 be removed in this line before you go on to subtract by 2 in a new line?

    loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0
    

    February 6th, 2011 @ 09:43 PM

  3. Dan Mayer
    Dan Mayer

    the -2 removes the def method and end lines when there is a method as they shouldn't count. The issue is when it has 0 or 1 as a result it outputs -1 or -2.

    February 8th, 2011 @ 12:36 AM