Skip to content

Commit

Permalink
linter package moved to pkg (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
incu6us committed Dec 24, 2023
1 parent ed23792 commit fbbdf8c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 99 deletions.
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

0 comments on commit fbbdf8c

Please sign in to comment.