Skip to content

Commit

Permalink
build(deps): bump github.com/ldez/tagliatelle from 0.6.0 to 0.7.1 (#5204
Browse files Browse the repository at this point in the history
)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and ldez authored Dec 8, 2024
1 parent 06ffc05 commit 59f05b5
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 26 deletions.
72 changes: 52 additions & 20 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3302,26 +3302,24 @@ linters-settings:
strict: true

tagliatelle:
# Check the struct tag name case.
# Checks the struct tag name case.
case:
# `camel` is used for `json` and `yaml`, and `header` is used for `header` (can be overridden)
# Default: {}
# Defines the association between tag name and case.
# Any struct tag name can be used.
# Supported string cases:
# - `camel`
# - `pascal`
# - `kebab`
# - `snake`
# - `upperSnake`
# - `goCamel`
# - `goPascal`
# - `goKebab`
# - `goSnake`
# - `upper`
# - `lower`
# - `header`
rules:
# Define the association between tag name and case.
# Any struct tag name can be used.
# Supported string cases:
# - `camel`
# - `pascal`
# - `kebab`
# - `snake`
# - `upperSnake`
# - `goCamel`
# - `goPascal`
# - `goKebab`
# - `goSnake`
# - `upper`
# - `lower`
# - `header`
json: camel
yaml: camel
xml: camel
Expand All @@ -3332,7 +3330,38 @@ linters-settings:
env: upperSnake
envconfig: upperSnake
whatever: snake
# Use the struct field name to check the name of the struct tag.
# Defines the association between tag name and case.
# Important: the `extended-rules` overrides `rules`.
# Default: empty
extended-rules:
json:
# Supported string cases:
# - `camel`
# - `pascal`
# - `kebab`
# - `snake`
# - `upperSnake`
# - `goCamel`
# - `goPascal`
# - `goKebab`
# - `goSnake`
# - `header`
# - `lower`
# - `header`
#
# Required
case: camel
# Adds 'AMQP', 'DB', 'GID', 'RTP', 'SIP', 'TS' to initialisms,
# and removes 'LHS', 'RHS' from initialisms.
# Default: false
extra-initialisms: true
# Defines initialism additions and overrides.
# Default: empty
initialism-overrides:
DB: true # add a new initialism
LHS: false # disable a default initialism.
# ...
# Uses the struct field name to check the name of the struct tag.
# Default: false
use-field-name: true
# The field names to ignore.
Expand All @@ -3345,12 +3374,15 @@ linters-settings:
overrides:
-
# The package path (uses `/` only as a separator).
# Required.
# Required
pkg: foo/bar
# Default: empty or the same as the default/root configuration.
rules:
json: snake
xml: pascal
# Default: empty or the same as the default/root configuration.
extended-rules:
# Same options as the base `extended-rules`.
# Default: false (WARNING: it doesn't follow the default/root configuration)
use-field-name: true
# The field names to ignore.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ require (
github.com/lasiar/canonicalheader v1.1.2
github.com/ldez/gomoddirectives v0.6.0
github.com/ldez/grignotin v0.6.0
github.com/ldez/tagliatelle v0.6.0
github.com/ldez/tagliatelle v0.7.1
github.com/ldez/usetesting v0.2.2
github.com/leonklingele/grouper v1.1.2
github.com/macabu/inamedparam v0.1.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2952,6 +2952,35 @@
}
}
},
"extended-rules": {
"description": "Defines the association between tag name and case.",
"type": "object",
"patternProperties": {
"^.+$": {
"type": "object",
"additionalProperties": false,
"required": ["case"],
"properties": {
"case": {
"$ref": "#/definitions/tagliatelle-cases"
},
"extra-initialisms": {
"type": "boolean",
"default": false
},
"initialism-overrides": {
"type": "object",
"patternProperties": {
"^.+$": {
"type": "boolean",
"default": false
}
}
}
}
}
}
},
"overrides": {
"description": "Overrides the default/root configuration.",
"type": "array",
Expand Down Expand Up @@ -2989,6 +3018,35 @@
"$ref": "#/definitions/tagliatelle-cases"
}
}
},
"extended-rules": {
"description": "Defines the association between tag name and case.",
"type": "object",
"patternProperties": {
"^.+$": {
"type": "object",
"additionalProperties": false,
"required": ["case"],
"properties": {
"case": {
"$ref": "#/definitions/tagliatelle-cases"
},
"extra-initialisms": {
"type": "boolean",
"default": false
},
"initialism-overrides": {
"type": "object",
"patternProperties": {
"^.+$": {
"type": "boolean",
"default": false
}
}
}
}
}
}
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,16 @@ type TagliatelleOverrides struct {
}

type TagliatelleBase struct {
Rules map[string]string `mapstructure:"rules"`
UseFieldName bool `mapstructure:"use-field-name"`
IgnoredFields []string `mapstructure:"ignored-fields"`
Rules map[string]string `mapstructure:"rules"`
ExtendedRules map[string]TagliatelleExtendedRule `mapstructure:"extended-rules"`
UseFieldName bool `mapstructure:"use-field-name"`
IgnoredFields []string `mapstructure:"ignored-fields"`
}

type TagliatelleExtendedRule struct {
Case string
ExtraInitialisms bool
InitialismOverrides map[string]bool
}

type TestifylintSettings struct {
Expand Down
16 changes: 16 additions & 0 deletions pkg/golinters/tagliatelle/tagliatelle.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
cfg.Rules[k] = v
}

cfg.ExtendedRules = toExtendedRules(settings.Case.ExtendedRules)
cfg.UseFieldName = settings.Case.UseFieldName
cfg.IgnoredFields = settings.Case.IgnoredFields

for _, override := range settings.Case.Overrides {
cfg.Overrides = append(cfg.Overrides, tagliatelle.Overrides{
Base: tagliatelle.Base{
Rules: override.Rules,
ExtendedRules: toExtendedRules(override.ExtendedRules),
UseFieldName: override.UseFieldName,
IgnoredFields: override.IgnoredFields,
Ignore: override.Ignore,
Expand All @@ -49,3 +51,17 @@ func New(settings *config.TagliatelleSettings) *goanalysis.Linter {
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}

func toExtendedRules(src map[string]config.TagliatelleExtendedRule) map[string]tagliatelle.ExtendedRule {
result := make(map[string]tagliatelle.ExtendedRule, len(src))

for k, v := range src {
result[k] = tagliatelle.ExtendedRule{
Case: v.Case,
ExtraInitialisms: v.ExtraInitialisms,
InitialismOverrides: v.InitialismOverrides,
}
}

return result
}

0 comments on commit 59f05b5

Please sign in to comment.