File: desc_length.pl

package info (click to toggle)
spamassassin 3.1.7-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 5,376 kB
  • ctags: 2,123
  • sloc: perl: 39,706; ansic: 3,133; sh: 1,344; sql: 170; makefile: 168
file content (96 lines) | stat: -rwxr-xr-x 2,124 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/perl -w

# This script is really sketchy and probably should be re-written to
# be less sketchy.

# These numbers for lengths are correct AFAIK for 2.60. You'll need to
# change them manually if they change.

# read descriptions into the hash descriptions
# find max length and save it into length

use strict;

my (%description, %length, %file);
my $len;

while (<>) {

  if (/^describe\s+(\S+)\s+(.*)$/) {
    $description{$1} = $2;
    $file{$1} = $ARGV;
    next;
  }

  if (/^header\s+(\S+)\s+rbleval:/) {
    $length{$1} = 45;
    next;
  }
  if (/^header\s+(\S+)\s+/) {
    $length{$1} = 50;
    next;
  }
  if (/^body\s+(\S+)\s+/) {
    $length{$1} = 44;
    next;
  }
  if (/^uri\s+(\S+)\s+/) {
    $length{$1} = 45;
    next;
  }
  if (/^rawbody\s+(\S+)\s+eval/) {
     $length{$1} = 45;
     next;
  }
  if (/^rawbody\s+(\S+)\s+/) {
     $length{$1} = 44;
     next;
  }
  if (/^full\s+(\S+)\s+eval:/) {
     $length{$1} = 50;
     next;
  }
  if (/^full\s+(\S+)\s+/) {
     $length{$1} = 44;
     next;
  }
  if (/^meta\s+(\S+)\s+/) {
     $length{$1} = 50;
     next;
  }
}

print "The following tests have names that are too long:\n";
print "-" x 22 . "\n";
foreach my $test (sort keys %length) {
  next if ($test =~ /^[T_]_/);
  print "$test\n" if length($test) > 22;
}

print "\nThe following tests have descriptions but are not defined:\n";
foreach my $test (sort keys %description) {
  next if $length{$test};
  print "$test\n";
  delete $description{$test};
}

# find descs that are too long
print "\nThe following tests have no description:\n";
foreach my $test (sort keys %length) {
  if (($test !~ /^[T_]_/) && !$description{$test}) {
    print "$test\n";
  }
  delete $length{$test} if !$description{$test};
  delete $file{$test} if !$description{$test};
}

print "\nThe following tests have descriptions that are too long:\n";
foreach my $test (sort {$file{$a} cmp $file{$b} || $a cmp $b} (keys %file)) {
  $len = length($description{$test});
  if ($len > $length{$test}) {
      print "$test: max $length{$test}, cur $len ($file{$test})\n";
      print "  $description{$test}\n";
  }
}