File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -349,17 +349,23 @@ type Report struct {
349349
350350// String formats the reports like SpamAssassin.
351351func (r Report ) String () string {
352- table := " pts rule name description\n "
353- table += "---- ---------------------- --------------------------------------------------\n "
352+ table := " pts rule name description\n "
353+ table += "---- -------------------------------- --------------------------------------------------\n "
354354
355355 for _ , t := range r .Table {
356356 leadingSpace := ""
357- if t .Points > 0 {
357+ // Only checking if t.Points is >=0 is not enough because sometimes
358+ // the score is -0.0 which equals to 0 even if it starts with a `-`
359+ if ! strings .HasPrefix (fmt .Sprintf ("%f" , t .Points ), "-" ) {
358360 leadingSpace = " "
359361 }
360362
361363 line := fmt .Sprintf ("%v%.1f %v" , leadingSpace , t .Points , t .Rule )
362- line += strings .Repeat (" " , 28 - len (line )) + t .Description + "\n "
364+ numberOfSpaces := 38 - len (line )
365+ if numberOfSpaces <= 0 {
366+ numberOfSpaces = 1
367+ }
368+ line += strings .Repeat (" " , numberOfSpaces ) + t .Description + "\n "
363369 table += line
364370 }
365371
You can’t perform that action at this time.
0 commit comments