Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: boundary conditions in checks
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Oct 1, 2024
1 parent 715bf8f commit 227a476
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/utils/checks/codeOfConduct.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default function codeOfConduct(communityMetrics) {
title: "Code of Conduct",
};

if (communityMetrics.files.code_of_conduct) {
if (communityMetrics.files?.code_of_conduct) {
response.status = "success";
response.description = `You have a CoC ${communityMetrics.files.code_of_conduct.name}.`;
response.extra = "No action required.";
}

if (!communityMetrics.files.code_of_conduct) {
if (!communityMetrics.files || !communityMetrics.files.code_of_conduct) {
response.status = "error";
response.description = "You do not have a CoC in your repo.";
response.extra =
Expand Down
4 changes: 2 additions & 2 deletions src/utils/checks/contributing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default function contributing(communityMetrics) {
title: "Contributing",
};

if (communityMetrics.files.contributing) {
if (communityMetrics.files?.contributing) {
response.status = "success";
response.description = "You have a contributing guide.";
response.extra = "No action required.";
}

if (!communityMetrics.files.contributing) {
if (!communityMetrics.files || !communityMetrics.files.contributing) {
response.status = "error";
response.description = "You do not have a contributing guide in your repo.";
response.extra =
Expand Down
3 changes: 3 additions & 0 deletions src/utils/checks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export function worstCheck(
warning = "warning",
success = "success",
) {
if (!check) {
return "unknow";
}
return check.red > 0 ? error : check.amber > 0 ? warning : success;
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/checks/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default function license(communityMetrics) {
title: "License",
};

if (communityMetrics.files.license) {
if (communityMetrics.files?.license) {
response.status = "success";
response.description = `You have a license ${communityMetrics.files.license.spdx_id}.`;
response.extra = "No action required.";
}

if (!communityMetrics.files.license) {
if (!communityMetrics.files || !communityMetrics.files.license) {
response.status = "error";
response.description = "You do not have a license in your repo.";
response.extra = "This does not mean it is moe Open Source but less.";
Expand Down
7 changes: 5 additions & 2 deletions src/utils/checks/pullRequestTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ export default function pullRequestTemplate(communityMetrics) {
title: "Pull Request template",
};

if (communityMetrics.files.pull_request_template) {
if (communityMetrics.files?.pull_request_template) {
response.status = "success";
response.description = "You have a Pull Request template.";
response.extra = "No action required.";
}

if (!communityMetrics.files.pull_request_template) {
if (
!communityMetrics.files ||
!communityMetrics.files.pull_request_template
) {
response.status = "error";
response.description =
"You do not have a pull request template in your repo.";
Expand Down
4 changes: 2 additions & 2 deletions src/utils/checks/readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default function readme(communityMetrics) {
title: "Readme",
};

if (communityMetrics.files.readme) {
if (communityMetrics.files?.readme) {
response.status = "success";
response.description = "You have a README file.";
response.extra = "No action required.";
}

if (!communityMetrics.files.readme) {
if (!communityMetrics.files || !communityMetrics.files.readme) {
response.status = "error";
response.description = "You do not have a readme.md file in your repo.";
response.extra = "This is the most important file in your project.";
Expand Down

0 comments on commit 227a476

Please sign in to comment.