Skip to content

Commit 4950169

Browse files
authored
bump bidichk from v0.1.1 to v0.2.0
1 parent 1b53520 commit 4950169

File tree

6 files changed

+76
-7
lines changed

6 files changed

+76
-7
lines changed

.golangci.example.yml

+12
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ output:
8282

8383
# all available settings of specific linters
8484
linters-settings:
85+
bidichk:
86+
# The following configurations check for all mentioned invisible unicode
87+
# runes. It can be omitted because all runes are enabled by default.
88+
left-to-right-embedding: true
89+
right-to-left-embedding: true
90+
pop-directional-formatting: true
91+
left-to-right-override: true
92+
right-to-left-override: true
93+
left-to-right-isolate: true
94+
right-to-left-isolate: true
95+
first-strong-isolate: true
96+
pop-directional-isolate: true
8597

8698
cyclop:
8799
# the maximal code complexity to report

go.mod

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

go.sum

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

pkg/config/linters_settings.go

+13
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ var defaultLintersSettings = LintersSettings{
8383
}
8484

8585
type LintersSettings struct {
86+
BiDiChk BiDiChkSettings
8687
Cyclop Cyclop
8788
Depguard DepGuardSettings
8889
Dogsled DogsledSettings
@@ -146,6 +147,18 @@ type LintersSettings struct {
146147
Custom map[string]CustomLinterSettings
147148
}
148149

150+
type BiDiChkSettings struct {
151+
LeftToRightEmbedding bool `mapstructure:"left-to-right-embedding"`
152+
RightToLeftEmbedding bool `mapstructure:"right-to-left-embedding"`
153+
PopDirectionalFormatting bool `mapstructure:"pop-directional-formatting"`
154+
LeftToRightOverride bool `mapstructure:"left-to-right-override"`
155+
RightToLeftOverride bool `mapstructure:"right-to-left-override"`
156+
LeftToRightIsolate bool `mapstructure:"left-to-right-isolate"`
157+
RightToLeftIsolate bool `mapstructure:"right-to-left-isolate"`
158+
FirstStrongIsolate bool `mapstructure:"first-strong-isolate"`
159+
PopDirectionalIsolate bool `mapstructure:"pop-directional-isolate"`
160+
}
161+
149162
type Cyclop struct {
150163
MaxComplexity int `mapstructure:"max-complexity"`
151164
PackageAverage float64 `mapstructure:"package-average"`

pkg/golinters/bidichk.go

+45-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,59 @@
11
package golinters
22

33
import (
4+
"strings"
5+
46
"github.com/breml/bidichk/pkg/bidichk"
57
"golang.org/x/tools/go/analysis"
68

9+
"github.com/golangci/golangci-lint/pkg/config"
710
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
811
)
912

10-
func NewBiDiChkFuncName() *goanalysis.Linter {
13+
func NewBiDiChkFuncName(cfg *config.BiDiChkSettings) *goanalysis.Linter {
14+
a := bidichk.NewAnalyzer()
15+
16+
cfgMap := map[string]map[string]interface{}{}
17+
if cfg != nil {
18+
var opts []string
19+
20+
if cfg.LeftToRightEmbedding {
21+
opts = append(opts, "LEFT-TO-RIGHT-EMBEDDING")
22+
}
23+
if cfg.RightToLeftEmbedding {
24+
opts = append(opts, "RIGHT-TO-LEFT-EMBEDDING")
25+
}
26+
if cfg.PopDirectionalFormatting {
27+
opts = append(opts, "POP-DIRECTIONAL-FORMATTING")
28+
}
29+
if cfg.LeftToRightOverride {
30+
opts = append(opts, "LEFT-TO-RIGHT-OVERRIDE")
31+
}
32+
if cfg.RightToLeftOverride {
33+
opts = append(opts, "RIGHT-TO-LEFT-OVERRIDE")
34+
}
35+
if cfg.LeftToRightIsolate {
36+
opts = append(opts, "LEFT-TO-RIGHT-ISOLATE")
37+
}
38+
if cfg.RightToLeftIsolate {
39+
opts = append(opts, "RIGHT-TO-LEFT-ISOLATE")
40+
}
41+
if cfg.FirstStrongIsolate {
42+
opts = append(opts, "FIRST-STRONG-ISOLATE")
43+
}
44+
if cfg.PopDirectionalIsolate {
45+
opts = append(opts, "POP-DIRECTIONAL-ISOLATE")
46+
}
47+
48+
cfgMap[a.Name] = map[string]interface{}{
49+
"disallowed-runes": strings.Join(opts, ","),
50+
}
51+
}
52+
1153
return goanalysis.NewLinter(
1254
"bidichk",
1355
"Checks for dangerous unicode character sequences",
14-
[]*analysis.Analyzer{bidichk.Analyzer},
15-
nil,
56+
[]*analysis.Analyzer{a},
57+
cfgMap,
1658
).WithLoadMode(goanalysis.LoadModeSyntax)
1759
}

pkg/lint/lintersdb/manager.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func enableLinterConfigs(lcs []*linter.Config, isEnabled func(lc *linter.Config)
100100

101101
//nolint:funlen
102102
func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
103+
var bidichkCfg *config.BiDiChkSettings
103104
var cyclopCfg *config.Cyclop
104105
var errorlintCfg *config.ErrorLintSettings
105106
var exhaustiveCfg *config.ExhaustiveSettings
@@ -126,6 +127,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
126127
var nlreturnCfg *config.NlreturnSettings
127128

128129
if m.cfg != nil {
130+
bidichkCfg = &m.cfg.LintersSettings.BiDiChk
129131
cyclopCfg = &m.cfg.LintersSettings.Cyclop
130132
errorlintCfg = &m.cfg.LintersSettings.ErrorLint
131133
exhaustiveCfg = &m.cfg.LintersSettings.Exhaustive
@@ -542,7 +544,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
542544
WithPresets(linter.PresetStyle).
543545
WithLoadForGoAnalysis().
544546
WithURL("https://github.com/blizzy78/varnamelen"),
545-
linter.NewConfig(golinters.NewBiDiChkFuncName()).
547+
linter.NewConfig(golinters.NewBiDiChkFuncName(bidichkCfg)).
546548
WithSince("1.43.0").
547549
WithPresets(linter.PresetBugs).
548550
WithURL("https://github.com/breml/bidichk"),

0 commit comments

Comments
 (0)