diff --git a/src/utils/checks/codeOfConduct.js b/src/utils/checks/codeOfConduct.js index 47df9b3..d16b3a3 100644 --- a/src/utils/checks/codeOfConduct.js +++ b/src/utils/checks/codeOfConduct.js @@ -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 = diff --git a/src/utils/checks/contributing.js b/src/utils/checks/contributing.js index b4c8f58..0c338cd 100644 --- a/src/utils/checks/contributing.js +++ b/src/utils/checks/contributing.js @@ -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 = diff --git a/src/utils/checks/index.js b/src/utils/checks/index.js index cce04cd..a659f10 100644 --- a/src/utils/checks/index.js +++ b/src/utils/checks/index.js @@ -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; } diff --git a/src/utils/checks/license.js b/src/utils/checks/license.js index 8067a0b..ad70fc4 100644 --- a/src/utils/checks/license.js +++ b/src/utils/checks/license.js @@ -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."; diff --git a/src/utils/checks/pullRequestTemplate.js b/src/utils/checks/pullRequestTemplate.js index e9930d8..a161221 100644 --- a/src/utils/checks/pullRequestTemplate.js +++ b/src/utils/checks/pullRequestTemplate.js @@ -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."; diff --git a/src/utils/checks/readme.js b/src/utils/checks/readme.js index 3d573da..8ab64dc 100644 --- a/src/utils/checks/readme.js +++ b/src/utils/checks/readme.js @@ -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.";