Skip to content

Commit d74f1ae

Browse files
build(deps): bump github.com/ldez/tagliatelle from 0.5.0 to 0.6.0 (#5164)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 9921355 commit d74f1ae

File tree

9 files changed

+203
-31
lines changed

9 files changed

+203
-31
lines changed

.golangci.next.reference.yml

+45-5
Original file line numberDiff line numberDiff line change
@@ -3285,14 +3285,24 @@ linters-settings:
32853285
tagliatelle:
32863286
# Check the struct tag name case.
32873287
case:
3288-
# Use the struct field name to check the name of the struct tag.
3289-
# Default: false
3290-
use-field-name: true
32913288
# `camel` is used for `json` and `yaml`, and `header` is used for `header` (can be overridden)
32923289
# Default: {}
32933290
rules:
3294-
# Any struct tag type can be used.
3295-
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `upperSnake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`
3291+
# Define the association between tag name and case.
3292+
# Any struct tag name can be used.
3293+
# Supported string cases:
3294+
# - `camel`
3295+
# - `pascal`
3296+
# - `kebab`
3297+
# - `snake`
3298+
# - `upperSnake`
3299+
# - `goCamel`
3300+
# - `goPascal`
3301+
# - `goKebab`
3302+
# - `goSnake`
3303+
# - `upper`
3304+
# - `lower`
3305+
# - `header`
32963306
json: camel
32973307
yaml: camel
32983308
xml: camel
@@ -3302,6 +3312,36 @@ linters-settings:
33023312
mapstructure: kebab
33033313
env: upperSnake
33043314
envconfig: upperSnake
3315+
whatever: snake
3316+
# Use the struct field name to check the name of the struct tag.
3317+
# Default: false
3318+
use-field-name: true
3319+
# The field names to ignore.
3320+
# Default: []
3321+
ignored-fields:
3322+
- Bar
3323+
- Foo
3324+
# Overrides the default/root configuration.
3325+
# Default: []
3326+
overrides:
3327+
-
3328+
# The package path (uses `/` only as a separator).
3329+
# Required.
3330+
pkg: foo/bar
3331+
# Default: empty or the same as the default/root configuration.
3332+
rules:
3333+
json: snake
3334+
xml: pascal
3335+
# Default: false (WARNING: it doesn't follow the default/root configuration)
3336+
use-field-name: true
3337+
# The field names to ignore.
3338+
# Default: [] or the same as the default/root configuration.
3339+
ignored-fields:
3340+
- Bar
3341+
- Foo
3342+
# Ignore the package (takes precedence over all other configurations).
3343+
# Default: false
3344+
ignore: true
33053345

33063346
tenv:
33073347
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.

go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ require (
6767
github.com/kyoh86/exportloopref v0.1.11
6868
github.com/lasiar/canonicalheader v1.1.2
6969
github.com/ldez/gomoddirectives v0.2.4
70-
github.com/ldez/tagliatelle v0.5.0
70+
github.com/ldez/tagliatelle v0.6.0
7171
github.com/leonklingele/grouper v1.1.2
7272
github.com/macabu/inamedparam v0.1.3
7373
github.com/maratori/testableexamples v1.0.0
@@ -159,6 +159,8 @@ require (
159159
github.com/google/go-cmp v0.6.0 // indirect
160160
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
161161
github.com/gostaticanalysis/comment v1.4.2 // indirect
162+
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
163+
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
162164
github.com/hashicorp/hcl v1.0.0 // indirect
163165
github.com/inconshreveable/mousetrap v1.1.0 // indirect
164166
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect

go.sum

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

jsonschema/golangci.next.jsonschema.json

+66-14
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,22 @@
305305
"opaque"
306306
]
307307
},
308+
"tagliatelle-cases": {
309+
"enum": [
310+
"camel",
311+
"pascal",
312+
"kebab",
313+
"snake",
314+
"goCamel",
315+
"goPascal",
316+
"goKebab",
317+
"goSnake",
318+
"upper",
319+
"upperSnake",
320+
"lower",
321+
"header"
322+
]
323+
},
308324
"linters": {
309325
"$comment": "anyOf with enum is used to allow auto completion of non-custom linters",
310326
"description": "Linters usable.",
@@ -2894,24 +2910,60 @@
28942910
"type": "boolean",
28952911
"default": false
28962912
},
2913+
"ignored-fields": {
2914+
"description": "The field names to ignore.",
2915+
"type": "array",
2916+
"items": {
2917+
"type": "string",
2918+
"examples": ["example"]
2919+
}
2920+
},
28972921
"rules": {
28982922
"type": "object",
28992923
"patternProperties": {
29002924
"^.+$": {
2901-
"enum": [
2902-
"camel",
2903-
"pascal",
2904-
"kebab",
2905-
"snake",
2906-
"goCamel",
2907-
"goPascal",
2908-
"goKebab",
2909-
"goSnake",
2910-
"upper",
2911-
"upperSnake",
2912-
"lower",
2913-
"header"
2914-
]
2925+
"$ref": "#/definitions/tagliatelle-cases"
2926+
}
2927+
}
2928+
},
2929+
"overrides": {
2930+
"description": "Overrides the default/root configuration.",
2931+
"type": "array",
2932+
"items": {
2933+
"type": "object",
2934+
"additionalProperties": false,
2935+
"required": ["pkg"],
2936+
"properties": {
2937+
"pkg": {
2938+
"description": "A package path.",
2939+
"type": "string"
2940+
},
2941+
"use-field-name": {
2942+
"description": "Use the struct field name to check the name of the struct tag.",
2943+
"type": "boolean",
2944+
"default": false
2945+
},
2946+
"ignored-fields": {
2947+
"description": "The field names to ignore.",
2948+
"type": "array",
2949+
"items": {
2950+
"type": "string",
2951+
"examples": ["example"]
2952+
}
2953+
},
2954+
"ignore": {
2955+
"description": "Ignore the package (takes precedence over all other configurations).",
2956+
"type": "boolean",
2957+
"default": false
2958+
},
2959+
"rules": {
2960+
"type": "object",
2961+
"patternProperties": {
2962+
"^.+$": {
2963+
"$ref": "#/definitions/tagliatelle-cases"
2964+
}
2965+
}
2966+
}
29152967
}
29162968
}
29172969
}

pkg/config/linters_settings.go

+18-4
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,24 @@ type TagAlignSettings struct {
870870
}
871871

872872
type TagliatelleSettings struct {
873-
Case struct {
874-
Rules map[string]string
875-
UseFieldName bool `mapstructure:"use-field-name"`
876-
}
873+
Case TagliatelleCase
874+
}
875+
876+
type TagliatelleCase struct {
877+
TagliatelleBase `mapstructure:",squash"`
878+
Overrides []TagliatelleOverrides
879+
}
880+
881+
type TagliatelleOverrides struct {
882+
TagliatelleBase `mapstructure:",squash"`
883+
Package string `mapstructure:"pkg"`
884+
Ignore bool `mapstructure:"ignore"`
885+
}
886+
887+
type TagliatelleBase struct {
888+
Rules map[string]string `mapstructure:"rules"`
889+
UseFieldName bool `mapstructure:"use-field-name"`
890+
IgnoredFields []string `mapstructure:"ignored-fields"`
877891
}
878892

879893
type TestifylintSettings struct {

pkg/golinters/tagliatelle/tagliatelle.go

+21-5
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,34 @@ import (
1010

1111
func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
1212
cfg := tagliatelle.Config{
13-
Rules: map[string]string{
14-
"json": "camel",
15-
"yaml": "camel",
16-
"header": "header",
13+
Base: tagliatelle.Base{
14+
Rules: map[string]string{
15+
"json": "camel",
16+
"yaml": "camel",
17+
"header": "header",
18+
},
1719
},
1820
}
1921

2022
if settings != nil {
2123
for k, v := range settings.Case.Rules {
2224
cfg.Rules[k] = v
2325
}
26+
2427
cfg.UseFieldName = settings.Case.UseFieldName
28+
cfg.IgnoredFields = settings.Case.IgnoredFields
29+
30+
for _, override := range settings.Case.Overrides {
31+
cfg.Overrides = append(cfg.Overrides, tagliatelle.Overrides{
32+
Base: tagliatelle.Base{
33+
Rules: override.Rules,
34+
UseFieldName: override.UseFieldName,
35+
IgnoredFields: override.IgnoredFields,
36+
Ignore: override.Ignore,
37+
},
38+
Package: override.Package,
39+
})
40+
}
2541
}
2642

2743
a := tagliatelle.New(cfg)
@@ -31,5 +47,5 @@ func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
3147
a.Doc,
3248
[]*analysis.Analyzer{a},
3349
nil,
34-
).WithLoadMode(goanalysis.LoadModeSyntax)
50+
).WithLoadMode(goanalysis.LoadModeTypesInfo)
3551
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//golangcitest:args -Etagliatelle
2+
//golangcitest:config_path testdata/tagliatelle_ignored_fields.yml
3+
package testdata
4+
5+
import "time"
6+
7+
type TglFoo struct {
8+
ID string `json:"ID"` // want `json\(camel\): got 'ID' want 'id'`
9+
UserID string `json:"UserID"` // want `json\(camel\): got 'UserID' want 'userId'`
10+
Name string `json:"name"`
11+
Value time.Duration `json:"value,omitempty"`
12+
Bar TglBar `json:"bar"`
13+
Bur `json:"bur"`
14+
}
15+
16+
type TglBar struct {
17+
Name string `json:"-"`
18+
Value string `json:"value"`
19+
CommonServiceFooItem *TglBir `json:"CommonServiceItem,omitempty"`
20+
}
21+
22+
type TglBir struct {
23+
Name string `json:"-"`
24+
Value string `json:"value"`
25+
ReplaceAllowList []string `mapstructure:"replace-allow-list"`
26+
}
27+
28+
type Bur struct {
29+
Name string
30+
Value string `yaml:"Value"` // want `yaml\(camel\): got 'Value' want 'value'`
31+
More string `json:"-"`
32+
Also string `json:"also,omitempty"`
33+
ReqPerS string `avro:"req_per_s"`
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
linters-settings:
2+
tagliatelle:
3+
case:
4+
ignored-fields:
5+
- CommonServiceFooItem
6+
7+

pkg/lint/lintersdb/builder_linter.go

+1
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
736736
linter.NewConfig(tagliatelle.New(&cfg.LintersSettings.Tagliatelle)).
737737
WithSince("v1.40.0").
738738
WithPresets(linter.PresetStyle).
739+
WithLoadForGoAnalysis().
739740
WithURL("https://github.com/ldez/tagliatelle"),
740741

741742
linter.NewConfig(tenv.New(&cfg.LintersSettings.Tenv)).

0 commit comments

Comments
 (0)