Skip to content

Commit

Permalink
Lint adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlif committed Nov 28, 2023
1 parent 0123b7d commit 7879073
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ gofmt:


lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1

@echo Running golangci-lint
golangci-lint run --fix ./...

Expand Down
2 changes: 1 addition & 1 deletion commands/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func init() {
rootCmd.AddCommand(mergeCmd)
}

func mergeCmdF(cmd *cobra.Command, args []string) {
func mergeCmdF(cmd *cobra.Command, _ []string) {
targetLang, errL := cmd.Flags().GetString("lang")
if errL != nil {
log.WithError(errL).Fatal("Invalid source file")
Expand Down
2 changes: 1 addition & 1 deletion goextractors/comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewCommentsExtractor() extractors.Extractor {
return &commentsExtractor{}
}

func (d *commentsExtractor) Run(ctx context.Context, extractCtx *extractors.Context) ([]result.Issue, error) {
func (d *commentsExtractor) Run(_ context.Context, extractCtx *extractors.Context) ([]result.Issue, error) {
util.TrackTime(time.Now(), "Extract comments")
for _, pkg := range extractCtx.OriginalPackages {
for _, file := range pkg.Syntax {
Expand Down
9 changes: 5 additions & 4 deletions goextractors/funcreturn.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ func (e *funcReturnExtractor) Run(_ context.Context, extractCtx *extractors.Cont
extractedResults := make([]etype.Token, len(node.Type.Results.List))
var foundType bool
for i, res := range node.Type.Results.List {
if tok, _ := extractCtx.SearchIdentAndToken(res); tok == etype.None {
tok, _ := extractCtx.SearchIdentAndToken(res)
if tok == etype.None {
extractedResults[i] = etype.None
continue
} else {
extractedResults[i] = tok
foundType = true
}

extractedResults[i] = tok
foundType = true
}

if !foundType {
Expand Down
8 changes: 4 additions & 4 deletions goextractors/testlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/vorlif/xspreak/config"
Expand All @@ -23,11 +24,10 @@ const (
func TestPrintAst(t *testing.T) {
fset := token.NewFileSet() // positions are relative to fset
f, err := parser.ParseFile(fset, filepath.Join(testdataDir, "funccall.go"), nil, 0)
if err != nil {
panic(err)
}
require.NoError(t, err)

ast.Print(fset, f)
err = ast.Print(fset, f)
assert.NoError(t, err)
}

func runExtraction(t *testing.T, dir string, testExtractors ...extractors.Extractor) []result.Issue {
Expand Down
12 changes: 7 additions & 5 deletions goextractors/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ func searchSelector(expr interface{}) *ast.SelectorExpr {
}

func calculatePosIdx(first, second int) int {
if first > 0 && second > 0 {
return first * second
} else if first > 0 {
if first > 0 {
if second > 0 {
return first * second
}

return first
} else {
return second
}

return second
}

type searchCollector struct {
Expand Down
1 change: 1 addition & 0 deletions testdata/project/globalassign.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

// TRANSLATORS: Name of the app
//
//goland:noinspection GoVarAndConstTypeMayBeOmitted
var applicationName alias.Singular = "app"

Expand Down

0 comments on commit 7879073

Please sign in to comment.