asasalint

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 12 Imported by: 5

README

asasalint

Golang linter, lint that pass any slice as any in variadic function

Install

go install github.com/alingse/asasalint/cmd/asasalint@latest

Usage

asasalint ./...

ignore some func that was by desgin

asasalint -e append,Append ./...

Why

two kind of unexpected usage, and go build success

package main

import "fmt"

func A(args ...any) int {
    return len(args)
}

func B(args ...any) int {
    return A(args)
}

func main() {

    // 1
    fmt.Println(B(1, 2, 3, 4))
}
package main

import "fmt"

func errMsg(msg string, args ...any) string {
    return fmt.Sprintf(msg, args...)
}

func Err(msg string, args ...any) string {
    return errMsg(msg, args)
}

func main() {

    // p1 [hello world] p2 %!s(MISSING)
    fmt.Println(Err("p1 %s p2 %s", "hello", "world"))
}

TODO

  1. add to golangci-lint
  2. given a SuggestEdition
  3. add append to default exclude ?
  4. ingore pattern fn(a, b, []any{1,2,3}) , because []any{1,2,3} is most likely by design

Documentation

Index

Constants

View Source
const BuiltinExclusions = `^(fmt|log|logger|t|)\.(Print|Fprint|Sprint|Fatal|Panic|Error|Warn|Warning|Info|Debug|Log)(|f|ln)$`

Variables

This section is empty.

Functions

func NewAnalyzer added in v0.0.3

func NewAnalyzer(setting LinterSetting) (*analysis.Analyzer, error)

Types

type LinterSetting added in v0.0.5

type LinterSetting struct {
	Exclude             []string
	NoBuiltinExclusions bool
	IgnoreTest          bool
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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