Skip to content

Commit

Permalink
better code composition
Browse files Browse the repository at this point in the history
  • Loading branch information
htrgouvea committed Nov 28, 2024
1 parent 95cbd28 commit ca1e3af
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lib/Sentra/Engine/SearchFiles.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ package Sentra::Engine::SearchFiles {
'X-GitHub-Api-Version' => '2022-11-28'
};

my $output = '';

my $output = '';
my $repo_url = "https://api.github.com/orgs/$org/repos?per_page=$per_page";
my $repo_tx = $userAgent -> get($repo_url => $headers);

my $res = $repo_tx->result or return "Error fetching repositories: " . $repo_tx->error->{message} . "\n";
$res->is_success or return "Error fetching repositories: " . $res->message . "\n";
my $repo_tx = $userAgent -> get($repo_url => $headers);

my $repos = $res->json;
my $res = $repo_tx -> result();

if ($res -> is_success) {
my $repos = $res -> json();

for my $repo (@$repos) {
next if $repo -> {archived};

my $full_name = "$org/$repo->{name}";

my $dependabot_url = "https://api.github.com/repos/$full_name/contents/.github/dependabot.yaml";
my $dependabot_tx = $userAgent->get($dependabot_url => $headers);

if ($dependabot_tx->result->code == 404) {
$output .= "The dependabot.yml file was not found in this repository: https://github.com/$full_name\n";
}
for my $repo (@$repos) {
next if $repo -> {archived};

my $full_name = "$org/$repo->{name}";

my $dependabot_url = "https://api.github.com/repos/$full_name/contents/.github/dependabot.yaml";
my $dependabot_tx = $userAgent -> get($dependabot_url => $headers);

if ($dependabot_tx -> result -> code == 404) {
$output .= "The dependabot.yml file was not found in this repository: https://github.com/$full_name\n";
}
}
}

return $output || "No issues found.";
Expand Down

0 comments on commit ca1e3af

Please sign in to comment.