Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Dec 22, 2023
1 parent 89179f1 commit f769aa6
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions rule/redundant-import-alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,11 @@ func (r *RedundantImportAlias) checkRedundantAliases(node ast.Node) map[string]s
return true
}

if imp.Name != nil && imp.Path != nil && imp.Name.Name != "_" {
aliasedPackages[imp.Name.Name] = "redundant"
if imp.Name != nil && imp.Path != nil && imp.Name.Name != "_" && getImportPackageName(imp) == imp.Name.Name {
aliasedPackages[imp.Name.Name] = "redundant"
}

if imp.Name != nil && imp.Path != nil && imp.Name.Name != "_" && getImportPackageName(imp) != imp.Name.Name {
delete(aliasedPackages, imp.Name.Name)
}

return true
return true
})

if !r.ignoreUsed {
Expand All @@ -95,8 +91,6 @@ func (r *RedundantImportAlias) checkRedundantAliases(node ast.Node) map[string]s
return true
})



return aliasedPackages

}
Expand Down

0 comments on commit f769aa6

Please sign in to comment.