repometrics

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 12 Imported by: 0

README

repometrics

Package repometrics provides functionality to gather and analyze metrics from software repositories.

It collects various metrics and information including:

  • Basic repository information (name, URL, creation date)
  • Project status (CNCF status, Kubernetes SIG status)
  • License information
  • Version information
  • Security vulnerabilities
  • Activity metrics:
    • Commit frequency
    • Release frequency
    • Contributor statistics
    • Issue and PR activity
    • Community engagement (stars, forks)

Documentation

Overview

Package repometrics provides functionality to analyze software repositories and gather metrics about their health, activity, and security status.

It can collect information from multiple sources including GitHub repositories, CNCF landscape data, and security vulnerability scans. The collected metrics provide insights into project activity, community engagement, release patterns, and security status.

The package is particularly useful for: - Evaluating project health and maintenance status - Understanding community engagement and contribution patterns - Monitoring security vulnerabilities - Analyzing release frequency and version management - Tracking project growth and adoption metrics

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contributor

type Contributor struct {
	Name    string `json:"name"`
	Commits int    `json:"commits"`
}

type Metrics

type Metrics struct {
	Name                string                `json:"name"`
	Type                RepoType              `json:"type"`
	URL                 string                `json:"url"`
	CreatedAt           *time.Time            `json:"created_at"`
	IsCNCF              bool                  `json:"is_cncf"`
	CNCFStatus          string                `json:"cncf_status"`
	IsKubernetesSIG     bool                  `json:"is_kubernetes_sig"`
	BackingOrganization string                `json:"backing_organization"`
	License             string                `json:"license"`
	CurrentVersion      string                `json:"current_version"`
	Vulnerabilities     []types.Vulnerability `json:"vulnerabilities"`
	Stats               *Stats                `json:"stats"`
}

Metrics represents the metrics of a repository

func New

func New(t RepoType) (*Metrics, error)

New creates a new Metrics

func (*Metrics) ProjectAge

func (m *Metrics) ProjectAge() time.Duration

ProjectAge returns the age of the project

func (*Metrics) ScanVulnerabilities

func (m *Metrics) ScanVulnerabilities(s Scanner) error

func (*Metrics) UpdateCNCFStatus

func (m *Metrics) UpdateCNCFStatus(opts UpdateCNCFOptions) error

UpdateCNCFStatus updates the CNCF status of the repository

func (*Metrics) UpdateGitHub

func (m *Metrics) UpdateGitHub(ctx context.Context, client *github.Client, owner, repository string) error

UpdateGitHub updates the metrics using data from a GitHub repository

type ReleaseMetrics

type ReleaseMetrics struct {
	PerDay   float64
	PerWeek  float64
	PerMonth float64
	PerYear  float64
}

func CalculateReleaseMetrics

func CalculateReleaseMetrics(firstRelease, lastRelease *time.Time, totalReleases int) ReleaseMetrics

CalculateReleaseMetrics calculates the release metrics based on the first and last release dates and the total number of releases.

type RepoType

type RepoType string
const (
	RepoTypeGitHub RepoType = "github"
)

func (RepoType) IsValid

func (t RepoType) IsValid() bool

type Scanner

type Scanner interface {
	Scan() ([]types.Vulnerability, error)
}

type Stats

type Stats struct {
	LastCommit        *time.Time    `json:"last_commit"`
	CommitsPerMonth6M int           `json:"commits_per_month_6m"`
	Contributors1Y    int           `json:"contributors_1y"`
	FirstRelease      *time.Time    `json:"first_release"`
	LastRelease       *time.Time    `json:"last_release"`
	Releases          int           `json:"releases"`
	ReleasesPerDay    float64       `json:"releases_per_day"`
	ReleasesPerWeek   float64       `json:"releases_per_week"`
	ReleasesPerMonth  float64       `json:"releases_per_month"`
	ReleasesPerYear   float64       `json:"releases_per_year"`
	OpenIssuesNow     int           `json:"open_issues_now"`
	OpenedIssues6M    int           `json:"opened_issues_6m"`
	ClosedIssues6M    int           `json:"closed_issues_6m"`
	OpenedPRs6M       int           `json:"opened_prs_6m"`
	ClosedPRs6M       int           `json:"closed_prs_6m"`
	Likes             int           `json:"likes"`
	Forks             int           `json:"forks"`
	TopCommitters     []Contributor `json:"top_committers"`
	TopCommitters1Y   []Contributor `json:"top_committers_1y"`
}

func NewStats

func NewStats() *Stats

type UpdateCNCFOptions

type UpdateCNCFOptions struct {
	Client             cncf.HTTPClient
	ProjectName        string
	ProjectRepoURL     string
	ProjectHomepageURL string
}

UpdateCNCFOptions represents the options for updating the CNCF status of a

ProjectName, ProjectRepoURL, and ProjectHomepageURL are used to find the project.

The order of precedence is: 1. ProjectRepoURL 2. ProjectHomepageURL 3. ProjectName (case-insensitive)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL