linter

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Serious   Severity = "S"
	Important          = "I"
	Minor              = "M"
	Style              = "T"
)

Variables

View Source
var (
	AL1 LintingViolation = LintingViolation{
		Code:        "AL1",
		Description: "builddir can be removed as it is the default value",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "DEFAULT_BUILDDIR_VALUE",
	}

	AL3 = LintingViolation{
		Code:        "AL3",
		Description: "pkgname must not be quoted",
		Certainty:   Possible,
		Severity:    Style,
		Skip:        "PKGNAME_QUOTED",
	}

	AL4 = LintingViolation{
		Code:        "AL4",
		Description: "pkgver must not be quoted",
		Certainty:   Possible,
		Severity:    Style,
		Skip:        "PKGVER_QUOTED",
	}

	AL5 = LintingViolation{
		Code:        "AL5",
		Description: "variable set to empty string: %s",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "EMPTY_VARIABLE",
	}

	AL6 = LintingViolation{
		Code:        "AL6",
		Description: "prefix custom variable with _: %s",
		Certainty:   Certain,
		Severity:    Important,
		Skip:        "CUSTOM_VARIABLE",
	}

	AL14 = LintingViolation{
		Code:        "AL14",
		Description: "pkgname must not have uppercase characters",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "PKGNAME_HAS_UPPERCASE",
	}

	AL15 = LintingViolation{
		Code:        "AL15",
		Description: "pkgver must not have -r or _r",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "PKGVER_HAS_PKGREL",
	}

	AL25 = LintingViolation{
		Code:        "AL25",
		Description: "use $() instead of backticks",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "BACKTICKS_USAGE",
	}

	AL26 = LintingViolation{
		Code:        "AL26",
		Description: "rename _builddir to builddir",
		Certainty:   Possible,
		Severity:    Serious,
		Skip:        "_BUILDDIR_IS_SET",
	}

	AL28 = LintingViolation{
		Code:        "AL28",
		Description: "literal integers must not be quoted",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "LITERAL_INTEGER_IS_QUOTED",
	}

	AL29 = LintingViolation{
		Code:        "AL29",
		Description: "$pkgname should not be used in the source url",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "PKGNAME_USED_IN_SOURCE",
	}

	AL30 = LintingViolation{
		Code:        "AL30",
		Description: "double underscore on variables are reserved",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "DOUBLE_UNDERSCORE_IN_VARIABLE",
	}

	AL31 = LintingViolation{
		Code:        "AL31",
		Description: "variable %s must not have capital letters",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "VARIABLE_CAPITALIZED",
	}

	AL32 = LintingViolation{
		Code:        "AL32",
		Description: "unnecessary use of braces: %s",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "BRACED_VARIABLE",
	}

	AL35 = LintingViolation{
		Code:        "AL35",
		Description: "merge the contents of %s into %s and remove it",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "CPAN_VARIABLE",
	}

	AL36 = LintingViolation{
		Code:        "AL36",
		Description: "%[1]s should not be overwritten, add %[1]s to it",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "OVERWRITE_XFLAGS",
	}

	AL49 = LintingViolation{
		Code:        "AL49",
		Description: "invalid option '%s'",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "INVALID_OPTION",
	}

	AL57 = LintingViolation{
		Code:        "AL57",
		Description: "invalid arch '%s'",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "INVALID_ARCH",
	}

	AL61 = LintingViolation{
		Code:        "AL61",
		Description: "Version '%s' is not valid",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "BAD_VERSION",
	}

	AL62 = LintingViolation{
		Code:        "AL62",
		Description: "volatile source '%s'",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "VOLATILE_SOURCE",
	}
)

Functions

func Register

func Register(violation *LintingViolation, check Linter)

Types

type Certainty

type Certainty string
const (
	Certain  Certainty = "C"
	Possible           = "P"
)

type Linter

type Linter = func(*apkbuild.Apkbuild) []LintingViolation

type LintingViolation

