Skip to content

Commit becee2f

Browse files
committed
feat: remove typecheck display as active linter
1 parent 96b9dae commit becee2f

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

pkg/lint/lintersdb/enabled_set.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ func (es EnabledSet) GetOptimizedLinters() ([]*linter.Config, error) {
144144
func (es EnabledSet) combineGoAnalysisLinters(linters map[string]*linter.Config) {
145145
var goanalysisLinters []*goanalysis.Linter
146146
goanalysisPresets := map[string]bool{}
147-
for _, linter := range linters {
148-
lnt, ok := linter.Linter.(*goanalysis.Linter)
147+
for _, lc := range linters {
148+
lnt, ok := lc.Linter.(*goanalysis.Linter)
149149
if !ok {
150150
continue
151151
}
@@ -154,7 +154,7 @@ func (es EnabledSet) combineGoAnalysisLinters(linters map[string]*linter.Config)
154154
continue
155155
}
156156
goanalysisLinters = append(goanalysisLinters, lnt)
157-
for _, p := range linter.InPresets {
157+
for _, p := range lc.InPresets {
158158
goanalysisPresets[p] = true
159159
}
160160
}
@@ -207,6 +207,10 @@ func (es EnabledSet) combineGoAnalysisLinters(linters map[string]*linter.Config)
207207
func (es EnabledSet) verbosePrintLintersStatus(lcs map[string]*linter.Config) {
208208
var linterNames []string
209209
for _, lc := range lcs {
210+
if lc.Internal {
211+
continue
212+
}
213+
210214
linterNames = append(linterNames, lc.Name())
211215
}
212216
sort.StringSlice(linterNames).Sort()

pkg/result/processors/nolint_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,15 @@ func TestNolintUnused(t *testing.T) {
279279
createProcessor := func(t *testing.T, log *logutils.MockLog, enabledLinters []string) *Nolint {
280280
enabledSetLog := logutils.NewMockLog()
281281
enabledSetLog.On("Infof", "Active %d linters: %s", len(enabledLinters), enabledLinters)
282+
282283
cfg := &config.Config{Linters: config.Linters{DisableAll: true, Enable: enabledLinters}}
283284
dbManager := lintersdb.NewManager(cfg, nil)
285+
284286
enabledLintersSet := lintersdb.NewEnabledSet(dbManager, lintersdb.NewValidator(dbManager), enabledSetLog, cfg)
287+
285288
enabledLintersMap, err := enabledLintersSet.GetEnabledLintersMap()
286289
assert.NoError(t, err)
290+
287291
return NewNolint(log, dbManager, enabledLintersMap)
288292
}
289293

@@ -310,21 +314,21 @@ func TestNolintUnused(t *testing.T) {
310314
}
311315

312316
t.Run("when an issue does not occur, it is not removed from the nolintlint issues", func(t *testing.T) {
313-
p := createProcessor(t, log, []string{"nolintlint", "typecheck", "varcheck"})
317+
p := createProcessor(t, log, []string{"nolintlint", "varcheck"})
314318
defer p.Finish()
315319

316320
processAssertSame(t, p, nolintlintIssueVarcheck)
317321
})
318322

319323
t.Run("when an issue does not occur but nolintlint is nolinted, it is removed from the nolintlint issues", func(t *testing.T) {
320-
p := createProcessor(t, log, []string{"nolintlint", "typecheck", "varcheck"})
324+
p := createProcessor(t, log, []string{"nolintlint", "varcheck"})
321325
defer p.Finish()
322326

323327
processAssertEmpty(t, p, nolintlintIssueVarcheckUnusedOK)
324328
})
325329

326330
t.Run("when an issue occurs, it is removed from the nolintlint issues", func(t *testing.T) {
327-
p := createProcessor(t, log, []string{"nolintlint", "typecheck", "varcheck"})
331+
p := createProcessor(t, log, []string{"nolintlint", "varcheck"})
328332
defer p.Finish()
329333

330334
processAssertEmpty(t, p, []result.Issue{{
@@ -338,7 +342,7 @@ func TestNolintUnused(t *testing.T) {
338342

339343
t.Run("when a linter is not enabled, it is removed from the nolintlint unused issues", func(t *testing.T) {
340344
enabledSetLog := logutils.NewMockLog()
341-
enabledSetLog.On("Infof", "Active %d linters: %s", 2, []string{"nolintlint", "typecheck"})
345+
enabledSetLog.On("Infof", "Active %d linters: %s", 1, []string{"nolintlint"})
342346

343347
cfg := &config.Config{Linters: config.Linters{DisableAll: true, Enable: []string{"nolintlint"}}}
344348
dbManager := lintersdb.NewManager(cfg, nil)

test/enabled_linters_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ func getEnabledByDefaultLinters() []string {
170170
ebdl := lintersdb.NewManager(nil, nil).GetAllEnabledByDefaultLinters()
171171
var ret []string
172172
for _, lc := range ebdl {
173+
if lc.Internal {
174+
continue
175+
}
176+
173177
ret = append(ret, lc.Name())
174178
}
175179

0 commit comments

Comments
 (0)