Skip to content

Commit 4291cde

Browse files
committed
cmplint -> ptrequality
Signed-off-by: Oliver Eikemeier <[email protected]>
1 parent 5d732c5 commit 4291cde

File tree

8 files changed

+63
-49
lines changed

8 files changed

+63
-49
lines changed

jsonschema/golangci.next.jsonschema.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,6 @@
728728
"bidichk",
729729
"bodyclose",
730730
"canonicalheader",
731-
"cmplint",
732731
"containedctx",
733732
"contextcheck",
734733
"copyloopvar",
@@ -805,6 +804,7 @@
805804
"predeclared",
806805
"promlinter",
807806
"protogetter",
807+
"ptrequality",
808808
"reassign",
809809
"recvcheck",
810810
"revive",
@@ -946,17 +946,6 @@
946946
}
947947
}
948948
},
949-
"cmplintSettings": {
950-
"type": "object",
951-
"additionalProperties": false,
952-
"properties": {
953-
"check-is": {
954-
"description": "Suppress check for errors with \"Is\" method",
955-
"type": "boolean",
956-
"default": true
957-
}
958-
}
959-
},
960949
"cyclopSettings": {
961950
"type": "object",
962951
"additionalProperties": false,
@@ -2893,6 +2882,17 @@
28932882
}
28942883
}
28952884
},
2885+
"ptrequalitySettings": {
2886+
"type": "object",
2887+
"additionalProperties": false,
2888+
"properties": {
2889+
"check-is": {
2890+
"description": "Suppress check for errors with \"Is\" method",
2891+
"type": "boolean",
2892+
"default": true
2893+
}
2894+
}
2895+
},
28962896
"reviveSettings": {
28972897
"type": "object",
28982898
"additionalProperties": false,
@@ -4374,9 +4374,6 @@
43744374
"bidichk": {
43754375
"$ref": "#/definitions/settings/definitions/bidichkSettings"
43764376
},
4377-
"cmplint": {
4378-
"$ref": "#/definitions/settings/definitions/cmplintSettings"
4379-
},
43804377
"cyclop": {
43814378
"$ref": "#/definitions/settings/definitions/cyclopSettings"
43824379
},
@@ -4545,6 +4542,9 @@
45454542
"protogetter": {
45464543
"$ref": "#/definitions/settings/definitions/protogetterSettings"
45474544
},
4545+
"ptrequality": {
4546+
"$ref": "#/definitions/settings/definitions/ptrequalitySettings"
4547+
},
45484548
"revive": {
45494549
"$ref": "#/definitions/settings/definitions/reviveSettings"
45504550
},

pkg/config/linters_settings.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ var defaultLintersSettings = LintersSettings{
1212
Asasalint: AsasalintSettings{
1313
UseBuiltinExclusions: true,
1414
},
15-
Cmplint: CmplintSettings{
16-
CheckIs: true,
17-
},
1815
Decorder: DecorderSettings{
1916
DecOrder: []string{"type", "const", "var", "func"},
2017
DisableDecNumCheck: true,
@@ -140,6 +137,9 @@ var defaultLintersSettings = LintersSettings{
140137
Predeclared: PredeclaredSettings{
141138
Qualified: false,
142139
},
140+
PtrEquality: PtrEqualitySettings{
141+
CheckIs: true,
142+
},
143143
SlogLint: SlogLintSettings{
144144
NoMixedArgs: true,
145145
KVOnly: false,
@@ -212,7 +212,6 @@ type LintersSettings struct {
212212
BiDiChk BiDiChkSettings `mapstructure:"bidichk"`
213213
CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"`
214214
Cyclop CyclopSettings `mapstructure:"cyclop"`
215-
Cmplint CmplintSettings `mapstructure:"cmplint"`
216215
Decorder DecorderSettings `mapstructure:"decorder"`
217216
Depguard DepGuardSettings `mapstructure:"depguard"`
218217
Dogsled DogsledSettings `mapstructure:"dogsled"`
@@ -267,6 +266,7 @@ type LintersSettings struct {
267266
Predeclared PredeclaredSettings `mapstructure:"predeclared"`
268267
Promlinter PromlinterSettings `mapstructure:"promlinter"`
269268
ProtoGetter ProtoGetterSettings `mapstructure:"protogetter"`
269+
PtrEquality PtrEqualitySettings `mapstructure:"ptrequality"`
270270
Reassign ReassignSettings `mapstructure:"reassign"`
271271
Recvcheck RecvcheckSettings `mapstructure:"recvcheck"`
272272
Revive ReviveSettings `mapstructure:"revive"`
@@ -323,10 +323,6 @@ type BiDiChkSettings struct {
323323
PopDirectionalIsolate bool `mapstructure:"pop-directional-isolate"`
324324
}
325325

326-
type CmplintSettings struct {
327-
CheckIs bool `mapstructure:"check-is"`
328-
}
329-
330326
type CopyLoopVarSettings struct {
331327
CheckAlias bool `mapstructure:"check-alias"`
332328
}
@@ -769,6 +765,10 @@ type ProtoGetterSettings struct {
769765
ReplaceFirstArgInAppend bool `mapstructure:"replace-first-arg-in-append"`
770766
}
771767

768+
type PtrEqualitySettings struct {
769+
CheckIs bool `mapstructure:"check-is"`
770+
}
771+
772772
type ReassignSettings struct {
773773
Patterns []string `mapstructure:"patterns"`
774774
}

pkg/golinters/cmplint/cmplint.go

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package ptrequality
2+
3+
import (
4+
"fillmore-labs.com/cmplint/analyzer"
5+
6+
"github.com/golangci/golangci-lint/v2/pkg/config"
7+
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
8+
)
9+
10+
const (
11+
Name = "ptrequality"
12+
Doc = "Detect new pointers used within equality comparisons, making the result always false or undefined"
13+
)
14+
15+
func New(settings *config.PtrEqualitySettings) *goanalysis.Linter {
16+
a := *analyzer.Analyzer
17+
a.Name = Name
18+
a.Doc = Doc
19+
20+
var cfg map[string]any
21+
if settings != nil {
22+
cfg = map[string]any{
23+
"check-is": settings.CheckIs,
24+
}
25+
}
26+
27+
return goanalysis.NewLinterFromAnalyzer(&a).
28+
WithConfig(cfg).
29+
WithLoadMode(goanalysis.LoadModeTypesInfo)
30+
}

pkg/golinters/cmplint/cmplint_integration_test.go renamed to pkg/golinters/ptrequality/ptrequality_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cmplint
1+
package ptrequality
22

33
import (
44
"testing"

pkg/golinters/cmplint/testdata/cmplint.go renamed to pkg/golinters/ptrequality/testdata/ptrequality.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//golangcitest:args -Ecmplint
2-
//golangcitest:config_path testdata/cmplint.yml
1+
//golangcitest:args -Eptrequality
2+
//golangcitest:config_path testdata/ptrequality.yml
33
package main
44

55
import (

pkg/golinters/cmplint/testdata/cmplint.yml renamed to pkg/golinters/ptrequality/testdata/ptrequality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ version: "2"
22

33
linters:
44
settings:
5-
cmplint:
5+
ptrequality:
66
check-is: false

pkg/lint/lintersdb/builder_linter.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/golangci/golangci-lint/v2/pkg/golinters/bidichk"
1010
"github.com/golangci/golangci-lint/v2/pkg/golinters/bodyclose"
1111
"github.com/golangci/golangci-lint/v2/pkg/golinters/canonicalheader"
12-
"github.com/golangci/golangci-lint/v2/pkg/golinters/cmplint"
1312
"github.com/golangci/golangci-lint/v2/pkg/golinters/containedctx"
1413
"github.com/golangci/golangci-lint/v2/pkg/golinters/contextcheck"
1514
"github.com/golangci/golangci-lint/v2/pkg/golinters/copyloopvar"
@@ -90,6 +89,7 @@ import (
9089
"github.com/golangci/golangci-lint/v2/pkg/golinters/predeclared"
9190
"github.com/golangci/golangci-lint/v2/pkg/golinters/promlinter"
9291
"github.com/golangci/golangci-lint/v2/pkg/golinters/protogetter"
92+
"github.com/golangci/golangci-lint/v2/pkg/golinters/ptrequality"
9393
"github.com/golangci/golangci-lint/v2/pkg/golinters/reassign"
9494
"github.com/golangci/golangci-lint/v2/pkg/golinters/recvcheck"
9595
"github.com/golangci/golangci-lint/v2/pkg/golinters/revive"
@@ -169,11 +169,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
169169
WithAutoFix().
170170
WithURL("https://github.com/lasiar/canonicalheader"),
171171

172-
linter.NewConfig(cmplint.New(&cfg.Linters.Settings.Cmplint)).
173-
WithSince("v2.2.0").
174-
WithLoadForGoAnalysis().
175-
WithURL("https://github.com/fillmore-labs/cmplint"),
176-
177172
linter.NewConfig(containedctx.New()).
178173
WithSince("v1.44.0").
179174
WithLoadForGoAnalysis().
@@ -561,6 +556,11 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
561556
WithAutoFix().
562557
WithURL("https://github.com/ghostiam/protogetter"),
563558

559+
linter.NewConfig(ptrequality.New(&cfg.Linters.Settings.PtrEquality)).
560+
WithSince("v2.2.0").
561+
WithLoadForGoAnalysis().
562+
WithURL("https://github.com/fillmore-labs/cmplint"),
563+
564564
linter.NewConfig(reassign.New(&cfg.Linters.Settings.Reassign)).
565565
WithSince("v1.49.0").
566566
WithLoadForGoAnalysis().

0 commit comments

Comments
 (0)