Skip to content

Commit

Permalink
Add Artifact Hub badge check
Browse files Browse the repository at this point in the history
Closes #37

Signed-off-by: Sergio Castaño Arteaga <[email protected]>
  • Loading branch information
tegioz committed Feb 15, 2022
1 parent 22a9500 commit 9ea38c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions clomonitor-core/src/linter/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) static LICENSE: [&str; 2] = ["LICENSE*", "COPYING*"];
pub(crate) static FOSSA_BADGE: [&str; 1] = [r"https://app.fossa.*/api/projects/.*"];

// Best practices
pub(crate) static ARTIFACTHUB_BADGE: [&str; 1] = [r"https://artifacthub.io/badge/repository/.*"];
pub(crate) static COMMUNITY_MEETING: [&str; 3] = [
r"(?i)(community|developer|development) (call|event|meeting|session)",
r"(?i)(weekly|biweekly|monthly) meeting",
Expand Down
9 changes: 9 additions & 0 deletions clomonitor-core/src/linter/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct License {
/// BestPractices section of the report.
#[derive(Debug, Serialize, Deserialize)]
pub struct BestPractices {
pub artifacthub_badge: bool,
pub community_meeting: bool,
pub openssf_badge: bool,
}
Expand Down Expand Up @@ -135,6 +136,14 @@ fn lint_license(root: &Path) -> Result<License, Error> {
/// Run best practices checks and prepare the report's best practices section.
fn lint_best_practices(root: &Path) -> Result<BestPractices, Error> {
Ok(BestPractices {
artifacthub_badge: check::content_matches(
Globs {
root,
patterns: README,
case_sensitive: true,
},
ARTIFACTHUB_BADGE,
)?,
community_meeting: check::content_matches(
Globs {
root,
Expand Down
5 changes: 4 additions & 1 deletion clomonitor-core/src/score/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ pub(crate) fn calculate_score(report: &Report) -> Score {
}

// Best practices
if report.best_practices.artifacthub_badge {
score.best_practices += 5;
}
if report.best_practices.community_meeting {
score.best_practices += 25;
}
if report.best_practices.openssf_badge {
score.best_practices += 75;
score.best_practices += 70;
}

// Security
Expand Down
4 changes: 4 additions & 0 deletions clomonitor-linter/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ pub(crate) fn display_primary(report: &linter::primary::Report, score: &score::p
cell_entry("License / FOSSA badge"),
cell_check(report.license.fossa_badge),
])
.add_row(vec![
cell_entry("Best practices / Artifact Hub badge"),
cell_check(report.best_practices.artifacthub_badge),
])
.add_row(vec![
cell_entry("Best practices / Community meeting"),
cell_check(report.best_practices.community_meeting),
Expand Down

0 comments on commit 9ea38c8

Please sign in to comment.