modcheck

package module
v0.0.0-...-5b363d1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

README

Modcheck

codecov

If you're reading this, then Godspeed.

Why

I made this tool to assess the state of a project's dependencies quickly. I wanted to know if any dependencies were not being used or were not being used by any other dependencies. I also wanted to know how widespread the dependencies were on GitHub, the codebase's quality, and the number of outstanding issues.

Installation

go install github.com/euanwm/modcheck/cmd/modcheck@latest

Usage

modcheck <path/to/folder/with/go.mod/file>

The modcheck tool can be used in two ways:

  • modcheck: without arguments, it will check the go.mod file in the current directory
  • modcheck /path/to/folder/: with a path to a folder containing a go.mod file, it will check that go.mod file.

Example output

modcheck example output

Development requirements

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindGitHub

func FindGitHub(packName string) string

FindGitHub searches deps.dev for a GitHub link.

func UpdateAllRepos

func UpdateAllRepos(repos []Repo)

UpdateAllRepos takes in a slice of Repo structs and updates the OSI data for each one.

Types

type PackageData

type PackageData struct {
	PackageKey PackageKey `json:"packageKey"`
	Versions   []Version  `json:"versions"`
}

Package Data is a struct that contains PackageKey and Versions for a package.

type PackageKey

type PackageKey struct {
	System string `json:"system"`
	Name   string `json:"name"`
}

PackageKey is a struct that contains ssystem and name for a package.

type Project

type Project struct {
	ProjectKey struct {
		ID string `json:"id"`
	} `json:"projectKey"`

	OpenIssuesCount string `json:"openIssuesCount"`
	StarsCount      string `json:"starsCount"`
	ForksCount      string `json:"forksCount"`
	License         string `json:"license"`
	Description     string `json:"description"`
	Homepage        string `json:"homepage"`
	Scorecard       struct {
		Date       string `json:"date"`
		Repository struct {
			Name   string `json:"name"`
			Commit string `json:"commit"`
		} `json:"repository"`
		Scorecard struct {
			Version string `json:"version"`
			Commit  string `json:"commit"`
		} `json:"scorecard"`
		Checks []struct {
			Name          string `json:"name"`
			Documentation struct {
				ShortDescription string `json:"shortDescription"`
				URL              string `json:"url"`
			} `json:"documentation"`
			Score   string   `json:"score"`
			Reason  string   `json:"reason"`
			Details []string `json:"details"`
		} `json:"checks"`
		OverallScore float32  `json:"overallScore"`
		Metadata     []string `json:"metadata"`
	} `json:"scorecard"`
}

Project is a struct that contains information about a project.

type Repo

type Repo struct {
	Link          string
	AlternateLink string
	ModVersion    string
	OSIData       Project
	VersionData   PackageData
}

Repo is a struct that contains links, versions abd other data about a repository.

func ExtractRepoInfo

func ExtractRepoInfo(filepath string) []Repo

ExtractRepoInfo takes in a filepath to a go.mod file and returns a slice of Repo structs.

func LinksToRepos

func LinksToRepos(gomod []byte) []Repo

LinksToRepos takes in a go.mod file as a byte slice and returns a slice of Repo structs.

func (*Repo) GetOSIData

func (p *Repo) GetOSIData() error

GetOSIData GET call to the OSI API "projects" endpoint. See documentation for more detail: https://docs.deps.dev/api/v3alpha/#getproject

func (*Repo) GetPackageData

func (p *Repo) GetPackageData() error

GetPackageData GET call to the OSI API "packages" endpoint.

func (*Repo) IsLatestVersion

func (p *Repo) IsLatestVersion() int

IsLatestVersion returns 1 if the package is the latest version, 0 if it is not, and -1 if there is no OSI data.

func (*Repo) LatestVersion

func (p *Repo) LatestVersion() string

LatestVersion returns the latest version of the package.

type Version

type Version struct {
	VersionKey VersionKey `json:"versionKey"`
	IsDefault  bool       `json:"isDefault"`
}

Version is a version of a module.

type VersionKey

type VersionKey struct {
	System  string `json:"system"`
	Name    string `json:"name"`
	Version string `json:"version"`
}

VersionKey is the key for a version of a module.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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