script/overview.pl untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 100 CC 1 SCAR 6.9
CC
1
Cov
0%
print_usage
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl
2 use strict;
3 use warnings;
4
5 use base ();
6 use lib qw( ./lib );
7 use mro ();
8 use Getopt::Long;
9 use Module::Overview;
10 use Text::SimpleTable;
11
12 my $target;
13 my $help;
14
15 # Get the command line options
16 GetOptions(
17 'class=s' => \$target,
18 'help|?' => \$help,
19 ) or die "Error in command line arguments\n";
20
21 # Display usage information if help is requested or class parameter is not used.
22 if ( $help || !defined $target ) {
23 print_usage();
24 exit;
25 }
26
27 # Check if the class parameter is provided
28 eval "require $target"
29 or die "Can't load class [$target]\n";
30
31 my $mo = Module::Overview->new({
32 module_name => $target,
33 });
34 print $mo->text_simpletable;
35
36 my $table = Text::SimpleTable->new(16, 60);
37 my @fields = ();
38 # check if we use %FIELDS (see 'base') and store all keys in @fields
39 for my $isa ( reverse @{ mro::get_linear_isa( $target ) } ) {
40 my %FIELDS = %{ base::get_fields( $isa ) };
41 for my $name ( sort { $FIELDS{$a} <=> $FIELDS{$b} } keys %FIELDS ) {
42 my $no = $FIELDS{$name} || next;
43 my $fattr = base::get_attr( $isa )->[$no];
44 next if !$fattr || ( $fattr & base::INHERITED );
45 push @fields, $target ne $isa ? "$name [$isa]" : $name;
46 }
47 }
48 # check if we use %HAS (see 'UNIVERSAL::Object') and store all keys in @fields
49 my %seen;
50 for my $isa ( reverse @{ mro::get_linear_isa( $target ) } ) {
51 no strict 'refs';
52 my %HAS = %{"${isa}::HAS"};
53 for my $name ( sort keys %HAS ) {
54 next if $seen{$name}++;
55 push @fields, $target ne $isa ? "$name [$isa]" : $name;
56 }
57 }
58 $table->row( 'fields', join "\n" => @fields );
59 print $table->draw;
60
61 # Function to display usage information
62 sub print_usage {
63 print << "END_USAGE";
64 Usage: perl overview.pl [options]
65 Options:
66 --class|c <string> Input class to be processed
67 --help|? Display this help message
68 END_USAGE
69 }