Skip to content

Commit 861262b

Browse files
authored
Add github.com/breml/bidichk linter (#2330)
1 parent 77d4115 commit 861262b

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/bkielbasa/cyclop v1.2.0
1616
github.com/blizzy78/varnamelen v0.3.0
1717
github.com/bombsimon/wsl/v3 v3.3.0
18+
github.com/breml/bidichk v0.1.1
1819
github.com/butuzov/ireturn v0.1.1
1920
github.com/charithe/durationcheck v0.0.9
2021
github.com/daixiang0/gci v0.2.9

go.sum

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/bidichk.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package golinters
2+
3+
import (
4+
"github.com/breml/bidichk/pkg/bidichk"
5+
"golang.org/x/tools/go/analysis"
6+
7+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8+
)
9+
10+
func NewBiDiChkFuncName() *goanalysis.Linter {
11+
return goanalysis.NewLinter(
12+
"bidichk",
13+
"Checks for dangerous unicode character sequences",
14+
[]*analysis.Analyzer{bidichk.Analyzer},
15+
nil,
16+
).WithLoadMode(goanalysis.LoadModeSyntax)
17+
}

pkg/lint/lintersdb/manager.go

+4
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
542542
WithPresets(linter.PresetStyle).
543543
WithLoadForGoAnalysis().
544544
WithURL("https://github.com/blizzy78/varnamelen"),
545+
linter.NewConfig(golinters.NewBiDiChkFuncName()).
546+
WithSince("1.43.0").
547+
WithPresets(linter.PresetBugs).
548+
WithURL("https://github.com/breml/bidichk"),
545549

546550
// nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives
547551
linter.NewConfig(golinters.NewNoLintLint()).

test/testdata/bidichk.go

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//args: -Ebidichk
2+
package testdata
3+
4+
import "fmt"
5+
6+
func main() {
7+
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"
8+
}

0 commit comments

Comments
 (0)