Skip to content

Commit 59f05b5

Browse files
build(deps): bump github.com/ldez/tagliatelle from 0.6.0 to 0.7.1 (#5204)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 06ffc05 commit 59f05b5

File tree

6 files changed

+139
-26
lines changed

6 files changed

+139
-26
lines changed

.golangci.next.reference.yml

+52-20
Original file line numberDiff line numberDiff line change
@@ -3302,26 +3302,24 @@ linters-settings:
33023302
strict: true
33033303

33043304
tagliatelle:
3305-
# Check the struct tag name case.
3305+
# Checks the struct tag name case.
33063306
case:
3307-
# `camel` is used for `json` and `yaml`, and `header` is used for `header` (can be overridden)
3308-
# Default: {}
3307+
# Defines the association between tag name and case.
3308+
# Any struct tag name can be used.
3309+
# Supported string cases:
3310+
# - `camel`
3311+
# - `pascal`
3312+
# - `kebab`
3313+
# - `snake`
3314+
# - `upperSnake`
3315+
# - `goCamel`
3316+
# - `goPascal`
3317+
# - `goKebab`
3318+
# - `goSnake`
3319+
# - `upper`
3320+
# - `lower`
3321+
# - `header`
33093322
rules:
3310-
# Define the association between tag name and case.
3311-
# Any struct tag name can be used.
3312-
# Supported string cases:
3313-
# - `camel`
3314-
# - `pascal`
3315-
# - `kebab`
3316-
# - `snake`
3317-
# - `upperSnake`
3318-
# - `goCamel`
3319-
# - `goPascal`
3320-
# - `goKebab`
3321-
# - `goSnake`
3322-
# - `upper`
3323-
# - `lower`
3324-
# - `header`
33253323
json: camel
33263324
yaml: camel
33273325
xml: camel
@@ -3332,7 +3330,38 @@ linters-settings:
33323330
env: upperSnake
33333331
envconfig: upperSnake
33343332
whatever: snake
3335-
# Use the struct field name to check the name of the struct tag.
3333+
# Defines the association between tag name and case.
3334+
# Important: the `extended-rules` overrides `rules`.
3335+
# Default: empty
3336+
extended-rules:
3337+
json:
3338+
# Supported string cases:
3339+
# - `camel`
3340+
# - `pascal`
3341+
# - `kebab`
3342+
# - `snake`
3343+
# - `upperSnake`
3344+
# - `goCamel`
3345+
# - `goPascal`
3346+
# - `goKebab`
3347+
# - `goSnake`
3348+
# - `header`
3349+
# - `lower`
3350+
# - `header`
3351+
#
3352+
# Required
3353+
case: camel
3354+
# Adds 'AMQP', 'DB', 'GID', 'RTP', 'SIP', 'TS' to initialisms,
3355+
# and removes 'LHS', 'RHS' from initialisms.
3356+
# Default: false
3357+
extra-initialisms: true
3358+
# Defines initialism additions and overrides.
3359+
# Default: empty
3360+
initialism-overrides:
3361+
DB: true # add a new initialism
3362+
LHS: false # disable a default initialism.
3363+
# ...
3364+
# Uses the struct field name to check the name of the struct tag.
33363365
# Default: false
33373366
use-field-name: true
33383367
# The field names to ignore.
@@ -3345,12 +3374,15 @@ linters-settings:
33453374
overrides:
33463375
-
33473376
# The package path (uses `/` only as a separator).
3348-
# Required.
3377+
# Required
33493378
pkg: foo/bar
33503379
# Default: empty or the same as the default/root configuration.
33513380
rules:
33523381
json: snake
33533382
xml: pascal
3383+
# Default: empty or the same as the default/root configuration.
3384+
extended-rules:
3385+
# Same options as the base `extended-rules`.
33543386
# Default: false (WARNING: it doesn't follow the default/root configuration)
33553387
use-field-name: true
33563388
# The field names to ignore.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ require (
6868
github.com/lasiar/canonicalheader v1.1.2
6969
github.com/ldez/gomoddirectives v0.6.0
7070
github.com/ldez/grignotin v0.6.0
71-
github.com/ldez/tagliatelle v0.6.0
71+
github.com/ldez/tagliatelle v0.7.1
7272
github.com/ldez/usetesting v0.2.2
7373
github.com/leonklingele/grouper v1.1.2
7474
github.com/macabu/inamedparam v0.1.3

go.sum

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

jsonschema/golangci.next.jsonschema.json

+58
Original file line numberDiff line numberDiff line change
@@ -2952,6 +2952,35 @@
29522952
}
29532953
}
29542954
},
2955+
"extended-rules": {
2956+
"description": "Defines the association between tag name and case.",
2957+
"type": "object",
2958+
"patternProperties": {
2959+
"^.+$": {
2960+
"type": "object",
2961+
"additionalProperties": false,
2962+
"required": ["case"],
2963+
"properties": {
2964+
"case": {
2965+
"$ref": "#/definitions/tagliatelle-cases"
2966+
},
2967+
"extra-initialisms": {
2968+
"type": "boolean",
2969+
"default": false
2970+
},
2971+
"initialism-overrides": {
2972+
"type": "object",
2973+
"patternProperties": {
2974+
"^.+$": {
2975+
"type": "boolean",
2976+
"default": false
2977+
}
2978+
}
2979+
}
2980+
}
2981+
}
2982+
}
2983+
},
29552984
"overrides": {
29562985
"description": "Overrides the default/root configuration.",
29572986
"type": "array",
@@ -2989,6 +3018,35 @@
29893018
"$ref": "#/definitions/tagliatelle-cases"
29903019
}
29913020
}
3021+
},
3022+
"extended-rules": {
3023+
"description": "Defines the association between tag name and case.",
3024+
"type": "object",
3025+
"patternProperties": {
3026+
"^.+$": {
3027+
"type": "object",
3028+
"additionalProperties": false,
3029+
"required": ["case"],
3030+
"properties": {
3031+
"case": {
3032+
"$ref": "#/definitions/tagliatelle-cases"
3033+
},
3034+
"extra-initialisms": {
3035+
"type": "boolean",
3036+
"default": false
3037+
},
3038+
"initialism-overrides": {
3039+
"type": "object",
3040+
"patternProperties": {
3041+
"^.+$": {
3042+
"type": "boolean",
3043+
"default": false
3044+
}
3045+
}
3046+
}
3047+
}
3048+
}
3049+
}
29923050
}
29933051
}
29943052
}

