| 1 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | package Open::This; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 20 | our $VERSION = '0.000035'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 20 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 9 | 20 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 10 | maybe_get_url_from_parsed_text | ||||||||||||||||||||||||||||||||||||||||||
| 11 | editor_args_from_parsed_text | ||||||||||||||||||||||||||||||||||||||||||
| 12 | parse_text | ||||||||||||||||||||||||||||||||||||||||||
| 13 | to_editor_args | ||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | ▶ | use Module::Runtime qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | is_module_name | ||||||||||||||||||||||||||||||||||||||||||
| 18 | module_notional_filename | ||||||||||||||||||||||||||||||||||||||||||
| 19 | require_module | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 20 | ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 20 | ▶ | use Module::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 20 | ▶ | use Path::Tiny qw( path ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 20 | ▶ | use Try::Tiny qw( catch try ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 20 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 69 | ▶ | sub parse_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_text: called CC=21 SCAR=30.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 69 | my $text = join q{ }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 69 | ▶ | if ($text) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 69 | $text =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # Don't fail on a trailing colon which was accidentally pasted. | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 69 | ▶ | if ($text) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 69 | $text =~ s{:\z}{}; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 69 | ▶ | return undef if !$text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 69 | my %parsed = ( original_text => $text ); | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 69 | my ( $line, $col ) = _maybe_extract_line_number( \$text ); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 69 | $parsed{line_number} = $line; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 69 | ▶ | $parsed{column_number} = $col if $col; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 69 | $parsed{sub_name} = _maybe_extract_subroutine_name( \$text ); | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 69 | _maybe_filter_text( \$text ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # Is this an actual file. | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 69 | ▶ | if ( -e path($text) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 41 | $parsed{file_name} = $text; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | elsif ( my $file_name = _maybe_git_diff_path($text) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | $parsed{file_name} = $file_name; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | elsif ( $text =~ m{^[^/]+\.go$} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | my $file_name = _find_go_files($text); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | $parsed{file_name} = $file_name if $file_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 69 | ▶ | if ( !exists $parsed{file_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 26 | ▶ | if ( my $bin = _which($text) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | $parsed{file_name} = $bin; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | $text = $bin; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 69 | $parsed{is_module_name} = is_module_name($text); | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 69 | ▶ | if ( !$parsed{file_name} && $text =~ m{\Ahttps?://}i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $parsed{"file_name"} and $text =~ m[\Ahttps?://]i
MC/DC100%2/2
not $parsed{"file_name"} and $text =~ m[\Ahttps?://]i
not $parsed{"file_name"}
$text =~ m[\Ahttps?://]i
Truth table100%3/3
not(A) and B
A= not $parsed{"file_name"}B= $text =~ m[\Ahttps?://]i
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | $parsed{file_name} = _maybe_extract_file_from_url( \$text ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 69 | ▶ | if ( !$parsed{file_name} && $parsed{is_module_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $parsed{"file_name"} and $parsed{"is_module_name"}
MC/DC100%2/2
not $parsed{"file_name"} and $parsed{"is_module_name"}
not $parsed{"file_name"}
$parsed{"is_module_name"}
Truth table100%3/3
not(A) and B
A= not $parsed{"file_name"}B= $parsed{"is_module_name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 15 | $parsed{file_name} = _maybe_find_local_file($text); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # This is a loadable module. Have this come after the local module checks | ||||||||||||||||||||||||||||||||||||||||||
| 80 | # so that we don't default to installed modules. | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 69 | ▶ | if ( !$parsed{file_name} && $parsed{is_module_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $parsed{"file_name"} and $parsed{"is_module_name"}
MC/DC100%2/2
not $parsed{"file_name"} and $parsed{"is_module_name"}
not $parsed{"file_name"}
$parsed{"is_module_name"}
Truth table100%3/3
not(A) and B
A= not $parsed{"file_name"}B= $parsed{"is_module_name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | my $found = Module::Util::find_installed($text); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | if ($found) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | $parsed{file_name} = $found; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 69 | ▶ | if ( !$parsed{line_number} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | $parsed{line_number} = _maybe_extract_line_number_via_sub_name( | ||||||||||||||||||||||||||||||||||||||||||
| 90 | $parsed{file_name}, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | $parsed{sub_name} | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 30 | ); | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 205 | my %return = map { $_ => $parsed{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 96 | 69 | ▶ | grep { defined $parsed{$_} && $parsed{$_} ne q{} } keys %parsed; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $parsed{$_} && $parsed{$_} ne ''
MC/DC100%2/2
defined $parsed{$_} && $parsed{$_} ne ''
defined $parsed{$_}
$parsed{$_} ne ''
Truth table100%3/3
A && B
A= defined $parsed{$_}B= $parsed{$_} ne ''
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 69 | ▶ | return $return{file_name} ? \%return : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub maybe_get_url_from_parsed_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maybe_get_url_from_parsed_text: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | require_module('Git::Helpers'); | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $err = $_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($err) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | warn 'This feature requires Git::Helpers to be installed'; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $parsed = shift; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return undef unless $parsed && $parsed->{file_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parsed and $parsed->{"file_name"}
MC/DC0%0/2
$parsed and $parsed->{"file_name"}
$parsed
$parsed->{"file_name"}
Truth table0%0/3
A and B
A= $parsedB= $parsed->{"file_name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $url = Git::Helpers::https_remote_url(); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return undef unless $url && $url->can('host'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$url and $url->can("host")
MC/DC0%0/2
$url and $url->can("host")
$url
$url->can("host")
Truth table0%0/3
A and B
A= $urlB= $url->can("host")
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $parsed->{remote_url} = $url; | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $clone = $url->clone; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my @parts = $clone->path_segments; | |||||||||||||||||||||||||||||||||||||||||
| 124 | push( | ||||||||||||||||||||||||||||||||||||||||||
| 125 | @parts, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 'blob', Git::Helpers::current_branch_name(), | ||||||||||||||||||||||||||||||||||||||||||
| 127 | $parsed->{file_name} | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $clone->path( join '/', @parts ); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ( $parsed->{line_number} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $clone->fragment( 'L' . $parsed->{line_number} ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $parsed->{remote_file_url} = $clone; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | return $clone; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 36 | ▶ | sub to_editor_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_editor_args: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 36 | return editor_args_from_parsed_text( parse_text(@_) ); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 45 | ▶ | sub editor_args_from_parsed_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
editor_args_from_parsed_text: called CC=16 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 45 | my $parsed = shift; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 45 | ▶ | return unless $parsed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 44 | ▶ | die '$EDITOR has not been set' unless $ENV{EDITOR}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 43 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # kate --line 11 --column 2 filename | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # idea.sh --line 11 --column 2 filename | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 43 | ▶ | if ( $ENV{EDITOR} eq 'kate' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$ENV{"EDITOR"} eq "kate" or $ENV{"EDITOR"} =~ /^(idea|rubymine|pycharm|phpstorm|webstorm|goland|rider|clion|fleet|aqua|data(grip|spell)|appcode)/i
MC/DC100%2/2
$ENV{"EDITOR"} eq "kate" or $ENV{"EDITOR"} =~ /^(idea|rubymine|pycharm|phpstorm|webstorm|goland|rider|clion|fleet|aqua|data(grip|spell)|appcode)/i
$ENV{"EDITOR"} eq "kate"
$ENV{"EDITOR"} =~ /^(idea|rubymine|pycharm|phpstorm|webstorm|goland|rider|clion|fleet|aqua|data(grip|spell)|appcode)/i
Truth table100%3/3
A or B
A= $ENV{"EDITOR"} eq "kate"B= $ENV{"EDITOR"} =~ /^(idea|rubymine|pycharm|phpstorm|webstorm|goland|rider|clion|fleet|aqua|data(grip|spell)|appcode)/i
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | || $ENV{EDITOR} | ||||||||||||||||||||||||||||||||||||||||||
| 154 | =~ /^(idea|rubymine|pycharm|phpstorm|webstorm|goland|rider|clion|fleet|aqua|data(grip|spell)|appcode)/i | ||||||||||||||||||||||||||||||||||||||||||
| 155 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | push @args, '--line', $parsed->{line_number} | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 23 | ▶ | if $parsed->{line_number}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | push @args, '--column', $parsed->{column_number} | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 23 | ▶ | if $parsed->{column_number}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | # code --goto filename:11:2 | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # codium --goto filename:11:2 | ||||||||||||||||||||||||||||||||||||||||||
| 165 | elsif ( $ENV{EDITOR} =~ /^cod(e|ium)/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 6 | my $result = $parsed->{file_name}; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | ▶ | if ( $parsed->{line_number} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | $result .= ":" . $parsed->{line_number}; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | ▶ | if ( $parsed->{column_number} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | $result .= ":" . $parsed->{column_number}; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 6 | return ( '--goto', $result ); | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | # See https://vi.stackexchange.com/questions/18499/can-i-open-a-file-at-an-arbitrary-line-and-column-via-the-command-line | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # nvim +'call cursor(11,2)' filename | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # vi +'call cursor(11,2)' filename | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # vim +'call cursor(11,2)' filename | ||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif ( exists $parsed->{column_number} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | if ( $ENV{EDITOR} eq 'nvim' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$ENV{"EDITOR"} eq "nvim" or $ENV{"EDITOR"} eq "vi" or $ENV{"EDITOR"} eq "vim"
$ENV{"EDITOR"} eq "nvim" or $ENV{"EDITOR"} eq "vi"
MC/DC33%1/3
$ENV{"EDITOR"} eq "nvim" or $ENV{"EDITOR"} eq "vi" or $ENV{"EDITOR"} eq "vim"
$ENV{"EDITOR"} eq "nvim"
$ENV{"EDITOR"} eq "vi"
$ENV{"EDITOR"} eq "vim"
Truth table50%2/4
A or B or C
A= $ENV{"EDITOR"} eq "nvim"B= $ENV{"EDITOR"} eq "vi"C= $ENV{"EDITOR"} eq "vim"
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | || $ENV{EDITOR} eq 'vi' | ||||||||||||||||||||||||||||||||||||||||||
| 183 | || $ENV{EDITOR} eq 'vim' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | @args = sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 185 | '+call cursor(%i,%i)', | ||||||||||||||||||||||||||||||||||||||||||
| 186 | $parsed->{line_number}, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | $parsed->{column_number}, | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | # nano +11,2 filename | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | ▶ | if ( $ENV{EDITOR} eq 'nano' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | @args = sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 194 | '+%i,%i', | ||||||||||||||||||||||||||||||||||||||||||
| 195 | $parsed->{line_number}, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | $parsed->{column_number}, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | # emacs +11 filename | ||||||||||||||||||||||||||||||||||||||||||
| 203 | # nano +11 filename | ||||||||||||||||||||||||||||||||||||||||||
| 204 | # nvim +11 filename | ||||||||||||||||||||||||||||||||||||||||||
| 205 | # pico +11 filename | ||||||||||||||||||||||||||||||||||||||||||
| 206 | # vi +11 filename | ||||||||||||||||||||||||||||||||||||||||||
| 207 | # vim +11 filename | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 12 | ▶ | push @args, '+' . $parsed->{line_number} if $parsed->{line_number}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 37 | return ( @args, $parsed->{file_name} ); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 80 | ▶ | sub _maybe_extract_line_number { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_extract_line_number: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 80 | my $text = shift; # scalar ref | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | # Ansible: ": line 14, column 16," | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 80 | ▶ | if ( $$text =~ s{ line (\d+).*, column (\d+).*}{} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | return $1, $2; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | # Find a line number | ||||||||||||||||||||||||||||||||||||||||||
| 223 | # lib/Foo/Bar.pm line 222. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 76 | ▶ | if ( $$text =~ s{ line (\d+).*}{} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 15 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | # mvn test output | ||||||||||||||||||||||||||||||||||||||||||
| 230 | # lib/Open/This.pm:[17,3] | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 61 | ▶ | if ( $$text =~ s{ (\w) : \[ (\d+) , (\d+) \] }{$1}x ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | return $2, $3; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | # ripgrep (rg --vimgrep) | ||||||||||||||||||||||||||||||||||||||||||
| 236 | # ./lib/Open/This.pm:17:3 | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 60 | ▶ | if ( $$text =~ s{(\w):(\d+):(\d+).*}{$1} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 11 | return $2, $3; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | # git-grep (don't match on ::) | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # lib/Open/This.pm:17 | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 49 | ▶ | if ( $$text =~ s{(\w):(\d+)\b}{$1} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 12 | return $2; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | # Github links: foo/bar.go#L100 | ||||||||||||||||||||||||||||||||||||||||||
| 248 | # Github links: foo/bar.go#L100-L110 | ||||||||||||||||||||||||||||||||||||||||||
| 249 | # In this case, discard everything after the matching line number as well. | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 37 | ▶ | if ( $$text =~ s{(\w)#L(\d+)\b.*}{$1} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 5 | return $2; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | # git-grep contextual match | ||||||||||||||||||||||||||||||||||||||||||
| 255 | # lib/Open/This.pm-17- | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 32 | ▶ | if ( $$text =~ s{(\w)-(\d+)\-{0,1}\z}{$1} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | return $2; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 30 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 69 | ▶ | sub _maybe_filter_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_filter_text: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 69 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | # Ansible: The error appears to be in '/path/to/file': | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 69 | ▶ | if ( $$text =~ m{'(.*)'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | my $maybe_file = $1; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | ▶ | $$text = $maybe_file if -e $maybe_file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 73 | ▶ | sub _maybe_extract_subroutine_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_extract_subroutine_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 73 | my $text = shift; # scalar ref | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 73 | ▶ | if ( $$text =~ s{::(\w+)\(.*\)}{} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 9 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 64 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 30 | ▶ | sub _maybe_extract_line_number_via_sub_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_extract_line_number_via_sub_name: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 30 | my $file_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 30 | my $sub_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 30 | ▶ | if ( $file_name && $sub_name && open( my $fh, '<', $file_name ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$file_name and $sub_name and open my $fh, "<", $file_name
$file_name and $sub_name
MC/DC66%2/3
$file_name and $sub_name and open my $fh, "<", $file_name
$file_name
$sub_name
open my $fh, "<", $file_name
Truth table75%3/4
A and B and C
A= $file_nameB= $sub_nameC= open my $fh, "<", $file_name
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 5 | my $line_number = 1; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 5 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 21 | ▶ | if ( $line =~ m{sub $sub_name\b} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | return $line_number; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 16 | ++$line_number; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | ▶ | sub _maybe_extract_file_from_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_extract_file_from_url: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 4 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 4 | require_module('URI'); | |||||||||||||||||||||||||||||||||||||||||
| 301 | 4 | my $uri = URI->new($$text); | |||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 4 | my @parts = $uri->path_segments; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | # Is this a GitHub(ish) URL? | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 4 | ▶ | if ( $parts[3] eq 'blob' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 4 | my $file = path( @parts[ 5 .. scalar @parts - 1 ] ); | |||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 4 | ▶ | return unless $file->is_file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 4 | $file = $file->stringify; | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 4 | ▶ | if ( $uri->fragment && $uri->fragment =~ m{\A[\d]\z} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$uri->fragment and $uri->fragment =~ /\A[\d]\z/
MC/DC0%0/2
$uri->fragment and $uri->fragment =~ /\A[\d]\z/
$uri->fragment
$uri->fragment =~ /\A[\d]\z/
Truth table66%2/3
A and B
A= $uri->fragmentB= $uri->fragment =~ /\A[\d]\z/
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $file .= ':' . $uri->fragment; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 4 | ▶ | return $file if $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 17 | ▶ | sub _maybe_find_local_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_find_local_file: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 17 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 17 | my $possible_name = module_notional_filename($text); | |||||||||||||||||||||||||||||||||||||||||
| 323 | my @dirs | ||||||||||||||||||||||||||||||||||||||||||
| 324 | = exists $ENV{OPEN_THIS_LIBS} | ||||||||||||||||||||||||||||||||||||||||||
| 325 | ? split m{,}, $ENV{OPEN_THIS_LIBS} | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 17 | ▶ | : ( 'lib', 't/lib' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 17 | for my $dir (@dirs) { | |||||||||||||||||||||||||||||||||||||||||
| 329 | 25 | my $path = path( $dir, $possible_name ); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 25 | ▶ | if ( $path->is_file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 13 | return "$path"; | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 4 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 28 | ▶ | sub _maybe_git_diff_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_git_diff_path: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 28 | my $file_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 28 | ▶ | if ( $file_name =~ m|^[ab]/(.+)$| ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 3 | ▶ | if ( -e path($1) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 27 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | # search for binaries in path | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 29 | ▶ | sub _which { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_which: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 29 | my $maybe_file = shift; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 29 | ▶ | return unless $maybe_file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 29 | require_module('File::Spec'); | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | # we only want binary names here -- no paths | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 29 | my ( $volume, $dir, $file ) = File::Spec->splitpath($maybe_file); | |||||||||||||||||||||||||||||||||||||||||
| 359 | 29 | ▶ | return if $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 20 | my @path = File::Spec->path; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 20 | for my $path (@path) { | |||||||||||||||||||||||||||||||||||||||||
| 363 | 168 | my $abs = path( $path, $file ); | |||||||||||||||||||||||||||||||||||||||||
| 364 | 168 | ▶ | return $abs->stringify if $abs->is_file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 18 | return; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | ▶ | sub _find_go_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_go_files: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 3 | ▶ | my $threshold_init = shift || 5000; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 5000
MC/DC100%1/1
shift() || 5000
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | my $file_name; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 3 | my $iter = path('.')->iterator( { recurse => 1 } ); | |||||||||||||||||||||||||||||||||||||||||
| 376 | 3 | my $threshold = $threshold_init; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 3 | ▶ | while ( my $path = $iter->() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 268 | ▶ | next unless $path->is_file; # dirs will never match anything | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 181 | ▶ | ( $threshold, $file_name ) = ( 0, "$path" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | if $path->basename eq $text; | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 181 | ▶ | last if --$threshold == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | ▶ | if ( $threshold == 0 && !$file_name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$threshold == 0 and not $file_name
MC/DC50%1/2
$threshold == 0 and not $file_name
$threshold == 0
not $file_name
Truth table66%2/3
A and not(B)
A= $threshold == 0B= not $file_name
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | warn "Only $threshold_init files searched recursively"; | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 3 | return $file_name; | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | # ABSTRACT: Try to Do the Right Thing when opening files | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | __END__ | ||||||||||||||||||||||||||||||||||||||||||