mirror of
https://github.com/Crocmagnon/fatcontext.git
synced 2024-11-21 07:28:09 +01:00
Compare commits
2 commits
4ad817c8f3
...
632a706303
Author | SHA1 | Date | |
---|---|---|---|
|
632a706303 | ||
|
98578576b8 |
4 changed files with 16 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
||||||
issues:
|
issues:
|
||||||
exclude-dirs:
|
exclude-dirs:
|
||||||
- contrib
|
- contrib
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- goimports
|
||||||
|
linters-settings:
|
||||||
|
goimports:
|
||||||
|
local-prefixes: "github.com/Crocmagnon/fatcontext"
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
|
|
||||||
"golang.org/x/tools/go/analysis/singlechecker"
|
"golang.org/x/tools/go/analysis/singlechecker"
|
||||||
|
|
||||||
|
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -59,7 +59,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||||
{
|
{
|
||||||
Pos: assignStmt.Pos(),
|
Pos: assignStmt.Pos(),
|
||||||
End: assignStmt.End(),
|
End: assignStmt.End(),
|
||||||
NewText: []byte(suggested),
|
NewText: suggested,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -215,10 +215,10 @@ func getRootIdent(pass *analysis.Pass, node ast.Node) *ast.Ident {
|
||||||
}
|
}
|
||||||
|
|
||||||
// render returns the pretty-print of the given node
|
// render returns the pretty-print of the given node
|
||||||
func render(fset *token.FileSet, x interface{}) (string, error) {
|
func render(fset *token.FileSet, x interface{}) ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if err := printer.Fprint(&buf, fset, x); err != nil {
|
if err := printer.Fprint(&buf, fset, x); err != nil {
|
||||||
return "", fmt.Errorf("printing node: %w", err)
|
return nil, fmt.Errorf("printing node: %w", err)
|
||||||
}
|
}
|
||||||
return buf.String(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package analyzer_test
|
package analyzer_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
|
|
||||||
"golang.org/x/tools/go/analysis/analysistest"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"golang.org/x/tools/go/analysis/analysistest"
|
||||||
|
|
||||||
|
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAll(t *testing.T) {
|
func TestAll(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue