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

Commit 227a476

Browse files
committed
fix: boundary conditions in checks
1 parent 715bf8f commit 227a476

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

src/utils/checks/codeOfConduct.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export default function codeOfConduct(communityMetrics) {
55
title: "Code of Conduct",
66
};
77

8-
if (communityMetrics.files.code_of_conduct) {
8+
if (communityMetrics.files?.code_of_conduct) {
99
response.status = "success";
1010
response.description = `You have a CoC ${communityMetrics.files.code_of_conduct.name}.`;
1111
response.extra = "No action required.";
1212
}
1313

14-
if (!communityMetrics.files.code_of_conduct) {
14+
if (!communityMetrics.files || !communityMetrics.files.code_of_conduct) {
1515
response.status = "error";
1616
response.description = "You do not have a CoC in your repo.";
1717
response.extra =

src/utils/checks/contributing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export default function contributing(communityMetrics) {
55
title: "Contributing",
66
};
77

8-
if (communityMetrics.files.contributing) {
8+
if (communityMetrics.files?.contributing) {
99
response.status = "success";
1010
response.description = "You have a contributing guide.";
1111
response.extra = "No action required.";
1212
}
1313

14-
if (!communityMetrics.files.contributing) {
14+
if (!communityMetrics.files || !communityMetrics.files.contributing) {
1515
response.status = "error";
1616
response.description = "You do not have a contributing guide in your repo.";
1717
response.extra =

src/utils/checks/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export function worstCheck(
6666
warning = "warning",
6767
success = "success",
6868
) {
69+
if (!check) {
70+
return "unknow";
71+
}
6972
return check.red > 0 ? error : check.amber > 0 ? warning : success;
7073
}
7174

src/utils/checks/license.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export default function license(communityMetrics) {
55
title: "License",
66
};
77

8-
if (communityMetrics.files.license) {
8+
if (communityMetrics.files?.license) {
99
response.status = "success";
1010
response.description = `You have a license ${communityMetrics.files.license.spdx_id}.`;
1111
response.extra = "No action required.";
1212
}
1313

14-
if (!communityMetrics.files.license) {
14+
if (!communityMetrics.files || !communityMetrics.files.license) {
1515
response.status = "error";
1616
response.description = "You do not have a license in your repo.";
1717
response.extra = "This does not mean it is moe Open Source but less.";

src/utils/checks/pullRequestTemplate.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ export default function pullRequestTemplate(communityMetrics) {
55
title: "Pull Request template",
66
};
77

8-
if (communityMetrics.files.pull_request_template) {
8+
if (communityMetrics.files?.pull_request_template) {
99
response.status = "success";
1010
response.description = "You have a Pull Request template.";
1111
response.extra = "No action required.";
1212
}
1313

14-
if (!communityMetrics.files.pull_request_template) {
14+
if (
15+
!communityMetrics.files ||
16+
!communityMetrics.files.pull_request_template
17+
) {
1518
response.status = "error";
1619
response.description =
1720
"You do not have a pull request template in your repo.";

src/utils/checks/readme.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ export default function readme(communityMetrics) {
55
title: "Readme",
66
};
77

8-
if (communityMetrics.files.readme) {
8+
if (communityMetrics.files?.readme) {
99
response.status = "success";
1010
response.description = "You have a README file.";
1111
response.extra = "No action required.";
1212
}
1313

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

0 commit comments

Comments
 (0)