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

Consolidate linters into single binary #2117

Merged
merged 2 commits into from
Jan 30, 2024
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
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ jobs:
skip-pkg-cache: true
- name: Custom Lint
run: |
go run ./linter/koanf ./...
go run ./linter/pointercheck ./...
go run ./linters ./...
- name: Set environment variables
run: |
Expand Down
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.
Loading