Skip to content

Commit

Permalink
feature/code-absence; fix missing filename
Browse files Browse the repository at this point in the history
  • Loading branch information
LvMalware committed Oct 30, 2024
1 parent 5ec7323 commit c3ac7a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
28 changes: 26 additions & 2 deletions lib/Zarn/Engine/Source_to_Sink.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,33 @@ package Zarn::Engine::Source_to_Sink {
'rules=s' => \$rules
);


if ($ast && $rules) {
my @absence = grep { $_->{type} && $_->{type} eq 'absence' } $rules->@*;
for my $rule (@absence) {
my $category = $rule -> {category};
my $title = $rule -> {name};
my $message = $rule -> {message};
foreach my $token ($rule -> {sample} -> @*) {
if ($ast->content() !~ m/$token/xms ) {
push @results, {
category => $category,
title => $title,
message => $message,
line_sink => 'n/a',
rowchar_sink => 'n/a',
line_source => 'n/a',
rowchar_source => 'n/a'
};
}
}
}

my @presence = grep { !($_->{type}) || $_->{type} eq 'presence' } $rules->@*;

foreach my $token (@{$ast -> find('PPI::Token')}) {
foreach my $rule (@{$rules}) {
foreach my $rule (@presence) {

my @sample = $rule -> {sample} -> @*;
my $category = $rule -> {category};
my $title = $rule -> {name};
Expand Down Expand Up @@ -63,4 +87,4 @@ package Zarn::Engine::Source_to_Sink {
}
}

1;
1;
2 changes: 1 addition & 1 deletion lib/Zarn/Helper/Rules.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ package Zarn::Helper::Rules {
}
}

1;
1;
4 changes: 2 additions & 2 deletions zarn.pl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sub main {
);

if (@analysis) {
$analysis[0]->{'file'} = $file;
map { $_->{file} = $file } @analysis;

Check failure on line 59 in zarn.pl

View workflow job for this annotation

GitHub Actions / critic

"map" used in void context at line 59, column 17. Use a "for" loop instead.
}

push @results, @analysis;
Expand Down Expand Up @@ -87,4 +87,4 @@ sub main {
return 0;
}

main();
main();

0 comments on commit c3ac7a4

Please sign in to comment.