type LintingViolation struct {
	Code        string
	Severity    Severity
	Certainty   Certainty
	Description string
	Skip        string
	Details     []string
	Filename    string
	Line        uint
	Column      uint
}
var (
	AL2 LintingViolation = LintingViolation{
		Code:        "AL2",
		Description: "return 1 is not required as set -e is used",
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "UNNECESSARY_RETURN_ONE",
	}

	AL9 LintingViolation = LintingViolation{
		Code:        "AL9",
		Description: "do not use the function keyword",
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "FUNCTION_KEYWORD",
	}

	AL10 LintingViolation = LintingViolation{
		Code:        "AL10",
		Description: "do not use space before function parenthesis",
		Certainty:   Certain,
		Severity:    Style,
		Skip:        "SPACE_BEFORE_FUNCTION_PARENTHESIS",
	}

	AL11 LintingViolation = LintingViolation{
		Code:        "AL11",
		Description: "use one space after function parenthesis",
		Certainty:   Certain,
		Severity:    Style,
		Skip:        "SPACE_AFTER_FUNCTION_PARENTHESIS",
	}

	AL12 LintingViolation = LintingViolation{
		Code:        "AL12",
		Description: "do not use a newline before function opening brace",
		Certainty:   Certain,
		Severity:    Style,
		Skip:        "NEWLINE_OPENING_BRACE",
	}

	AL13 LintingViolation = LintingViolation{
		Code:        "AL13",
		Description: `cd "builddir" can be removed in phase '%s'`,
		Certainty:   Certain,
		Severity:    Minor,
		Skip:        "SUPERFLUOUS_CD_BUILDDIR",
	}

	AL54 LintingViolation = LintingViolation{
		Code:        "AL54",
		Description: `prepare() is missing call to 'default_prepare'`,
		Certainty:   Certain,
		Severity:    Serious,
		Skip:        "MISSING_DEFAULT_PREPARE",
	}
)
var (
	AL7 LintingViolation = LintingViolation{
		Code:        "AL7",
		Description: "indent with tabs",
		Certainty:   Certain,
		Severity:    Important,
		Skip:        "INDENT_TABS",
	}

	AL8 LintingViolation = LintingViolation{
		Code:        "AL8",
		Description: "trailing whitespace",
		Certainty:   Certain,
		Severity:    Important,
		Skip:        "TRAILING_WHITESPACE",
	}
)

func Check

func Check(reader io.Reader, filename string) (violations []LintingViolation)

func CheckBackticksUsage

func CheckBackticksUsage(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckBadVersion

func CheckBadVersion(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckCpanVariables

func CheckCpanVariables(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckDefaultBuildDir

func CheckDefaultBuildDir(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckDoubleUnderOnVariables

func CheckDoubleUnderOnVariables(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckFunctionKeyword

func CheckFunctionKeyword(apkbuild *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckGlobalVariableIsNotEmpty

func CheckGlobalVariableIsNotEmpty(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckIndentTabs

func CheckIndentTabs(apkbuild *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckInvalidArch

func CheckInvalidArch(apkbuildFile *Apkbuild) (violations []LintingViolation)

func CheckInvalidOption

func CheckInvalidOption(apkbuildFile *Apkbuild) (violations []LintingViolation)

func CheckLiteralIntegerIsQuoted

func CheckLiteralIntegerIsQuoted(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckMissingDefaultPrepare

func CheckMissingDefaultPrepare(a *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckNewlineOpeningBrace

func CheckNewlineOpeningBrace(apkbuild *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckOverwriteXflags

func CheckOverwriteXflags(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckPkgNameIsNotQuoted

func CheckPkgNameIsNotQuoted(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckPkgNameUppercase

func CheckPkgNameUppercase(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckPkgRelInPkgVer

func CheckPkgRelInPkgVer(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckPkgVersionIsNotQuoted

func CheckPkgVersionIsNotQuoted(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckPkgnameInSource

func CheckPkgnameInSource(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckSpaceAfterFunctionParenthesis

func CheckSpaceAfterFunctionParenthesis(apkbuild *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckSpaceBeforeFunctionParenthesis

func CheckSpaceBeforeFunctionParenthesis(apkbuild *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckSuperfluousCDBuilddir

func CheckSuperfluousCDBuilddir(a *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckTrailingWhitespace

func CheckTrailingWhitespace(apkbuild *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckUnderscoreBuildDir

func CheckUnderscoreBuildDir(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckUnnecessaryReturnOne

func CheckUnnecessaryReturnOne(apkbuild *apkbuild.Apkbuild) (violations []LintingViolation)

func CheckUnnecessaryUseOfBraces

func CheckUnnecessaryUseOfBraces(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckUseOfCustomVariables

func CheckUseOfCustomVariables(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckVariableCapitalized

func CheckVariableCapitalized(apkbuild *Apkbuild) (violations []LintingViolation)

func CheckVolatileSource

func CheckVolatileSource(apkbuild *Apkbuild) (violations []LintingViolation)

func SortViolationsByLine

func SortViolationsByLine(vl []LintingViolation) []LintingViolation

func (LintingViolation) Instantiate

func (lv LintingViolation) Instantiate(filename string, line uint, column uint, details ...string) (instantiated LintingViolation)

func (*LintingViolation) Is

func (lv *LintingViolation) Is(other LintingViolation) bool

func (LintingViolation) String

func (lv LintingViolation) String() string

type Severity

type Severity string

Jump to

Keyboard shortcuts

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