pkg/config/linters_settings.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,16 @@ type TagliatelleOverrides struct {
900900
}
901901

902902
type TagliatelleBase struct {
903-
Rules map[string]string `mapstructure:"rules"`
904-
UseFieldName bool `mapstructure:"use-field-name"`
905-
IgnoredFields []string `mapstructure:"ignored-fields"`
903+
Rules map[string]string `mapstructure:"rules"`
904+
ExtendedRules map[string]TagliatelleExtendedRule `mapstructure:"extended-rules"`
905+
UseFieldName bool `mapstructure:"use-field-name"`
906+
IgnoredFields []string `mapstructure:"ignored-fields"`
907+
}
908+
909+
type TagliatelleExtendedRule struct {
910+
Case string
911+
ExtraInitialisms bool
912+
InitialismOverrides map[string]bool
906913
}
907914

908915
type TestifylintSettings struct {

pkg/golinters/tagliatelle/tagliatelle.go

+16
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
2424
cfg.Rules[k] = v
2525
}
2626

27+
cfg.ExtendedRules = toExtendedRules(settings.Case.ExtendedRules)
2728
cfg.UseFieldName = settings.Case.UseFieldName
2829
cfg.IgnoredFields = settings.Case.IgnoredFields
2930

3031
for _, override := range settings.Case.Overrides {
3132
cfg.Overrides = append(cfg.Overrides, tagliatelle.Overrides{
3233
Base: tagliatelle.Base{
3334
Rules: override.Rules,
35+
ExtendedRules: toExtendedRules(override.ExtendedRules),
3436
UseFieldName: override.UseFieldName,
3537
IgnoredFields: override.IgnoredFields,
3638
Ignore: override.Ignore,
@@ -49,3 +51,17 @@ func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
4951
nil,
5052
).WithLoadMode(goanalysis.LoadModeTypesInfo)
5153
}
54+
55+
func toExtendedRules(src map[string]config.TagliatelleExtendedRule) map[string]tagliatelle.ExtendedRule {
56+
result := make(map[string]tagliatelle.ExtendedRule, len(src))
57+
58+
for k, v := range src {
59+
result[k] = tagliatelle.ExtendedRule{
60+
Case: v.Case,
61+
ExtraInitialisms: v.ExtraInitialisms,
62+
InitialismOverrides: v.InitialismOverrides,
63+
}
64+
}
65+
66+
return result
67+
}

0 commit comments

Comments
 (0)