Skip to content

Commit

Permalink
Consolidate linters into single binary
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar committed Jan 30, 2024
1 parent 2bc60c3 commit d920feb
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 32 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(arbitrator_pro
# strategic rules to minimize dependency building

.make/lint: $(DEP_PREDICATE) build-node-deps $(ORDER_ONLY_PREDICATE) .make
go run ./linter/koanf ./...
go run ./linter/pointercheck ./...
go run ./linter/rightshift ./...
go run ./linters ./...
golangci-lint run --fix
yarn --cwd contracts solhint
@touch $@
Expand Down
2 changes: 1 addition & 1 deletion linter/koanf/handlers.go → linters/koanf/handlers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package koanf

import (
"fmt"
Expand Down
7 changes: 1 addition & 6 deletions linter/koanf/koanf.go → linters/koanf/koanf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package koanf

import (
"errors"
Expand All @@ -8,7 +8,6 @@ import (
"reflect"

"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/singlechecker"
)

var (
Expand Down Expand Up @@ -97,7 +96,3 @@ func run(dryRun bool, pass *analysis.Pass) (interface{}, error) {
}
return ret, nil
}

func main() {
singlechecker.Main(Analyzer)
}
2 changes: 1 addition & 1 deletion linter/koanf/koanf_test.go → linters/koanf/koanf_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package koanf

import (
"errors"
Expand Down
18 changes: 18 additions & 0 deletions linters/linters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"github.com/offchainlabs/nitro/linters/koanf"
"github.com/offchainlabs/nitro/linters/pointercheck"
"github.com/offchainlabs/nitro/linters/rightshift"
"github.com/offchainlabs/nitro/linters/structinit"
"golang.org/x/tools/go/analysis/multichecker"
)

func main() {
multichecker.Main(
koanf.Analyzer,
pointercheck.Analyzer,
rightshift.Analyzer,
structinit.Analyzer,
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package pointercheck

import (
"fmt"
Expand All @@ -8,7 +8,6 @@ import (
"reflect"

"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/singlechecker"
)

var Analyzer = &analysis.Analyzer{
Expand Down Expand Up @@ -90,7 +89,3 @@ func ptrIdent(pass *analysis.Pass, e ast.Expr) bool {
}
return false
}

func main() {
singlechecker.Main(Analyzer)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package pointercheck

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package main
package rightshift

import (
"go/ast"
"go/token"
"reflect"

"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/singlechecker"
)

var Analyzer = &analysis.Analyzer{
Expand Down Expand Up @@ -70,7 +69,3 @@ func isOne(expr ast.Expr) bool {
bl, ok := expr.(*ast.BasicLit)
return ok && bl.Kind == token.INT && bl.Value == "1"
}

func main() {
singlechecker.Main(Analyzer)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package rightshift

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package structinit

import (
"fmt"
Expand All @@ -8,7 +8,6 @@ import (
"strings"

"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/singlechecker"
)

// Tip for linter that struct that has this comment should be included in the
Expand Down Expand Up @@ -112,7 +111,3 @@ type position struct {
fileName string
line int
}

func main() {
singlechecker.Main(Analyzer)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package structinit

import (
"os"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d920feb

Please sign in to comment.