Add github.com/breml/bidichk linter (#2330)
Some checks failed
Extra / Vulnerability scanner (push) Has been cancelled
CI / go-mod (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
Release a tag / release (push) Has been cancelled
CI / tests-on-windows (push) Has been cancelled
CI / tests-on-macos (push) Has been cancelled
CI / tests-on-unix (1.16) (push) Has been cancelled
CI / tests-on-unix (1.17) (push) Has been cancelled
CI / check_generated (push) Has been cancelled
Release a tag / docker-release (map[Dockerfile:build/Dockerfile.alpine]) (push) Has been cancelled
Release a tag / docker-release (map[Dockerfile:build/Dockerfile]) (push) Has been cancelled

This commit is contained in:
Lucas Bremgartner 2021-11-02 21:54:42 +01:00 committed by GitHub
parent 77d4115b0f
commit 861262b71f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 0 deletions

1
go.mod
View File

@ -15,6 +15,7 @@ require (
github.com/bkielbasa/cyclop v1.2.0
github.com/blizzy78/varnamelen v0.3.0
github.com/bombsimon/wsl/v3 v3.3.0
github.com/breml/bidichk v0.1.1
github.com/butuzov/ireturn v0.1.1
github.com/charithe/durationcheck v0.0.9
github.com/daixiang0/gci v0.2.9

2
go.sum generated
View File

@ -106,6 +106,8 @@ github.com/blizzy78/varnamelen v0.3.0 h1:80mYO7Y5ppeEefg1Jzu+NBg16iwToOQVnDnNIoW
github.com/blizzy78/varnamelen v0.3.0/go.mod h1:hbwRdBvoBqxk34XyQ6HA0UH3G0/1TKuv5AC4eaBT0Ec=
github.com/bombsimon/wsl/v3 v3.3.0 h1:Mka/+kRLoQJq7g2rggtgQsjuI/K5Efd87WX96EWFxjM=
github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc=
github.com/breml/bidichk v0.1.1 h1:Qpy8Rmgos9qdJxhka0K7ADEE5bQZX9PQUthkgggHpFM=
github.com/breml/bidichk v0.1.1/go.mod h1:zbfeitpevDUGI7V91Uzzuwrn4Vls8MoBMrwtt78jmso=
github.com/butuzov/ireturn v0.1.1 h1:QvrO2QF2+/Cx1WA/vETCIYBKtRjc30vesdoPUNo1EbY=
github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

17
pkg/golinters/bidichk.go Normal file
View File

@ -0,0 +1,17 @@
package golinters
import (
"github.com/breml/bidichk/pkg/bidichk"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)
func NewBiDiChkFuncName() *goanalysis.Linter {
return goanalysis.NewLinter(
"bidichk",
"Checks for dangerous unicode character sequences",
[]*analysis.Analyzer{bidichk.Analyzer},
nil,
).WithLoadMode(goanalysis.LoadModeSyntax)
}

View File

@ -542,6 +542,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/blizzy78/varnamelen"),
linter.NewConfig(golinters.NewBiDiChkFuncName()).
WithSince("1.43.0").
WithPresets(linter.PresetBugs).
WithURL("https://github.com/breml/bidichk"),
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
linter.NewConfig(golinters.NewNoLintLint()).

8
test/testdata/bidichk.go vendored Normal file
View File

@ -0,0 +1,8 @@
//args: -Ebidichk
package testdata
import "fmt"
func main() {
fmt.Println("LEFT-TO-RIGHT-OVERRIDE: '', it is between the single quotes, but it is not visible with a regular editor") // ERROR "found dangerous unicode character sequence LEFT-TO-RIGHT-OVERRIDE"
}