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

linter package moved to pkg #148

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions linter/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions linter/go.mod

This file was deleted.

12 changes: 0 additions & 12 deletions linter/go.sum

This file was deleted.

45 changes: 0 additions & 45 deletions linter/main.go

This file was deleted.

20 changes: 9 additions & 11 deletions linter/analyzer.go → pkg/goanalysis/analyzer.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
//go:build linter
// +build linter

package main
package goanalysis

import (
"flag"
"go/ast"
"go/parser"
"go/token"

"github.com/incu6us/goimports-reviser/v2/pkg/module"
"github.com/incu6us/goimports-reviser/v2/reviser"
"golang.org/x/tools/go/analysis"

"github.com/incu6us/goimports-reviser/v3/pkg/module"
"github.com/incu6us/goimports-reviser/v3/reviser"
)

const errMessage = "imports must be formatted"

func NewAnalyzer(flagSet *flag.FlagSet, localPkgPrefixes string, options ...reviser.Option) *analysis.Analyzer {
func NewAnalyzer(flagSet *flag.FlagSet, localPkgPrefixes string, options ...reviser.SourceFileOption) *analysis.Analyzer {
return &analysis.Analyzer{
Name: "goimportsreviserlint",
Doc: "Linter for imports sorting",
Name: "goimportsreviser",
Doc: "goimports-reviser linter",
Run: run(localPkgPrefixes, options...),
Flags: *flagSet,
}
}

func run(localPkgPrefixes string, options ...reviser.Option) func(pass *analysis.Pass) (interface{}, error) {
func run(localPkgPrefixes string, options ...reviser.SourceFileOption) func(pass *analysis.Pass) (interface{}, error) {
return func(pass *analysis.Pass) (interface{}, error) {
inspect := func(formattedFile *ast.File, hasChanged bool) func(node ast.Node) bool {
return func(node ast.Node) bool {
Expand Down Expand Up @@ -79,7 +77,7 @@ func run(localPkgPrefixes string, options ...reviser.Option) func(pass *analysis
}
}

formattedFileContent, hasChanged, err := reviser.Execute(projectName, filePath, localPkgPrefixes, options...)
formattedFileContent, hasChanged, err := reviser.NewSourceFile(projectName, filePath).Fix(options...)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/std/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/tools/go/packages"
)

//go:generate go run -tags gen github.com/incu6us/goimports-reviser/v2/pkg/std/gen
//go:generate go run -tags gen github.com/incu6us/goimports-reviser/v3/pkg/std/gen

const (
fileName = "package_list.go"
Expand Down
Loading