Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flip importas configuration #1959

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .golangci.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ linters-settings:
# List of aliases
alias:
# using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package
servingv1: knative.dev/serving/pkg/apis/serving/v1
knative.dev/serving/pkg/apis/serving/v1: servingv1
# using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package
autoscalingv1alpha1: knative.dev/serving/pkg/apis/autoscaling/v1alpha1
knative.dev/serving/pkg/apis/autoscaling/v1alpha1: autoscalingv1alpha1
# You can specify the package path by regular expression,
# and alias by regular expression expansion syntax like below.
# see https://github.com/julz/importas#use-regular-expression for details
"$1$2": 'knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)'
'knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)': '$1$2'

lll:
# max line length, lines longer will be reported. Default is 120.
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/importas.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewImportAs(settings *config.ImportAsSettings) *goanalysis.Linter {
lintCtx.Log.Errorf("failed to parse configuration: %v", err)
}

for alias, pkg := range settings.Alias {
for pkg, alias := range settings.Alias {
err := analyzer.Flags.Set("alias", fmt.Sprintf("%s:%s", pkg, alias))
if err != nil {
lintCtx.Log.Errorf("failed to parse configuration: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/configs/importas.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
linters-settings:
importas:
alias:
fff: fmt
std_os: os
fmt: fff
os: std_os
4 changes: 2 additions & 2 deletions test/testdata/configs/importas_noalias.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
linters-settings:
importas:
fff: fmt
std_os: os
fmt: fff
os: std_os
4 changes: 2 additions & 2 deletions test/testdata/configs/importas_strict.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ linters-settings:
importas:
no-unaliased: true
alias:
fff: fmt
std_os: os
fmt: fff
os: std_os