File tree 10 files changed +302
-336
lines changed 10 files changed +302
-336
lines changed Original file line number Diff line number Diff line change
1
+ linters-settings :
2
+ custom :
3
+ noprint :
4
+ type : module
5
+ nodebug :
6
+ type : module
7
+ rangevarref :
8
+ type : module
9
+
10
+ goheader :
11
+ values :
12
+ const :
13
+ AUTHOR : The Accumulate Authors
14
+ template : |-
15
+ Copyright {{ YEAR }} {{ AUTHOR }}
16
+
17
+ Use of this source code is governed by an MIT-style
18
+ license that can be found in the LICENSE file or at
19
+ https://opensource.org/licenses/MIT.
20
+
1
21
linters :
2
22
disable-all : true
3
23
enable :
@@ -59,15 +79,3 @@ issues:
59
79
- path : ^test/util/goroutine_leaks\.go$
60
80
linters :
61
81
- goheader
62
-
63
- linters-settings :
64
- goheader :
65
- values :
66
- const :
67
- AUTHOR : The Accumulate Authors
68
- template : |-
69
- Copyright {{ YEAR }} {{ AUTHOR }}
70
-
71
- Use of this source code is governed by an MIT-style
72
- license that can be found in the LICENSE file or at
73
- https://opensource.org/licenses/MIT.
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1
- // Copyright 2022 The Accumulate Authors
2
- //
1
+ // Copyright 2024 The Accumulate Authors
2
+ //
3
3
// Use of this source code is governed by an MIT-style
4
4
// license that can be found in the LICENSE file or at
5
5
// https://opensource.org/licenses/MIT.
6
6
7
7
package main
8
8
9
9
import (
10
- "fmt"
11
- "reflect"
12
- "unsafe"
13
-
14
- "github.com/golangci/golangci-lint/pkg/lint/linter"
15
- "github.com/golangci/golangci-lint/pkg/lint/lintersdb"
10
+ "golang.org/x/tools/go/analysis"
16
11
)
17
12
18
- var customLinters []* linter.Config
19
-
20
- func addCustomLinters (db * lintersdb.Manager ) {
21
- field , ok := reflect .TypeOf (db ).Elem ().FieldByName ("nameToLCs" )
22
- if ! ok {
23
- panic (fmt .Errorf ("can't find linter config field" ))
24
- }
13
+ type customLinter struct {
14
+ LoadMode string
15
+ Analyzer * analysis.Analyzer
16
+ }
25
17
26
- // This is a horrific abuse of Go. But using a plugin would be a huge PITA.
27
- nameToLCs := * (* map [string ][]* linter.Config )(unsafe .Pointer (uintptr (unsafe .Pointer (db )) + field .Offset ))
18
+ func (c * customLinter ) GetLoadMode () string {
19
+ return c .LoadMode
20
+ }
28
21
29
- for _ , lc := range customLinters {
30
- nameToLCs [lc .Name ()] = append (nameToLCs [lc .Name ()], lc )
31
- }
22
+ func (c * customLinter ) BuildAnalyzers () ([]* analysis.Analyzer , error ) {
23
+ return []* analysis.Analyzer {c .Analyzer }, nil
32
24
}
Original file line number Diff line number Diff line change 1
- // Copyright 2023 The Accumulate Authors
2
- //
1
+ // Copyright 2024 The Accumulate Authors
2
+ //
3
3
// Use of this source code is governed by an MIT-style
4
4
// license that can be found in the LICENSE file or at
5
5
// https://opensource.org/licenses/MIT.
Original file line number Diff line number Diff line change 1
- // Copyright 2022 The Accumulate Authors
2
- //
1
+ // Copyright 2024 The Accumulate Authors
2
+ //
3
3
// Use of this source code is governed by an MIT-style
4
4
// license that can be found in the LICENSE file or at
5
5
// https://opensource.org/licenses/MIT.
Original file line number Diff line number Diff line change 1
- // Copyright 2023 The Accumulate Authors
2
- //
1
+ // Copyright 2024 The Accumulate Authors
2
+ //
3
3
// Use of this source code is governed by an MIT-style
4
4
// license that can be found in the LICENSE file or at
5
5
// https://opensource.org/licenses/MIT.
@@ -23,15 +23,14 @@ var (
23
23
)
24
24
25
25
func main () {
26
- e := commands .NewExecutor (commands.BuildInfo {
26
+ err := commands .Execute (commands.BuildInfo {
27
27
GoVersion : "go" ,
28
28
Version : version ,
29
29
Commit : commit ,
30
30
Date : date ,
31
31
})
32
- addCustomLinters (e .DBManager )
33
32
34
- if err := e . Execute (); err != nil {
33
+ if err != nil {
35
34
fmt .Fprintf (os .Stderr , "failed executing command with error %v\n " , err )
36
35
os .Exit (exitcodes .Failure )
37
36
}
Original file line number Diff line number Diff line change 1
- // Copyright 2022 The Accumulate Authors
2
- //
1
+ // Copyright 2024 The Accumulate Authors
2
+ //
3
3
// Use of this source code is governed by an MIT-style
4
4
// license that can be found in the LICENSE file or at
5
5
// https://opensource.org/licenses/MIT.
@@ -10,23 +10,24 @@ import (
10
10
"go/ast"
11
11
"strings"
12
12
13
- "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
14
- "github.com/golangci/golangci-lint/pkg/lint/linter"
13
+ "github.com/golangci/plugin-module-register/register"
15
14
"golang.org/x/tools/go/analysis"
16
15
)
17
16
18
17
func init () {
19
18
const name = "nodebug"
20
19
const doc = "Checks for enabled debug flags"
21
20
22
- customLinters = append (customLinters , linter .NewConfig (
23
- goanalysis .NewLinter (name , doc , []* analysis.Analyzer {{
24
- Name : name ,
25
- Doc : doc ,
26
- Run : nodebug ,
27
- }}, nil ).
28
- WithLoadMode (goanalysis .LoadModeSyntax ),
29
- ))
21
+ register .Plugin (name , func (any ) (register.LinterPlugin , error ) {
22
+ return & customLinter {
23
+ LoadMode : register .LoadModeSyntax ,
24
+ Analyzer : & analysis.Analyzer {
25
+ Name : name ,
26
+ Doc : doc ,
27
+ Run : nodebug ,
28
+ },
29
+ }, nil
30
+ })
30
31
}
31
32
32
33
func nodebug (pass * analysis.Pass ) (interface {}, error ) {
Original file line number Diff line number Diff line change 1
- // Copyright 2022 The Accumulate Authors
2
- //
1
+ // Copyright 2024 The Accumulate Authors
2
+ //
3
3
// Use of this source code is governed by an MIT-style
4
4
// license that can be found in the LICENSE file or at
5
5
// https://opensource.org/licenses/MIT.
@@ -9,23 +9,24 @@ package main
9
9
import (
10
10
"go/ast"
11
11
12
- "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
13
- "github.com/golangci/golangci-lint/pkg/lint/linter"
12
+ "github.com/golangci/plugin-module-register/register"
14
13
"golang.org/x/tools/go/analysis"
15
14
)
16
15
17
16
func init () {
18
17
const name = "noprint"
19
18
const doc = "Checks for out of place print statements"
20
19
21
- customLinters = append (customLinters , linter .NewConfig (
22
- goanalysis .NewLinter (name , doc , []* analysis.Analyzer {{
23
- Name : name ,
24
- Doc : doc ,
25
- Run : noprint ,
26
- }}, nil ).
27
- WithLoadMode (goanalysis .LoadModeSyntax ),
28
- ))
20
+ register .Plugin (name , func (any ) (register.LinterPlugin , error ) {
21
+ return & customLinter {
22
+ LoadMode : register .LoadModeSyntax ,
23
+ Analyzer : & analysis.Analyzer {
24
+ Name : name ,
25
+ Doc : doc ,
26
+ Run : noprint ,
27
+ },
28
+ }, nil
29
+ })
29
30
}
30
31
31
32
func noprint (pass * analysis.Pass ) (interface {}, error ) {
Original file line number Diff line number Diff line change 1
- // Copyright 2022 The Accumulate Authors
2
- //
1
+ // Copyright 2024 The Accumulate Authors
2
+ //
3
3
// Use of this source code is governed by an MIT-style
4
4
// license that can be found in the LICENSE file or at
5
5
// https://opensource.org/licenses/MIT.
@@ -11,23 +11,24 @@ import (
11
11
"go/token"
12
12
"go/types"
13
13
14
- "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
15
- "github.com/golangci/golangci-lint/pkg/lint/linter"
14
+ "github.com/golangci/plugin-module-register/register"
16
15
"golang.org/x/tools/go/analysis"
17
16
)
18
17
19
18
func init () {
20
19
const name = "rangevarref"
21
20
const doc = "Checks for loops that capture a pointer to a value-type range variable"
22
21
23
- customLinters = append (customLinters , linter .NewConfig (
24
- goanalysis .NewLinter (name , doc , []* analysis.Analyzer {{
25
- Name : name ,
26
- Doc : doc ,
27
- Run : rangevarref ,
28
- }}, nil ).
29
- WithLoadMode (goanalysis .LoadModeTypesInfo ),
30
- ))
22
+ register .Plugin (name , func (any ) (register.LinterPlugin , error ) {
23
+ return & customLinter {
24
+ LoadMode : register .LoadModeSyntax ,
25
+ Analyzer : & analysis.Analyzer {
26
+ Name : name ,
27
+ Doc : doc ,
28
+ Run : rangevarref ,
29
+ },
30
+ }, nil
31
+ })
31
32
}
32
33
33
34
func rangevarref (pass * analysis.Pass ) (interface {}, error ) {
You can’t perform that action at this time.
0 commit comments