App-cloc
view release on metacpan or search on metacpan
$opt_by_percent ,
$opt_xml ,
$opt_xsl ,
$opt_yaml ,
$opt_csv ,
$opt_csv_delimiter ,
$opt_fullpath ,
$opt_json ,
$opt_md ,
$opt_match_f ,
$opt_not_match_f ,
$opt_match_d ,
$opt_not_match_d ,
$opt_skip_uniqueness ,
$opt_list_file ,
$opt_help ,
$opt_skip_win_hidden ,
$opt_read_binary_files ,
$opt_sql ,
$opt_sql_append ,
$opt_sql_project ,
$opt_sql_style ,
$opt_inline ,
"xsl=s" => \$opt_xsl ,
"force_lang|force-lang=s" => \@opt_force_lang ,
"lang_no_ext|lang-no-ext=s" => \$opt_lang_no_ext ,
"yaml" => \$opt_yaml ,
"csv" => \$opt_csv ,
"csv_delimeter|csv-delimiter=s" => \$opt_csv_delimiter ,
"json" => \$opt_json ,
"md" => \$opt_md ,
"fullpath" => \$opt_fullpath ,
"match_f|match-f=s" => \$opt_match_f ,
"not_match_f|not-match-f=s" => \$opt_not_match_f ,
"match_d|match-d=s" => \$opt_match_d ,
"not_match_d|not-match-d=s" => \$opt_not_match_d ,
"list_file|list-file=s" => \$opt_list_file ,
"help" => \$opt_help ,
"skip_win_hidden|skip-win-hidden" => \$opt_skip_win_hidden ,
"read_binary_files|read-binary-files" => \$opt_read_binary_files ,
"sql=s" => \$opt_sql ,
"sql_project|sql-project=s" => \$opt_sql_project ,
"sql_append|sql-append" => \$opt_sql_append ,
"sql_style|sql-style=s" => \$opt_sql_style ,
"inline" => \$opt_inline ,
"exclude_ext|exclude-ext=s" => \$opt_exclude_ext ,
$p_ignored{$file_R} = "--include-lang=$Lang_R";
next;
}
# filter out excluded or unrecognized languages
if ($Exclude_Language{$Lang_L} or $Exclude_Language{$Lang_R}) {
$p_ignored{$file_L} = "--exclude-lang=$Lang_L";
$p_ignored{$file_R} = "--exclude-lang=$Lang_R";
next;
}
my $not_Filters_by_Language_Lang_LR = 0;
#print "file_LR = [$file_L] [$file_R]\n";
#print "Lang_LR = [$Lang_L] [$Lang_R]\n";
if (!(@{$Filters_by_Language{$Lang_L} }) or
!(@{$Filters_by_Language{$Lang_R} })) {
$not_Filters_by_Language_Lang_LR = 1;
}
if ($not_Filters_by_Language_Lang_LR) {
if (($Lang_L eq "(unknown)") or ($Lang_R eq "(unknown)")) {
$p_ignored{$fset_a}{$file_L} = "language unknown (#1)";
$p_ignored{$fset_b}{$file_R} = "language unknown (#1)";
} else {
$p_ignored{$fset_a}{$file_L} = "missing Filters_by_Language{$Lang_L}";
$p_ignored{$fset_b}{$file_R} = "missing Filters_by_Language{$Lang_R}";
}
next;
}
my @post_filter = ();
foreach my $F (@files) {
if ($opt_match_f) {
push @post_filter, $F if basename($F) =~ m{$opt_match_f};
next;
}
if ($opt_match_d) {
push @post_filter, $F if $F =~ m{$opt_match_d};
next;
}
if ($opt_not_match_d) {
if ($opt_fullpath and $F =~ m{$opt_not_match_d}) {
$Ignored{$F} = "--not-match-d=$opt_not_match_d";
next;
} elsif (basename($F) =~ m{$opt_not_match_d}) {
$Ignored{$F} = "--not-match-d (basename) =$opt_not_match_d";
next;
}
}
if ($opt_not_match_f) {
push @post_filter, $F unless basename($F) =~ m{$opt_not_match_f};
next;
}
push @post_filter, $F;
}
print "<- invoke_generator\n" if $opt_v > 2;
return @post_filter;
} # 1}}}
sub remove_duplicate_files { # {{{1
my ($fh , # in
$rh_Language , # out
my @ok = ();
#printf "TOP find_preprocessor\n";
foreach my $F_or_D (@_) { # pure file or directory name, no separators
next if $F_or_D =~ /^\.{1,2}$/; # skip . and ..
if ($Exclude_Dir{$F_or_D}) {
$Ignored{$File::Find::name} = "--exclude-dir=$Exclude_Dir{$F_or_D}";
} else {
#printf " F_or_D=%-20s File::Find::name=%s\n", $F_or_D, $File::Find::name;
if ($opt_not_match_d) {
if ($opt_fullpath and $File::Find::name =~ m{$opt_not_match_d}) {
$Ignored{$File::Find::name} = "--not-match-d=$opt_not_match_d";
} elsif (!-d $F_or_D and basename($File::Find::name) =~ m{$opt_not_match_d}) {
$Ignored{$File::Find::name} = "--not-match-d (basename) =$opt_not_match_d";
} else {
push @ok, $F_or_D;
}
} else {
push @ok, $F_or_D;
}
}
}
print "<- find_preprocessor(@ok)\n" if $opt_v > 2;
sub files { # {{{1
# invoked by File::Find's find() Populates global variable @file_list.
# See also find_preprocessor() which prunes undesired directories.
my $Dir = fastcwd(); # not $File::Find::dir which just gives relative path
if ($opt_fullpath) {
# look at as much of the path as is known
if ($opt_match_f ) {
return unless $File::Find::name =~ m{$opt_match_f};
}
if ($opt_not_match_f) {
return if $File::Find::name =~ m{$opt_not_match_f};
}
} else {
# only look at the basename
if ($opt_match_f ) { return unless /$opt_match_f/; }
if ($opt_not_match_f) { return if /$opt_not_match_f/; }
}
if ($opt_match_d ) { return unless $Dir =~ m{$opt_match_d} }
my $nBytes = -s $_ ;
if (!$nBytes) {
$Ignored{$File::Find::name} = 'zero sized file';
printf "files(%s) zero size\n", $File::Find::name if $opt_v > 5;
}
return unless $nBytes ; # attempting other tests w/pipe or socket will hang
if ($nBytes > $opt_max_file_size*1024**2) {
( run in 0.225 second using v1.01-cache-2.11-cpan-cc502c75498 )