From 2c666ed4ebc4d75b46fa173eebb884af984954d0 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 9 Apr 2024 23:34:55 +0200 Subject: [PATCH] dev: group linter implementation and integration tests (#4603) --- .gitignore | 1 + .golangci.yml | 16 +- Makefile | 20 +- docs/src/docs/contributing/new-linters.mdx | 13 +- pkg/golinters/{ => asasalint}/asasalint.go | 4 +- .../asasalint/asasalint_integration_test.go | 11 + .../asasalint}/testdata/asasalint.go | 0 pkg/golinters/{ => asciicheck}/asciicheck.go | 4 +- .../asciicheck/asciicheck_integration_test.go | 11 + .../asciicheck}/testdata/asciicheck.go | 0 pkg/golinters/{ => bidichk}/bidichk.go | 4 +- .../bidichk/bidichk_integration_test.go | 11 + .../golinters/bidichk}/testdata/bidichk.go | 0 pkg/golinters/{ => bodyclose}/bodyclose.go | 4 +- .../bodyclose/bodyclose_integration_test.go | 11 + .../bodyclose}/testdata/bodyclose.go | 0 .../{ => containedctx}/containedctx.go | 4 +- .../containedctx_integration_test.go | 11 + .../containedctx}/testdata/containedctx.go | 0 .../{ => contextcheck}/contextcheck.go | 4 +- .../contextcheck_integration_test.go | 11 + .../contextcheck}/testdata/contextcheck.go | 0 .../{ => copyloopvar}/copyloopvar.go | 4 +- .../copyloopvar_integration_test.go | 11 + .../copyloopvar}/testdata/copyloopvar.go | 0 .../copyloopvar/testdata}/copyloopvar.yml | 0 .../testdata/copyloopvar_custom.go | 2 +- pkg/golinters/{ => cyclop}/cyclop.go | 4 +- .../cyclop/cyclop_integration_test.go | 11 + .../golinters/cyclop}/testdata/cyclop.go | 2 +- .../golinters/cyclop/testdata}/cyclop.yml | 0 pkg/golinters/{ => decorder}/decorder.go | 4 +- .../decorder/decorder_integration_test.go | 11 + .../golinters/decorder}/testdata/decorder.go | 0 .../decorder}/testdata/decorder_custom.go | 2 +- .../decorder/testdata}/decorder_custom.yml | 0 pkg/golinters/{ => depguard}/depguard.go | 4 +- .../depguard/depguard_integration_test.go | 11 + .../golinters/depguard}/testdata/depguard.go | 2 +- .../golinters/depguard/testdata}/depguard.yml | 0 .../testdata/depguard_additional_guards.go | 2 +- .../testdata}/depguard_additional_guards.yml | 0 .../testdata/depguard_ignore_file_rules.go | 2 +- .../testdata}/depguard_ignore_file_rules.yml | 0 pkg/golinters/{ => dogsled}/dogsled.go | 12 +- .../dogsled/dogsled_integration_test.go | 11 + .../golinters/dogsled}/testdata/dogsled.go | 0 pkg/golinters/{ => dupl}/dupl.go | 12 +- pkg/golinters/dupl/dupl_integration_test.go | 11 + {test => pkg/golinters/dupl}/testdata/dupl.go | 2 +- .../golinters/dupl/testdata}/dupl.yml | 0 pkg/golinters/{ => dupword}/dupword.go | 4 +- .../dupword/dupword_integration_test.go | 11 + .../golinters/dupword}/testdata/dupword.go | 0 .../dupword}/testdata/dupword_ignore_the.go | 2 +- .../dupword/testdata}/dupword_ignore_the.yml | 0 .../{ => durationcheck}/durationcheck.go | 4 +- .../durationcheck_integration_test.go | 11 + .../durationcheck}/testdata/durationcheck.go | 0 pkg/golinters/{ => err113}/err113.go | 4 +- .../err113/err113_integration_test.go | 11 + .../golinters/err113}/testdata/err113.go | 0 pkg/golinters/{ => errcheck}/errcheck.go | 12 +- .../errcheck/errcheck_integration_test.go | 11 + .../golinters/errcheck}/testdata/errcheck.go | 0 .../errcheck}/testdata/errcheck_exclude.go | 2 +- .../errcheck/testdata}/errcheck_exclude.txt | 0 .../errcheck/testdata}/errcheck_exclude.yml | 0 .../testdata/errcheck_exclude_functions.go | 2 +- .../testdata}/errcheck_exclude_functions.yml | 0 .../errcheck}/testdata/errcheck_ignore.go | 2 +- .../testdata}/errcheck_ignore_config.yml | 0 .../testdata/errcheck_ignore_default.go | 2 +- .../testdata}/errcheck_ignore_default.yml | 0 .../testdata/errcheck_type_assertions.go | 2 +- .../testdata}/errcheck_type_assertions.yml | 0 pkg/golinters/{ => errchkjson}/errchkjson.go | 4 +- .../errchkjson/errchkjson_integration_test.go | 11 + .../errchkjson}/testdata/errchkjson.go | 2 +- .../errchkjson/testdata}/errchkjson.yml | 0 .../errchkjson_check_error_free_encoding.go | 2 +- .../errchkjson_check_error_free_encoding.yml | 0 .../testdata/errchkjson_no_exported.go | 2 +- .../testdata}/errchkjson_no_exported.yml | 0 pkg/golinters/{ => errname}/errname.go | 4 +- .../errname/errname_integration_test.go | 11 + .../golinters/errname}/testdata/errname.go | 0 pkg/golinters/{ => errorlint}/errorlint.go | 4 +- .../errorlint/errorlint_integration_test.go | 11 + .../errorlint}/testdata/errorlint.go | 0 .../errorlint}/testdata/errorlint_asserts.go | 2 +- .../errorlint/testdata}/errorlint_asserts.yml | 0 .../testdata/errorlint_comparison.go | 2 +- .../testdata}/errorlint_comparison.yml | 0 .../errorlint}/testdata/errorlint_errorf.go | 2 +- .../errorlint/testdata}/errorlint_errorf.yml | 0 .../{ => execinquery}/execinquery.go | 4 +- .../execinquery_integration_test.go | 11 + .../execinquery}/testdata/execinquery.go | 0 pkg/golinters/{ => exhaustive}/exhaustive.go | 4 +- .../exhaustive/exhaustive_integration_test.go | 11 + .../exhaustive}/testdata/exhaustive.go | 0 .../testdata/exhaustive_default.go | 2 +- .../testdata}/exhaustive_default.yml | 0 .../testdata/exhaustive_generated.go | 0 .../exhaustive_ignore_enum_members.go | 2 +- .../exhaustive_ignore_enum_members.yml | 0 .../{ => exhaustruct}/exhaustruct.go | 4 +- .../exhaustruct_integration_test.go | 11 + .../exhaustruct}/testdata/exhaustruct.go | 0 .../exhaustruct/testdata}/exhaustruct.yml | 0 .../testdata/exhaustruct_custom.go | 2 +- .../{ => exportloopref}/exportloopref.go | 4 +- .../exportloopref_integration_test.go | 11 + .../exportloopref}/testdata/exportloopref.go | 0 pkg/golinters/{ => fatcontext}/fatcontext.go | 4 +- .../fatcontext/fatcontext_integration_test.go | 11 + .../fatcontext}/testdata/fatcontext.go | 0 pkg/golinters/{ => forbidigo}/forbidigo.go | 14 +- .../forbidigo/forbidigo_integration_test.go | 11 + .../forbidigo/testdata}/forbidigo.yml | 0 .../forbidigo}/testdata/forbidigo_example.go | 2 +- .../testdata/forbidigo_example_test.go | 2 +- .../forbidigo_include_godoc_examples.yml | 0 .../forbidigo_include_godoc_examples_test.go | 2 +- .../forbidigo/testdata}/forbidigo_struct.yml | 0 .../testdata/forbidigo_struct_config.go | 2 +- .../{ => forcetypeassert}/forcetypeassert.go | 4 +- .../forcetypeassert_integration_test.go | 11 + .../testdata/forcetypeassert.go | 0 pkg/golinters/{ => funlen}/funlen.go | 12 +- .../funlen/funlen_integration_test.go | 11 + .../golinters/funlen}/testdata/funlen.go | 2 +- .../golinters/funlen/testdata}/funlen.yml | 0 pkg/golinters/{ => gci}/gci.go | 12 +- pkg/golinters/gci/gci_integration_test.go | 19 + .../golinters/gci/testdata/fix/in}/gci.go | 8 +- .../golinters/gci/testdata/fix/out}/gci.go | 8 +- {test => pkg/golinters/gci}/testdata/gci.go | 2 +- .../golinters/gci/testdata}/gci.yml | 0 .../{ => ginkgolinter}/ginkgolinter.go | 4 +- .../ginkgolinter_integration_test.go | 11 + .../ginkgolinter/testdata}/ginkgolinter.go | 0 .../testdata}/ginkgolinter_allow_havelen0.yml | 0 .../testdata}/ginkgolinter_default.yml | 0 .../testdata}/ginkgolinter_havelen0.go | 2 +- .../testdata}/ginkgolinter_suppress_async.go | 2 +- .../testdata}/ginkgolinter_suppress_async.yml | 0 .../ginkgolinter_suppress_compare.go | 2 +- .../ginkgolinter_suppress_compare.yml | 0 .../testdata}/ginkgolinter_suppress_err.go | 2 +- .../testdata}/ginkgolinter_suppress_err.yml | 0 ...inkgolinter_suppress_focused_containers.go | 2 +- ...nkgolinter_suppress_focused_containers.yml | 0 .../testdata}/ginkgolinter_suppress_len.go | 2 +- .../testdata}/ginkgolinter_suppress_len.yml | 0 .../testdata}/ginkgolinter_suppress_nil.go | 2 +- .../testdata}/ginkgolinter_suppress_nil.yml | 0 .../golinters/ginkgolinter/testdata}/go.mod | 0 .../golinters/ginkgolinter/testdata}/go.sum | 0 .../gocheckcompilerdirectives.go | 4 +- ...heckcompilerdirectives_integration_test.go | 11 + .../testdata/gocheckcompilerdirectives.go | 0 .../gochecknoglobals.go | 4 +- .../gochecknoglobals_integration_test.go | 11 + .../testdata/gochecknoglobals.go | 0 .../{ => gochecknoinits}/gochecknoinits.go | 12 +- .../gochecknoinits_integration_test.go | 11 + .../testdata/gochecknoinits.go | 0 .../{ => gochecksumtype}/gochecksumtype.go | 12 +- .../gochecksumtype_integration_test.go | 11 + .../testdata/gochecksumtype.go | 0 pkg/golinters/{ => gocognit}/gocognit.go | 10 +- .../gocognit/gocognit_integration_test.go | 11 + .../golinters/gocognit}/testdata/gocognit.go | 2 +- .../golinters/gocognit/testdata}/gocognit.yml | 0 pkg/golinters/{ => goconst}/goconst.go | 12 +- .../goconst/goconst_integration_test.go | 11 + .../golinters/goconst}/testdata/goconst.go | 0 .../testdata/goconst_calls_enabled.go | 2 +- .../testdata}/goconst_calls_enabled.yml | 0 .../goconst/testdata}/goconst_dont_ignore.yml | 0 .../testdata/goconst_dont_ignore_test.go | 2 +- .../goconst/testdata}/goconst_ignore.yml | 0 .../goconst}/testdata/goconst_ignore_test.go | 2 +- pkg/golinters/{ => gocritic}/gocritic.go | 115 +++--- .../gocritic/gocritic_integration_test.go | 19 + pkg/golinters/{ => gocritic}/gocritic_test.go | 10 +- .../gocritic}/testdata/fix/in/gocritic.go | 2 +- .../gocritic}/testdata/fix/out/gocritic.go | 2 +- .../gocritic/testdata/gocritic-fix.yml | 8 + .../golinters/gocritic}/testdata/gocritic.go | 2 +- .../golinters/gocritic/testdata}/gocritic.yml | 2 +- .../gocritic/testdata}/ruleguard/README.md | 10 +- .../testdata}/ruleguard/preferWriteString.go | 0 .../testdata}/ruleguard/rangeExprCopy.go | 0 .../testdata}/ruleguard/stringsSimplify.go | 0 pkg/golinters/{ => gocyclo}/gocyclo.go | 12 +- .../gocyclo/gocyclo_integration_test.go | 11 + .../golinters/gocyclo}/testdata/gocyclo.go | 2 +- .../golinters/gocyclo/testdata}/gocyclo.yml | 0 pkg/golinters/{ => godot}/godot.go | 12 +- pkg/golinters/godot/godot_integration_test.go | 19 + .../golinters/godot}/testdata/fix/in/godot.go | 0 .../godot}/testdata/fix/out/godot.go | 0 .../golinters/godot}/testdata/godot.go | 0 pkg/golinters/{ => godox}/godox.go | 12 +- pkg/golinters/godox/godox_integration_test.go | 11 + .../golinters/godox}/testdata/godox.go | 2 +- .../golinters/godox/testdata}/godox.yml | 0 pkg/golinters/{ => gofmt}/gofmt.go | 12 +- pkg/golinters/gofmt/gofmt_integration_test.go | 19 + .../golinters/gofmt}/testdata/fix/in/gofmt.go | 0 .../testdata/fix/in/gofmt_rewrite_rules.go | 2 +- .../gofmt}/testdata/fix/out/gofmt.go | 0 .../testdata/fix/out/gofmt_rewrite_rules.go | 2 +- .../golinters/gofmt}/testdata/gofmt.go | 0 .../gofmt}/testdata/gofmt_no_simplify.go | 2 +- .../gofmt/testdata}/gofmt_no_simplify.yml | 0 .../gofmt}/testdata/gofmt_rewrite_rules.go | 2 +- .../gofmt/testdata}/gofmt_rewrite_rules.yml | 0 pkg/golinters/{ => gofumpt}/gofumpt.go | 12 +- .../gofumpt/gofumpt_integration_test.go | 19 + .../gofumpt}/testdata/fix/in/gofumpt.go | 2 +- .../gofumpt}/testdata/fix/out/gofumpt.go | 2 +- .../gofumpt/testdata}/gofumpt-fix.yml | 0 .../golinters/gofumpt}/testdata/gofumpt.go | 0 .../gofumpt}/testdata/gofumpt_with_extra.go | 2 +- .../gofumpt/testdata}/gofumpt_with_extra.yml | 0 pkg/golinters/{ => goheader}/goheader.go | 12 +- .../goheader/goheader_integration_test.go | 19 + .../goheader}/testdata/fix/in/goheader_1.go | 2 +- .../goheader}/testdata/fix/in/goheader_2.go | 2 +- .../goheader}/testdata/fix/in/goheader_3.go | 2 +- .../goheader}/testdata/fix/out/goheader_1.go | 2 +- .../goheader}/testdata/fix/out/goheader_2.go | 2 +- .../goheader}/testdata/fix/out/goheader_3.go | 2 +- .../goheader/testdata}/goheader-fix.yml | 0 .../golinters/goheader/testdata}/goheader.yml | 0 .../goheader}/testdata/goheader_bad.go | 2 +- .../goheader}/testdata/goheader_good.go | 2 +- pkg/golinters/{ => goimports}/goimports.go | 12 +- .../goimports/goimports_integration_test.go | 19 + .../goimports}/testdata/fix/in/goimports.go | 0 .../goimports}/testdata/fix/out/goimports.go | 0 .../goimports}/testdata/goimports.go | 0 .../goimports}/testdata/goimports_local.go | 2 +- .../goimports/testdata}/goimports_local.yml | 0 .../{ => gomoddirectives}/gomoddirectives.go | 13 +- pkg/golinters/{ => gomodguard}/gomodguard.go | 15 +- .../gomodguard/gomodguard_integration_test.go | 11 + .../gomodguard}/testdata/gomodguard.go | 2 +- .../gomodguard/testdata}/gomodguard.yml | 0 .../goprintffuncname.go | 4 +- .../goprintffuncname_integration_test.go | 11 + .../testdata/goprintffuncname.go | 0 pkg/golinters/{ => gosec}/gosec.go | 12 +- pkg/golinters/gosec/gosec_integration_test.go | 11 + pkg/golinters/{ => gosec}/gosec_test.go | 2 +- .../golinters/gosec}/testdata/gosec.go | 0 .../golinters/gosec/testdata}/gosec.yml | 0 .../gosec}/testdata/gosec_global_option.go | 2 +- .../gosec/testdata}/gosec_global_option.yml | 0 .../gosec}/testdata/gosec_rules_config.go | 2 +- .../testdata/gosec_severity_confidence.go | 2 +- .../testdata}/gosec_severity_confidence.yml | 0 pkg/golinters/{ => gosimple}/gosimple.go | 4 +- .../gosimple/gosimple_integration_test.go | 11 + .../golinters/gosimple}/testdata/gosimple.go | 0 .../{ => gosmopolitan}/gosmopolitan.go | 4 +- .../gosmopolitan_integration_test.go | 11 + .../gosmopolitan}/testdata/gosmopolitan.go | 0 .../testdata/gosmopolitan_allow_time_local.go | 2 +- .../gosmopolitan_allow_time_local.yml | 0 .../testdata/gosmopolitan_dont_ignore_test.go | 2 +- .../gosmopolitan_dont_ignore_tests.yml | 0 .../testdata/gosmopolitan_escape_hatches.go | 2 +- .../testdata}/gosmopolitan_escape_hatches.yml | 0 .../testdata/gosmopolitan_ignore_test.go | 0 .../testdata/gosmopolitan_scripts.go | 2 +- .../testdata}/gosmopolitan_scripts.yml | 0 pkg/golinters/{ => govet}/govet.go | 12 +- pkg/golinters/govet/govet_integration_test.go | 11 + pkg/golinters/{ => govet}/govet_test.go | 2 +- .../golinters/govet}/testdata/govet.go | 2 +- .../golinters/govet/testdata}/govet.yml | 0 .../govet}/testdata/govet_custom_formatter.go | 0 .../govet}/testdata/govet_fieldalignment.go | 2 +- .../govet/testdata}/govet_fieldalignment.yml | 0 .../govet}/testdata/govet_ifaceassert.go | 2 +- .../govet/testdata}/govet_ifaceassert.yml | 0 pkg/golinters/{ => grouper}/grouper.go | 4 +- .../grouper/grouper_integration_test.go | 11 + .../golinters/grouper}/testdata/grouper.go | 2 +- .../golinters/grouper/testdata}/grouper.yml | 0 pkg/golinters/{ => importas}/importas.go | 4 +- .../importas/importas_integration_test.go | 11 + .../golinters/importas}/testdata/importas.go | 2 +- .../golinters/importas/testdata}/importas.yml | 0 .../importas}/testdata/importas_strict.go | 2 +- .../importas/testdata}/importas_strict.yml | 0 .../{ => inamedparam}/inamedparam.go | 4 +- .../inamedparam_integration_test.go | 11 + .../inamedparam}/testdata/inamedparam.go | 0 .../testdata/inamedparam_skip_single_param.go | 2 +- .../inamedparam_skip_single_param.yml | 0 .../{ => ineffassign}/ineffassign.go | 4 +- .../ineffassign_integration_test.go | 11 + .../ineffassign}/testdata/ineffassign.go | 0 .../{ => interfacebloat}/interfacebloat.go | 4 +- .../interfacebloat_integration_test.go | 11 + .../testdata/interfacebloat.go | 0 pkg/golinters/{ => intrange}/intrange.go | 4 +- .../intrange/intrange_integration_test.go | 11 + .../golinters/intrange}/testdata/intrange.go | 0 pkg/golinters/{ => ireturn}/ireturn.go | 4 +- .../ireturn/ireturn_integration_test.go | 11 + .../golinters/ireturn}/testdata/ireturn.go | 0 .../ireturn}/testdata/ireturn_allow.go | 2 +- .../ireturn/testdata}/ireturn_allow.yml | 0 .../testdata/ireturn_reject_generics.go | 2 +- .../testdata}/ireturn_reject_generics.yml | 0 .../testdata/ireturn_reject_stdlib.go | 2 +- .../testdata}/ireturn_reject_stdlib.yml | 0 pkg/golinters/{ => lll}/lll.go | 14 +- pkg/golinters/lll/lll_integration_test.go | 11 + {test => pkg/golinters/lll}/testdata/lll.go | 2 +- .../golinters/lll/testdata}/lll.yml | 0 .../golinters/lll/testdata}/lll_import.yml | 0 .../lll}/testdata/lll_import_multi.go | 2 +- .../lll}/testdata/lll_import_single.go | 2 +- .../{ => loggercheck}/loggercheck.go | 4 +- .../loggercheck_integration_test.go | 11 + .../golinters/loggercheck/testdata}/go.mod | 0 .../golinters/loggercheck/testdata}/go.sum | 0 .../testdata}/loggercheck_custom.go | 2 +- .../testdata}/loggercheck_custom.yml | 0 .../testdata}/loggercheck_default.go | 0 .../testdata}/loggercheck_kitlogonly.go | 2 +- .../testdata}/loggercheck_kitlogonly.yml | 0 .../testdata}/loggercheck_logronly.go | 2 +- .../testdata}/loggercheck_logronly.yml | 0 .../testdata}/loggercheck_noprintflike.go | 2 +- .../testdata}/loggercheck_noprintflike.yml | 0 .../testdata}/loggercheck_requirestringkey.go | 2 +- .../loggercheck_requirestringkey.yml | 0 .../testdata}/loggercheck_zaponly.go | 2 +- .../testdata}/loggercheck_zaponly.yml | 0 .../testdata}/logrlint_compatiblity.go | 0 pkg/golinters/{ => maintidx}/maintidx.go | 4 +- .../maintidx/maintidx_integration_test.go | 11 + .../golinters/maintidx}/testdata/maintidx.go | 0 .../maintidx}/testdata/maintidx_under_100.go | 2 +- .../maintidx/testdata}/maintidx_under_100.yml | 0 pkg/golinters/{ => makezero}/makezero.go | 12 +- .../makezero/makezero_integration_test.go | 11 + .../golinters/makezero}/testdata/makezero.go | 0 .../makezero}/testdata/makezero_always.go | 2 +- .../makezero/testdata}/makezero_always.yml | 0 pkg/golinters/{ => mirror}/mirror.go | 4 +- .../mirror/mirror_integration_test.go | 19 + .../mirror}/testdata/fix/in/mirror.go | 0 .../mirror}/testdata/fix/out/mirror.go | 0 .../golinters/mirror}/testdata/mirror.go | 0 pkg/golinters/{ => misspell}/misspell.go | 12 +- .../misspell/misspell_integration_test.go | 19 + pkg/golinters/{ => misspell}/misspell_test.go | 2 +- .../misspell}/testdata/fix/in/misspell.go | 0 .../misspell}/testdata/fix/out/misspell.go | 0 .../golinters/misspell}/testdata/misspell.go | 2 +- .../golinters/misspell/testdata}/misspell.yml | 0 .../misspell}/testdata/misspell_custom.go | 2 +- .../misspell/testdata}/misspell_custom.yml | 0 pkg/golinters/{ => mnd}/mnd.go | 4 +- pkg/golinters/mnd/mnd_integration_test.go | 11 + {test => pkg/golinters/mnd}/testdata/mnd.go | 0 pkg/golinters/{ => musttag}/musttag.go | 4 +- .../musttag/musttag_integration_test.go | 11 + .../golinters/musttag}/testdata/musttag.go | 0 .../golinters/musttag/testdata}/musttag.yml | 0 .../musttag}/testdata/musttag_custom.go | 2 +- pkg/golinters/{ => nakedret}/nakedret.go | 4 +- .../nakedret/nakedret_integration_test.go | 11 + .../golinters/nakedret}/testdata/nakedret.go | 0 pkg/golinters/{ => nestif}/nestif.go | 10 +- .../nestif/nestif_integration_test.go | 11 + .../golinters/nestif}/testdata/nestif.go | 2 +- .../golinters/nestif/testdata}/nestif.yml | 0 pkg/golinters/{ => nilerr}/nilerr.go | 4 +- .../nilerr/nilerr_integration_test.go | 11 + .../golinters/nilerr}/testdata/nilerr.go | 0 pkg/golinters/{ => nilnil}/nilnil.go | 4 +- .../nilnil/nilnil_integration_test.go | 11 + .../golinters/nilnil}/testdata/nilnil.go | 0 pkg/golinters/{ => nlreturn}/nlreturn.go | 4 +- .../nlreturn/nlreturn_integration_test.go | 11 + .../nlreturn}/testdata/nlreturn-block-size.go | 2 +- .../golinters/nlreturn}/testdata/nlreturn.go | 0 .../golinters/nlreturn/testdata}/nlreturn.yml | 0 pkg/golinters/{ => noctx}/noctx.go | 4 +- pkg/golinters/noctx/noctx_integration_test.go | 11 + .../golinters/noctx}/testdata/noctx.go | 0 pkg/golinters/nolintlint.go | 104 ------ .../nolintlint/{ => internal}/README.md | 0 .../nolintlint/internal/nolintlint.go | 304 +++++++++++++++ .../{ => internal}/nolintlint_test.go | 2 +- pkg/golinters/nolintlint/nolintlint.go | 346 ++++-------------- .../{ => nonamedreturns}/nonamedreturns.go | 4 +- .../nonamedreturns_integration_test.go | 11 + .../testdata/nonamedreturns.go | 0 .../testdata/nonamedreturns_custom.go | 2 +- .../testdata}/nonamedreturns_custom.yml | 0 .../nosprintfhostport.go | 4 +- .../nosprintfhostport_integration_test.go | 11 + .../testdata/nosprintfhostport.go | 0 .../{ => paralleltest}/paralleltest.go | 4 +- .../paralleltest_integration_test.go | 11 + .../paralleltest}/testdata/paralleltest.go | 0 .../testdata/paralleltest_custom.go | 2 +- .../testdata}/paralleltest_custom.yml | 0 pkg/golinters/{ => perfsprint}/perfsprint.go | 4 +- .../perfsprint/perfsprint_integration_test.go | 11 + .../perfsprint}/testdata/perfsprint.go | 0 .../perfsprint}/testdata/perfsprint_custom.go | 2 +- .../testdata}/perfsprint_custom.yml | 0 pkg/golinters/{ => prealloc}/prealloc.go | 12 +- .../prealloc/prealloc_integration_test.go | 11 + .../golinters/prealloc}/testdata/prealloc.go | 0 .../{ => predeclared}/predeclared.go | 4 +- .../predeclared_integration_test.go | 11 + .../predeclared}/testdata/predeclared.go | 0 .../testdata/predeclared_custom.go | 2 +- .../testdata}/predeclared_custom.yml | 0 pkg/golinters/{ => promlinter}/promlinter.go | 12 +- .../promlinter/promlinter_integration_test.go | 11 + .../promlinter}/testdata/promlinter.go | 0 .../{ => protogetter}/protogetter.go | 4 +- .../protogetter_integration_test.go | 11 + .../golinters/protogetter/testdata}/go.mod | 0 .../golinters/protogetter/testdata}/go.sum | 0 .../protogetter/testdata}/proto/test.go | 0 .../protogetter/testdata}/proto/test.pb.go | 0 .../protogetter/testdata}/proto/test.proto | 0 .../testdata}/proto/test_grpc.pb.go | 0 .../protogetter/testdata}/protogetter.go | 0 pkg/golinters/{ => reassign}/reassign.go | 4 +- .../reassign/reassign_integration_test.go | 11 + .../golinters/reassign}/testdata/reassign.go | 0 .../reassign}/testdata/reassign_patterns.go | 2 +- .../reassign/testdata}/reassign_patterns.yml | 0 pkg/golinters/{ => revive}/revive.go | 17 +- .../revive/revive_integration_test.go | 11 + .../golinters/revive}/testdata/revive.go | 2 +- .../golinters/revive/testdata}/revive.yml | 0 .../revive}/testdata/revive_default.go | 0 .../{ => rowserrcheck}/rowserrcheck.go | 4 +- .../rowserrcheck_integration_test.go | 11 + .../rowserrcheck}/testdata/rowserrcheck.go | 0 pkg/golinters/{ => sloglint}/sloglint.go | 4 +- .../sloglint/sloglint_integration_test.go | 11 + .../golinters/sloglint}/testdata/sloglint.go | 0 .../testdata/sloglint_args_on_sep_lines.go | 2 +- .../testdata}/sloglint_args_on_sep_lines.yml | 0 .../sloglint}/testdata/sloglint_attr_only.go | 2 +- .../sloglint/testdata}/sloglint_attr_only.yml | 0 .../testdata/sloglint_context_only.go | 2 +- .../testdata}/sloglint_context_only.yml | 0 .../testdata/sloglint_key_naming_case.go | 2 +- .../testdata}/sloglint_key_naming_case.yml | 0 .../sloglint}/testdata/sloglint_kv_only.go | 2 +- .../sloglint/testdata}/sloglint_kv_only.yml | 0 .../testdata/sloglint_no_raw_keys.go | 2 +- .../testdata}/sloglint_no_raw_keys.yml | 0 .../sloglint}/testdata/sloglint_static_msg.go | 2 +- .../testdata}/sloglint_static_msg.yml | 0 pkg/golinters/{ => spancheck}/spancheck.go | 4 +- .../spancheck/spancheck_integration_test.go | 11 + .../golinters/spancheck/testdata}/go.mod | 0 .../golinters/spancheck/testdata}/go.sum | 0 .../spancheck/testdata}/spancheck_default.go | 0 .../testdata}/spancheck_enable_all.go | 2 +- .../testdata}/spancheck_enable_all.yml | 0 .../{ => sqlclosecheck}/sqlclosecheck.go | 4 +- .../sqlclosecheck_integration_test.go | 11 + .../sqlclosecheck}/testdata/sqlclosecheck.go | 0 .../{ => staticcheck}/staticcheck.go | 4 +- .../staticcheck_integration_test.go | 11 + .../staticcheck}/testdata/staticcheck.go | 0 .../testdata/staticcheck_in_megacheck.go | 0 pkg/golinters/{ => stylecheck}/stylecheck.go | 4 +- .../stylecheck/stylecheck_integration_test.go | 11 + .../stylecheck}/testdata/stylecheck.go | 0 .../testdata/stylecheck_not_in_megacheck.go | 0 pkg/golinters/{ => tagalign}/tagalign.go | 4 +- .../tagalign/tagalign_integration_test.go | 19 + .../tagalign}/testdata/fix/in/tagalign.go | 2 +- .../tagalign}/testdata/fix/out/tagalign.go | 2 +- .../golinters/tagalign}/testdata/tagalign.go | 0 .../tagalign}/testdata/tagalign_align_only.go | 2 +- .../testdata}/tagalign_align_only.yml | 0 .../tagalign}/testdata/tagalign_order_only.go | 2 +- .../testdata}/tagalign_order_only.yml | 0 .../tagalign}/testdata/tagalign_sort_only.go | 2 +- .../tagalign/testdata}/tagalign_sort_only.yml | 0 .../tagalign}/testdata/tagalign_strict.go | 2 +- .../tagalign/testdata}/tagalign_strict.yml | 0 .../{ => tagliatelle}/tagliatelle.go | 4 +- .../tagliatelle_integration_test.go | 11 + .../tagliatelle}/testdata/tagliatelle.go | 0 pkg/golinters/{ => tenv}/tenv.go | 4 +- pkg/golinters/tenv/tenv_integration_test.go | 11 + {test => pkg/golinters/tenv}/testdata/tenv.go | 2 +- .../golinters/tenv}/testdata/tenv_all.go | 2 +- .../golinters/tenv/testdata}/tenv_all.yml | 0 .../golinters/tenv}/testdata/tenv_all_test.go | 2 +- .../golinters/tenv}/testdata/tenv_fuzz.go | 0 .../golinters/tenv}/testdata/tenv_test.go | 0 .../testableexamples.go | 4 +- .../testableexamples_integration_test.go | 11 + .../testdata/testableexamples_test.go | 0 .../testifylint}/testdata/testifylint.go | 0 .../testdata/testifylint_bool_compare_only.go | 2 +- .../testifylint_bool_compare_only.yml | 0 .../testifylint_require_error_only.go | 2 +- .../testifylint_require_error_only.yml | 0 .../{ => testifylint}/testifylint.go | 4 +- .../testifylint_integration_test.go | 11 + .../testpackage}/testdata/testpackage_test.go | 0 .../{ => testpackage}/testpackage.go | 4 +- .../testpackage_integration_test.go | 11 + .../golinters/thelper}/testdata/thelper.go | 0 .../golinters/thelper/testdata}/thelper.yml | 0 .../thelper}/testdata/thelper_fuzz.go | 0 .../thelper}/testdata/thelper_with_options.go | 2 +- pkg/golinters/{ => thelper}/thelper.go | 4 +- .../thelper/thelper_integration_test.go | 11 + .../testdata/tparallel_happy_path_test.go | 0 .../tparallel_missing_subtest_test.go | 0 .../tparallel_missing_toplevel_test.go | 0 pkg/golinters/{ => tparallel}/tparallel.go | 4 +- .../tparallel/tparallel_integration_test.go | 11 + .../unconvert}/testdata/unconvert.go | 0 pkg/golinters/{ => unconvert}/unconvert.go | 12 +- .../unconvert/unconvert_integration_test.go | 11 + .../golinters/unparam}/testdata/unparam.go | 0 pkg/golinters/{ => unparam}/unparam.go | 12 +- .../unparam/unparam_integration_test.go | 11 + .../golinters/unused}/testdata/unused.go | 0 pkg/golinters/{ => unused}/unused.go | 12 +- .../unused/unused_integration_test.go | 11 + .../usestdlibvars}/testdata/usestdlibvars.go | 0 .../testdata/usestdlibvars_non_default.go | 2 +- .../testdata}/usestdlibvars_non_default.yml | 0 .../{ => usestdlibvars}/usestdlibvars.go | 4 +- .../usestdlibvars_integration_test.go | 11 + .../varnamelen}/testdata/varnamelen.go | 0 pkg/golinters/{ => varnamelen}/varnamelen.go | 4 +- .../varnamelen/varnamelen_integration_test.go | 11 + .../wastedassign}/testdata/wastedassign.go | 0 .../{ => wastedassign}/wastedassign.go | 4 +- .../wastedassign_integration_test.go | 11 + .../whitespace}/testdata/fix/in/whitespace.go | 2 +- .../testdata/fix/out/whitespace.go | 2 +- .../whitespace/testdata}/whitespace-fix.yml | 0 pkg/golinters/{ => whitespace}/whitespace.go | 8 +- .../whitespace/whitespace_integration_test.go | 15 + .../wrapcheck}/testdata/wrapcheck.go | 0 pkg/golinters/{ => wrapcheck}/wrapcheck.go | 4 +- .../wrapcheck/wrapcheck_integration_test.go | 11 + {test => pkg/golinters/wsl}/testdata/wsl.go | 2 +- .../golinters/wsl/testdata}/wsl.yml | 0 pkg/golinters/{ => wsl}/wsl.go | 4 +- pkg/golinters/wsl/wsl_integration_test.go | 11 + .../golinters/zerologlint/testdata}/go.mod | 0 .../golinters/zerologlint/testdata}/go.sum | 0 .../zerologlint/testdata}/zerologlint.go | 0 .../{ => zerologlint}/zerologlint.go | 4 +- .../zerologlint_integration_test.go | 11 + pkg/lint/lintersdb/builder_linter.go | 320 ++++++++++------ pkg/result/processors/nolint.go | 10 +- pkg/result/processors/nolint_test.go | 6 +- test/configuration_file_test.go | 5 + test/enabled_linters_test.go | 3 +- test/fix_test.go | 107 +----- test/linters_test.go | 122 +----- test/output_test.go | 14 +- test/run_test.go | 25 +- test/testdata/configs/gocritic-fix.yml | 7 - test/testdata/configs/output.yml | 6 + test/testdata/output.go | 10 + test/testshared/analysis.go | 4 + test/testshared/install.go | 121 ++++++ test/testshared/integration/fix.go | 93 +++++ test/testshared/integration/run.go | 116 ++++++ test/testshared/runner.go | 31 +- test/testshared/runner_unix.go | 8 +- test/testshared/runner_windows.go | 7 +- 597 files changed, 2788 insertions(+), 1353 deletions(-) rename pkg/golinters/{ => asasalint}/asasalint.go (88%) create mode 100644 pkg/golinters/asasalint/asasalint_integration_test.go rename {test => pkg/golinters/asasalint}/testdata/asasalint.go (100%) rename pkg/golinters/{ => asciicheck}/asciicheck.go (83%) create mode 100644 pkg/golinters/asciicheck/asciicheck_integration_test.go rename {test => pkg/golinters/asciicheck}/testdata/asciicheck.go (100%) rename pkg/golinters/{ => bidichk}/bidichk.go (94%) create mode 100644 pkg/golinters/bidichk/bidichk_integration_test.go rename {test => pkg/golinters/bidichk}/testdata/bidichk.go (100%) rename pkg/golinters/{ => bodyclose}/bodyclose.go (85%) create mode 100644 pkg/golinters/bodyclose/bodyclose_integration_test.go rename {test => pkg/golinters/bodyclose}/testdata/bodyclose.go (100%) rename pkg/golinters/{ => containedctx}/containedctx.go (82%) create mode 100644 pkg/golinters/containedctx/containedctx_integration_test.go rename {test => pkg/golinters/containedctx}/testdata/containedctx.go (100%) rename pkg/golinters/{ => contextcheck}/contextcheck.go (89%) create mode 100644 pkg/golinters/contextcheck/contextcheck_integration_test.go rename {test => pkg/golinters/contextcheck}/testdata/contextcheck.go (100%) rename pkg/golinters/{ => copyloopvar}/copyloopvar.go (84%) create mode 100644 pkg/golinters/copyloopvar/copyloopvar_integration_test.go rename {test => pkg/golinters/copyloopvar}/testdata/copyloopvar.go (100%) rename {test/testdata/configs => pkg/golinters/copyloopvar/testdata}/copyloopvar.yml (100%) rename {test => pkg/golinters/copyloopvar}/testdata/copyloopvar_custom.go (93%) rename pkg/golinters/{ => cyclop}/cyclop.go (90%) create mode 100644 pkg/golinters/cyclop/cyclop_integration_test.go rename {test => pkg/golinters/cyclop}/testdata/cyclop.go (89%) rename {test/testdata/configs => pkg/golinters/cyclop/testdata}/cyclop.yml (100%) rename pkg/golinters/{ => decorder}/decorder.go (93%) create mode 100644 pkg/golinters/decorder/decorder_integration_test.go rename {test => pkg/golinters/decorder}/testdata/decorder.go (100%) rename {test => pkg/golinters/decorder}/testdata/decorder_custom.go (85%) rename {test/testdata/configs => pkg/golinters/decorder/testdata}/decorder_custom.yml (100%) rename pkg/golinters/{ => depguard}/depguard.go (92%) create mode 100644 pkg/golinters/depguard/depguard_integration_test.go rename {test => pkg/golinters/depguard}/testdata/depguard.go (89%) rename {test/testdata/configs => pkg/golinters/depguard/testdata}/depguard.yml (100%) rename {test => pkg/golinters/depguard}/testdata/depguard_additional_guards.go (90%) rename {test/testdata/configs => pkg/golinters/depguard/testdata}/depguard_additional_guards.yml (100%) rename {test => pkg/golinters/depguard}/testdata/depguard_ignore_file_rules.go (79%) rename {test/testdata/configs => pkg/golinters/depguard/testdata}/depguard_ignore_file_rules.yml (100%) rename pkg/golinters/{ => dogsled}/dogsled.go (91%) create mode 100644 pkg/golinters/dogsled/dogsled_integration_test.go rename {test => pkg/golinters/dogsled}/testdata/dogsled.go (100%) rename pkg/golinters/{ => dupl}/dupl.go (92%) create mode 100644 pkg/golinters/dupl/dupl_integration_test.go rename {test => pkg/golinters/dupl}/testdata/dupl.go (93%) rename {test/testdata/configs => pkg/golinters/dupl/testdata}/dupl.yml (100%) rename pkg/golinters/{ => dupword}/dupword.go (87%) create mode 100644 pkg/golinters/dupword/dupword_integration_test.go rename {test => pkg/golinters/dupword}/testdata/dupword.go (100%) rename {test => pkg/golinters/dupword}/testdata/dupword_ignore_the.go (86%) rename {test/testdata/configs => pkg/golinters/dupword/testdata}/dupword_ignore_the.yml (100%) rename pkg/golinters/{ => durationcheck}/durationcheck.go (82%) create mode 100644 pkg/golinters/durationcheck/durationcheck_integration_test.go rename {test => pkg/golinters/durationcheck}/testdata/durationcheck.go (100%) rename pkg/golinters/{ => err113}/err113.go (85%) create mode 100644 pkg/golinters/err113/err113_integration_test.go rename {test => pkg/golinters/err113}/testdata/err113.go (100%) rename pkg/golinters/{ => errcheck}/errcheck.go (96%) create mode 100644 pkg/golinters/errcheck/errcheck_integration_test.go rename {test => pkg/golinters/errcheck}/testdata/errcheck.go (100%) rename {test => pkg/golinters/errcheck}/testdata/errcheck_exclude.go (82%) rename {test/testdata/configs => pkg/golinters/errcheck/testdata}/errcheck_exclude.txt (100%) rename {test/testdata/configs => pkg/golinters/errcheck/testdata}/errcheck_exclude.yml (100%) rename {test => pkg/golinters/errcheck}/testdata/errcheck_exclude_functions.go (82%) rename {test/testdata/configs => pkg/golinters/errcheck/testdata}/errcheck_exclude_functions.yml (100%) rename {test => pkg/golinters/errcheck}/testdata/errcheck_ignore.go (86%) rename {test/testdata/configs => pkg/golinters/errcheck/testdata}/errcheck_ignore_config.yml (100%) rename {test => pkg/golinters/errcheck}/testdata/errcheck_ignore_default.go (85%) rename {test/testdata/configs => pkg/golinters/errcheck/testdata}/errcheck_ignore_default.yml (100%) rename {test => pkg/golinters/errcheck}/testdata/errcheck_type_assertions.go (75%) rename {test/testdata/configs => pkg/golinters/errcheck/testdata}/errcheck_type_assertions.yml (100%) rename pkg/golinters/{ => errchkjson}/errchkjson.go (87%) create mode 100644 pkg/golinters/errchkjson/errchkjson_integration_test.go rename {test => pkg/golinters/errchkjson}/testdata/errchkjson.go (99%) rename {test/testdata/configs => pkg/golinters/errchkjson/testdata}/errchkjson.yml (100%) rename {test => pkg/golinters/errchkjson}/testdata/errchkjson_check_error_free_encoding.go (99%) rename {test/testdata/configs => pkg/golinters/errchkjson/testdata}/errchkjson_check_error_free_encoding.yml (100%) rename {test => pkg/golinters/errchkjson}/testdata/errchkjson_no_exported.go (92%) rename {test/testdata/configs => pkg/golinters/errchkjson/testdata}/errchkjson_no_exported.yml (100%) rename pkg/golinters/{ => errname}/errname.go (83%) create mode 100644 pkg/golinters/errname/errname_integration_test.go rename {test => pkg/golinters/errname}/testdata/errname.go (100%) rename pkg/golinters/{ => errorlint}/errorlint.go (89%) create mode 100644 pkg/golinters/errorlint/errorlint_integration_test.go rename {test => pkg/golinters/errorlint}/testdata/errorlint.go (100%) rename {test => pkg/golinters/errorlint}/testdata/errorlint_asserts.go (94%) rename {test/testdata/configs => pkg/golinters/errorlint/testdata}/errorlint_asserts.yml (100%) rename {test => pkg/golinters/errorlint}/testdata/errorlint_comparison.go (95%) rename {test/testdata/configs => pkg/golinters/errorlint/testdata}/errorlint_comparison.yml (100%) rename {test => pkg/golinters/errorlint}/testdata/errorlint_errorf.go (90%) rename {test/testdata/configs => pkg/golinters/errorlint/testdata}/errorlint_errorf.yml (100%) rename pkg/golinters/{ => execinquery}/execinquery.go (82%) create mode 100644 pkg/golinters/execinquery/execinquery_integration_test.go rename {test => pkg/golinters/execinquery}/testdata/execinquery.go (100%) rename pkg/golinters/{ => exhaustive}/exhaustive.go (92%) create mode 100644 pkg/golinters/exhaustive/exhaustive_integration_test.go rename {test => pkg/golinters/exhaustive}/testdata/exhaustive.go (100%) rename {test => pkg/golinters/exhaustive}/testdata/exhaustive_default.go (87%) rename {test/testdata/configs => pkg/golinters/exhaustive/testdata}/exhaustive_default.yml (100%) rename {test => pkg/golinters/exhaustive}/testdata/exhaustive_generated.go (100%) rename {test => pkg/golinters/exhaustive}/testdata/exhaustive_ignore_enum_members.go (83%) rename {test/testdata/configs => pkg/golinters/exhaustive/testdata}/exhaustive_ignore_enum_members.yml (100%) rename pkg/golinters/{ => exhaustruct}/exhaustruct.go (87%) create mode 100644 pkg/golinters/exhaustruct/exhaustruct_integration_test.go rename {test => pkg/golinters/exhaustruct}/testdata/exhaustruct.go (100%) rename {test/testdata/configs => pkg/golinters/exhaustruct/testdata}/exhaustruct.yml (100%) rename {test => pkg/golinters/exhaustruct}/testdata/exhaustruct_custom.go (96%) rename pkg/golinters/{ => exportloopref}/exportloopref.go (82%) create mode 100644 pkg/golinters/exportloopref/exportloopref_integration_test.go rename {test => pkg/golinters/exportloopref}/testdata/exportloopref.go (100%) rename pkg/golinters/{ => fatcontext}/fatcontext.go (83%) create mode 100644 pkg/golinters/fatcontext/fatcontext_integration_test.go rename {test => pkg/golinters/fatcontext}/testdata/fatcontext.go (100%) rename pkg/golinters/{ => forbidigo}/forbidigo.go (90%) create mode 100644 pkg/golinters/forbidigo/forbidigo_integration_test.go rename {test/testdata/configs => pkg/golinters/forbidigo/testdata}/forbidigo.yml (100%) rename {test => pkg/golinters/forbidigo}/testdata/forbidigo_example.go (86%) rename {test => pkg/golinters/forbidigo}/testdata/forbidigo_example_test.go (78%) rename {test/testdata/configs => pkg/golinters/forbidigo/testdata}/forbidigo_include_godoc_examples.yml (100%) rename {test => pkg/golinters/forbidigo}/testdata/forbidigo_include_godoc_examples_test.go (68%) rename {test/testdata/configs => pkg/golinters/forbidigo/testdata}/forbidigo_struct.yml (100%) rename {test => pkg/golinters/forbidigo}/testdata/forbidigo_struct_config.go (80%) rename pkg/golinters/{ => forcetypeassert}/forcetypeassert.go (83%) create mode 100644 pkg/golinters/forcetypeassert/forcetypeassert_integration_test.go rename {test => pkg/golinters/forcetypeassert}/testdata/forcetypeassert.go (100%) rename pkg/golinters/{ => funlen}/funlen.go (90%) create mode 100644 pkg/golinters/funlen/funlen_integration_test.go rename {test => pkg/golinters/funlen}/testdata/funlen.go (90%) rename {test/testdata/configs => pkg/golinters/funlen/testdata}/funlen.yml (100%) rename pkg/golinters/{ => gci}/gci.go (96%) create mode 100644 pkg/golinters/gci/gci_integration_test.go rename {test/testdata/fix/out => pkg/golinters/gci/testdata/fix/in}/gci.go (86%) rename {test/testdata/fix/in => pkg/golinters/gci/testdata/fix/out}/gci.go (86%) rename {test => pkg/golinters/gci}/testdata/gci.go (92%) rename {test/testdata/configs => pkg/golinters/gci/testdata}/gci.yml (100%) rename pkg/golinters/{ => ginkgolinter}/ginkgolinter.go (93%) create mode 100644 pkg/golinters/ginkgolinter/ginkgolinter_integration_test.go rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter.go (100%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_allow_havelen0.yml (100%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_default.yml (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_havelen0.go (98%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_async.go (98%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_async.yml (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_compare.go (98%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_compare.yml (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_err.go (98%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_err.yml (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_focused_containers.go (98%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_focused_containers.yml (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_len.go (98%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_len.yml (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_nil.go (98%) rename {test/testdata/ginkgolinter/configs => pkg/golinters/ginkgolinter/testdata}/ginkgolinter_suppress_nil.yml (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/go.mod (100%) rename {test/testdata/ginkgolinter => pkg/golinters/ginkgolinter/testdata}/go.sum (100%) rename pkg/golinters/{ => gocheckcompilerdirectives}/gocheckcompilerdirectives.go (81%) create mode 100644 pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives_integration_test.go rename {test => pkg/golinters/gocheckcompilerdirectives}/testdata/gocheckcompilerdirectives.go (100%) rename pkg/golinters/{ => gochecknoglobals}/gochecknoglobals.go (91%) create mode 100644 pkg/golinters/gochecknoglobals/gochecknoglobals_integration_test.go rename {test => pkg/golinters/gochecknoglobals}/testdata/gochecknoglobals.go (100%) rename pkg/golinters/{ => gochecknoinits}/gochecknoinits.go (89%) create mode 100644 pkg/golinters/gochecknoinits/gochecknoinits_integration_test.go rename {test => pkg/golinters/gochecknoinits}/testdata/gochecknoinits.go (100%) rename pkg/golinters/{ => gochecksumtype}/gochecksumtype.go (89%) create mode 100644 pkg/golinters/gochecksumtype/gochecksumtype_integration_test.go rename {test => pkg/golinters/gochecksumtype}/testdata/gochecksumtype.go (100%) rename pkg/golinters/{ => gocognit}/gocognit.go (91%) create mode 100644 pkg/golinters/gocognit/gocognit_integration_test.go rename {test => pkg/golinters/gocognit}/testdata/gocognit.go (95%) rename {test/testdata/configs => pkg/golinters/gocognit/testdata}/gocognit.yml (100%) rename pkg/golinters/{ => goconst}/goconst.go (92%) create mode 100644 pkg/golinters/goconst/goconst_integration_test.go rename {test => pkg/golinters/goconst}/testdata/goconst.go (100%) rename {test => pkg/golinters/goconst}/testdata/goconst_calls_enabled.go (80%) rename {test/testdata/configs => pkg/golinters/goconst/testdata}/goconst_calls_enabled.yml (100%) rename {test/testdata/configs => pkg/golinters/goconst/testdata}/goconst_dont_ignore.yml (100%) rename {test => pkg/golinters/goconst}/testdata/goconst_dont_ignore_test.go (91%) rename {test/testdata/configs => pkg/golinters/goconst/testdata}/goconst_ignore.yml (100%) rename {test => pkg/golinters/goconst}/testdata/goconst_ignore_test.go (90%) rename pkg/golinters/{ => gocritic}/gocritic.go (81%) create mode 100644 pkg/golinters/gocritic/gocritic_integration_test.go rename pkg/golinters/{ => gocritic}/gocritic_test.go (98%) rename {test => pkg/golinters/gocritic}/testdata/fix/in/gocritic.go (84%) rename {test => pkg/golinters/gocritic}/testdata/fix/out/gocritic.go (84%) create mode 100644 pkg/golinters/gocritic/testdata/gocritic-fix.yml rename {test => pkg/golinters/gocritic}/testdata/gocritic.go (96%) rename {test/testdata/configs => pkg/golinters/gocritic/testdata}/gocritic.yml (86%) rename {test => pkg/golinters/gocritic/testdata}/ruleguard/README.md (66%) rename {test => pkg/golinters/gocritic/testdata}/ruleguard/preferWriteString.go (100%) rename {test => pkg/golinters/gocritic/testdata}/ruleguard/rangeExprCopy.go (100%) rename {test => pkg/golinters/gocritic/testdata}/ruleguard/stringsSimplify.go (100%) rename pkg/golinters/{ => gocyclo}/gocyclo.go (90%) create mode 100644 pkg/golinters/gocyclo/gocyclo_integration_test.go rename {test => pkg/golinters/gocyclo}/testdata/gocyclo.go (89%) rename {test/testdata/configs => pkg/golinters/gocyclo/testdata}/gocyclo.yml (100%) rename pkg/golinters/{ => godot}/godot.go (92%) create mode 100644 pkg/golinters/godot/godot_integration_test.go rename {test => pkg/golinters/godot}/testdata/fix/in/godot.go (100%) rename {test => pkg/golinters/godot}/testdata/fix/out/godot.go (100%) rename {test => pkg/golinters/godot}/testdata/godot.go (100%) rename pkg/golinters/{ => godox}/godox.go (90%) create mode 100644 pkg/golinters/godox/godox_integration_test.go rename {test => pkg/golinters/godox}/testdata/godox.go (91%) rename {test/testdata/configs => pkg/golinters/godox/testdata}/godox.yml (100%) rename pkg/golinters/{ => gofmt}/gofmt.go (92%) create mode 100644 pkg/golinters/gofmt/gofmt_integration_test.go rename {test => pkg/golinters/gofmt}/testdata/fix/in/gofmt.go (100%) rename {test => pkg/golinters/gofmt}/testdata/fix/in/gofmt_rewrite_rules.go (83%) rename {test => pkg/golinters/gofmt}/testdata/fix/out/gofmt.go (100%) rename {test => pkg/golinters/gofmt}/testdata/fix/out/gofmt_rewrite_rules.go (82%) rename {test => pkg/golinters/gofmt}/testdata/gofmt.go (100%) rename {test => pkg/golinters/gofmt}/testdata/gofmt_no_simplify.go (74%) rename {test/testdata/configs => pkg/golinters/gofmt/testdata}/gofmt_no_simplify.yml (100%) rename {test => pkg/golinters/gofmt}/testdata/gofmt_rewrite_rules.go (79%) rename {test/testdata/configs => pkg/golinters/gofmt/testdata}/gofmt_rewrite_rules.yml (100%) rename pkg/golinters/{ => gofumpt}/gofumpt.go (92%) create mode 100644 pkg/golinters/gofumpt/gofumpt_integration_test.go rename {test => pkg/golinters/gofumpt}/testdata/fix/in/gofumpt.go (72%) rename {test => pkg/golinters/gofumpt}/testdata/fix/out/gofumpt.go (71%) rename {test/testdata/configs => pkg/golinters/gofumpt/testdata}/gofumpt-fix.yml (100%) rename {test => pkg/golinters/gofumpt}/testdata/gofumpt.go (100%) rename {test => pkg/golinters/gofumpt}/testdata/gofumpt_with_extra.go (72%) rename {test/testdata/configs => pkg/golinters/gofumpt/testdata}/gofumpt_with_extra.yml (100%) rename pkg/golinters/{ => goheader}/goheader.go (92%) create mode 100644 pkg/golinters/goheader/goheader_integration_test.go rename {test => pkg/golinters/goheader}/testdata/fix/in/goheader_1.go (66%) rename {test => pkg/golinters/goheader}/testdata/fix/in/goheader_2.go (72%) rename {test => pkg/golinters/goheader}/testdata/fix/in/goheader_3.go (72%) rename {test => pkg/golinters/goheader}/testdata/fix/out/goheader_1.go (74%) rename {test => pkg/golinters/goheader}/testdata/fix/out/goheader_2.go (74%) rename {test => pkg/golinters/goheader}/testdata/fix/out/goheader_3.go (74%) rename {test/testdata/configs => pkg/golinters/goheader/testdata}/goheader-fix.yml (100%) rename {test/testdata/configs => pkg/golinters/goheader/testdata}/goheader.yml (100%) rename {test => pkg/golinters/goheader}/testdata/goheader_bad.go (65%) rename {test => pkg/golinters/goheader}/testdata/goheader_good.go (63%) rename pkg/golinters/{ => goimports}/goimports.go (90%) create mode 100644 pkg/golinters/goimports/goimports_integration_test.go rename {test => pkg/golinters/goimports}/testdata/fix/in/goimports.go (100%) rename {test => pkg/golinters/goimports}/testdata/fix/out/goimports.go (100%) rename {test => pkg/golinters/goimports}/testdata/goimports.go (100%) rename {test => pkg/golinters/goimports}/testdata/goimports_local.go (83%) rename {test/testdata/configs => pkg/golinters/goimports/testdata}/goimports_local.yml (100%) rename pkg/golinters/{ => gomoddirectives}/gomoddirectives.go (83%) rename pkg/golinters/{ => gomodguard}/gomodguard.go (88%) create mode 100644 pkg/golinters/gomodguard/gomodguard_integration_test.go rename {test => pkg/golinters/gomodguard}/testdata/gomodguard.go (91%) rename {test/testdata/configs => pkg/golinters/gomodguard/testdata}/gomodguard.yml (100%) rename pkg/golinters/{ => goprintffuncname}/goprintffuncname.go (82%) create mode 100644 pkg/golinters/goprintffuncname/goprintffuncname_integration_test.go rename {test => pkg/golinters/goprintffuncname}/testdata/goprintffuncname.go (100%) rename pkg/golinters/{ => gosec}/gosec.go (97%) create mode 100644 pkg/golinters/gosec/gosec_integration_test.go rename pkg/golinters/{ => gosec}/gosec_test.go (98%) rename {test => pkg/golinters/gosec}/testdata/gosec.go (100%) rename {test/testdata/configs => pkg/golinters/gosec/testdata}/gosec.yml (100%) rename {test => pkg/golinters/gosec}/testdata/gosec_global_option.go (79%) rename {test/testdata/configs => pkg/golinters/gosec/testdata}/gosec_global_option.yml (100%) rename {test => pkg/golinters/gosec}/testdata/gosec_rules_config.go (87%) rename {test => pkg/golinters/gosec}/testdata/gosec_severity_confidence.go (88%) rename {test/testdata/configs => pkg/golinters/gosec/testdata}/gosec_severity_confidence.yml (100%) rename pkg/golinters/{ => gosimple}/gosimple.go (85%) create mode 100644 pkg/golinters/gosimple/gosimple_integration_test.go rename {test => pkg/golinters/gosimple}/testdata/gosimple.go (100%) rename pkg/golinters/{ => gosmopolitan}/gosmopolitan.go (87%) create mode 100644 pkg/golinters/gosmopolitan/gosmopolitan_integration_test.go rename {test => pkg/golinters/gosmopolitan}/testdata/gosmopolitan.go (100%) rename {test => pkg/golinters/gosmopolitan}/testdata/gosmopolitan_allow_time_local.go (64%) rename {test/testdata/configs => pkg/golinters/gosmopolitan/testdata}/gosmopolitan_allow_time_local.yml (100%) rename {test => pkg/golinters/gosmopolitan}/testdata/gosmopolitan_dont_ignore_test.go (73%) rename {test/testdata/configs => pkg/golinters/gosmopolitan/testdata}/gosmopolitan_dont_ignore_tests.yml (100%) rename {test => pkg/golinters/gosmopolitan}/testdata/gosmopolitan_escape_hatches.go (88%) rename {test/testdata/configs => pkg/golinters/gosmopolitan/testdata}/gosmopolitan_escape_hatches.yml (100%) rename {test => pkg/golinters/gosmopolitan}/testdata/gosmopolitan_ignore_test.go (100%) rename {test => pkg/golinters/gosmopolitan}/testdata/gosmopolitan_scripts.go (84%) rename {test/testdata/configs => pkg/golinters/gosmopolitan/testdata}/gosmopolitan_scripts.yml (100%) rename pkg/golinters/{ => govet}/govet.go (95%) create mode 100644 pkg/golinters/govet/govet_integration_test.go rename pkg/golinters/{ => govet}/govet_test.go (99%) rename {test => pkg/golinters/govet}/testdata/govet.go (95%) rename {test/testdata/configs => pkg/golinters/govet/testdata}/govet.yml (100%) rename {test => pkg/golinters/govet}/testdata/govet_custom_formatter.go (100%) rename {test => pkg/golinters/govet}/testdata/govet_fieldalignment.go (91%) rename {test/testdata/configs => pkg/golinters/govet/testdata}/govet_fieldalignment.yml (100%) rename {test => pkg/golinters/govet}/testdata/govet_ifaceassert.go (81%) rename {test/testdata/configs => pkg/golinters/govet/testdata}/govet_ifaceassert.yml (100%) rename pkg/golinters/{ => grouper}/grouper.go (92%) create mode 100644 pkg/golinters/grouper/grouper_integration_test.go rename {test => pkg/golinters/grouper}/testdata/grouper.go (73%) rename {test/testdata/configs => pkg/golinters/grouper/testdata}/grouper.yml (100%) rename pkg/golinters/{ => importas}/importas.go (95%) create mode 100644 pkg/golinters/importas/importas_integration_test.go rename {test => pkg/golinters/importas}/testdata/importas.go (91%) rename {test/testdata/configs => pkg/golinters/importas/testdata}/importas.yml (100%) rename {test => pkg/golinters/importas}/testdata/importas_strict.go (91%) rename {test/testdata/configs => pkg/golinters/importas/testdata}/importas_strict.yml (100%) rename pkg/golinters/{ => inamedparam}/inamedparam.go (83%) create mode 100644 pkg/golinters/inamedparam/inamedparam_integration_test.go rename {test => pkg/golinters/inamedparam}/testdata/inamedparam.go (100%) rename {test => pkg/golinters/inamedparam}/testdata/inamedparam_skip_single_param.go (84%) rename {test/testdata/configs => pkg/golinters/inamedparam/testdata}/inamedparam_skip_single_param.yml (100%) rename pkg/golinters/{ => ineffassign}/ineffassign.go (85%) create mode 100644 pkg/golinters/ineffassign/ineffassign_integration_test.go rename {test => pkg/golinters/ineffassign}/testdata/ineffassign.go (100%) rename pkg/golinters/{ => interfacebloat}/interfacebloat.go (83%) create mode 100644 pkg/golinters/interfacebloat/interfacebloat_integration_test.go rename {test => pkg/golinters/interfacebloat}/testdata/interfacebloat.go (100%) rename pkg/golinters/{ => intrange}/intrange.go (83%) create mode 100644 pkg/golinters/intrange/intrange_integration_test.go rename {test => pkg/golinters/intrange}/testdata/intrange.go (100%) rename pkg/golinters/{ => ireturn}/ireturn.go (86%) create mode 100644 pkg/golinters/ireturn/ireturn_integration_test.go rename {test => pkg/golinters/ireturn}/testdata/ireturn.go (100%) rename {test => pkg/golinters/ireturn}/testdata/ireturn_allow.go (84%) rename {test/testdata/configs => pkg/golinters/ireturn/testdata}/ireturn_allow.yml (100%) rename {test => pkg/golinters/ireturn}/testdata/ireturn_reject_generics.go (82%) rename {test/testdata/configs => pkg/golinters/ireturn/testdata}/ireturn_reject_generics.yml (100%) rename {test => pkg/golinters/ireturn}/testdata/ireturn_reject_stdlib.go (82%) rename {test/testdata/configs => pkg/golinters/ireturn/testdata}/ireturn_reject_stdlib.yml (100%) rename pkg/golinters/{ => lll}/lll.go (95%) create mode 100644 pkg/golinters/lll/lll_integration_test.go rename {test => pkg/golinters/lll}/testdata/lll.go (92%) rename {test/testdata/configs => pkg/golinters/lll/testdata}/lll.yml (100%) rename {test/testdata/configs => pkg/golinters/lll/testdata}/lll_import.yml (100%) rename {test => pkg/golinters/lll}/testdata/lll_import_multi.go (87%) rename {test => pkg/golinters/lll}/testdata/lll_import_single.go (80%) rename pkg/golinters/{ => loggercheck}/loggercheck.go (90%) create mode 100644 pkg/golinters/loggercheck/loggercheck_integration_test.go rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/go.mod (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/go.sum (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/loggercheck_custom.go (98%) rename {test/testdata/loggercheck/configs => pkg/golinters/loggercheck/testdata}/loggercheck_custom.yml (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/loggercheck_default.go (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/loggercheck_kitlogonly.go (93%) rename {test/testdata/loggercheck/configs => pkg/golinters/loggercheck/testdata}/loggercheck_kitlogonly.yml (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/loggercheck_logronly.go (90%) rename {test/testdata/loggercheck/configs => pkg/golinters/loggercheck/testdata}/loggercheck_logronly.yml (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/loggercheck_noprintflike.go (87%) rename {test/testdata/loggercheck/configs => pkg/golinters/loggercheck/testdata}/loggercheck_noprintflike.yml (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/loggercheck_requirestringkey.go (91%) rename {test/testdata/loggercheck/configs => pkg/golinters/loggercheck/testdata}/loggercheck_requirestringkey.yml (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/loggercheck_zaponly.go (86%) rename {test/testdata/loggercheck/configs => pkg/golinters/loggercheck/testdata}/loggercheck_zaponly.yml (100%) rename {test/testdata/loggercheck => pkg/golinters/loggercheck/testdata}/logrlint_compatiblity.go (100%) rename pkg/golinters/{ => maintidx}/maintidx.go (85%) create mode 100644 pkg/golinters/maintidx/maintidx_integration_test.go rename {test => pkg/golinters/maintidx}/testdata/maintidx.go (100%) rename {test => pkg/golinters/maintidx}/testdata/maintidx_under_100.go (97%) rename {test/testdata/configs => pkg/golinters/maintidx/testdata}/maintidx_under_100.yml (100%) rename pkg/golinters/{ => makezero}/makezero.go (89%) create mode 100644 pkg/golinters/makezero/makezero_integration_test.go rename {test => pkg/golinters/makezero}/testdata/makezero.go (100%) rename {test => pkg/golinters/makezero}/testdata/makezero_always.go (83%) rename {test/testdata/configs => pkg/golinters/makezero/testdata}/makezero_always.yml (100%) rename pkg/golinters/{ => mirror}/mirror.go (96%) create mode 100644 pkg/golinters/mirror/mirror_integration_test.go rename {test => pkg/golinters/mirror}/testdata/fix/in/mirror.go (100%) rename {test => pkg/golinters/mirror}/testdata/fix/out/mirror.go (100%) rename {test => pkg/golinters/mirror}/testdata/mirror.go (100%) rename pkg/golinters/{ => misspell}/misspell.go (96%) create mode 100644 pkg/golinters/misspell/misspell_integration_test.go rename pkg/golinters/{ => misspell}/misspell_test.go (99%) rename {test => pkg/golinters/misspell}/testdata/fix/in/misspell.go (100%) rename {test => pkg/golinters/misspell}/testdata/fix/out/misspell.go (100%) rename {test => pkg/golinters/misspell}/testdata/misspell.go (83%) rename {test/testdata/configs => pkg/golinters/misspell/testdata}/misspell.yml (100%) rename {test => pkg/golinters/misspell}/testdata/misspell_custom.go (85%) rename {test/testdata/configs => pkg/golinters/misspell/testdata}/misspell_custom.yml (100%) rename pkg/golinters/{ => mnd}/mnd.go (95%) create mode 100644 pkg/golinters/mnd/mnd_integration_test.go rename {test => pkg/golinters/mnd}/testdata/mnd.go (100%) rename pkg/golinters/{ => musttag}/musttag.go (85%) create mode 100644 pkg/golinters/musttag/musttag_integration_test.go rename {test => pkg/golinters/musttag}/testdata/musttag.go (100%) rename {test/testdata/configs => pkg/golinters/musttag/testdata}/musttag.yml (100%) rename {test => pkg/golinters/musttag}/testdata/musttag_custom.go (90%) rename pkg/golinters/{ => nakedret}/nakedret.go (82%) create mode 100644 pkg/golinters/nakedret/nakedret_integration_test.go rename {test => pkg/golinters/nakedret}/testdata/nakedret.go (100%) rename pkg/golinters/{ => nestif}/nestif.go (91%) create mode 100644 pkg/golinters/nestif/nestif_integration_test.go rename {test => pkg/golinters/nestif}/testdata/nestif.go (93%) rename {test/testdata/configs => pkg/golinters/nestif/testdata}/nestif.yml (100%) rename pkg/golinters/{ => nilerr}/nilerr.go (86%) create mode 100644 pkg/golinters/nilerr/nilerr_integration_test.go rename {test => pkg/golinters/nilerr}/testdata/nilerr.go (100%) rename pkg/golinters/{ => nilnil}/nilnil.go (87%) create mode 100644 pkg/golinters/nilnil/nilnil_integration_test.go rename {test => pkg/golinters/nilnil}/testdata/nilnil.go (100%) rename pkg/golinters/{ => nlreturn}/nlreturn.go (86%) create mode 100644 pkg/golinters/nlreturn/nlreturn_integration_test.go rename {test => pkg/golinters/nlreturn}/testdata/nlreturn-block-size.go (82%) rename {test => pkg/golinters/nlreturn}/testdata/nlreturn.go (100%) rename {test/testdata/configs => pkg/golinters/nlreturn/testdata}/nlreturn.yml (100%) rename pkg/golinters/{ => noctx}/noctx.go (85%) create mode 100644 pkg/golinters/noctx/noctx_integration_test.go rename {test => pkg/golinters/noctx}/testdata/noctx.go (100%) delete mode 100644 pkg/golinters/nolintlint.go rename pkg/golinters/nolintlint/{ => internal}/README.md (100%) create mode 100644 pkg/golinters/nolintlint/internal/nolintlint.go rename pkg/golinters/nolintlint/{ => internal}/nolintlint_test.go (99%) rename pkg/golinters/{ => nonamedreturns}/nonamedreturns.go (83%) create mode 100644 pkg/golinters/nonamedreturns/nonamedreturns_integration_test.go rename {test => pkg/golinters/nonamedreturns}/testdata/nonamedreturns.go (100%) rename {test => pkg/golinters/nonamedreturns}/testdata/nonamedreturns_custom.go (97%) rename {test/testdata/configs => pkg/golinters/nonamedreturns/testdata}/nonamedreturns_custom.yml (100%) rename pkg/golinters/{ => nosprintfhostport}/nosprintfhostport.go (82%) create mode 100644 pkg/golinters/nosprintfhostport/nosprintfhostport_integration_test.go rename {test => pkg/golinters/nosprintfhostport}/testdata/nosprintfhostport.go (100%) rename pkg/golinters/{ => paralleltest}/paralleltest.go (88%) create mode 100644 pkg/golinters/paralleltest/paralleltest_integration_test.go rename {test => pkg/golinters/paralleltest}/testdata/paralleltest.go (100%) rename {test => pkg/golinters/paralleltest}/testdata/paralleltest_custom.go (85%) rename {test/testdata/configs => pkg/golinters/paralleltest/testdata}/paralleltest_custom.yml (100%) rename pkg/golinters/{ => perfsprint}/perfsprint.go (87%) create mode 100644 pkg/golinters/perfsprint/perfsprint_integration_test.go rename {test => pkg/golinters/perfsprint}/testdata/perfsprint.go (100%) rename {test => pkg/golinters/perfsprint}/testdata/perfsprint_custom.go (96%) rename {test/testdata/configs => pkg/golinters/perfsprint/testdata}/perfsprint_custom.yml (100%) rename pkg/golinters/{ => prealloc}/prealloc.go (88%) create mode 100644 pkg/golinters/prealloc/prealloc_integration_test.go rename {test => pkg/golinters/prealloc}/testdata/prealloc.go (100%) rename pkg/golinters/{ => predeclared}/predeclared.go (85%) create mode 100644 pkg/golinters/predeclared/predeclared_integration_test.go rename {test => pkg/golinters/predeclared}/testdata/predeclared.go (100%) rename {test => pkg/golinters/predeclared}/testdata/predeclared_custom.go (86%) rename {test/testdata/configs => pkg/golinters/predeclared/testdata}/predeclared_custom.yml (100%) rename pkg/golinters/{ => promlinter}/promlinter.go (88%) create mode 100644 pkg/golinters/promlinter/promlinter_integration_test.go rename {test => pkg/golinters/promlinter}/testdata/promlinter.go (100%) rename pkg/golinters/{ => protogetter}/protogetter.go (94%) create mode 100644 pkg/golinters/protogetter/protogetter_integration_test.go rename {test/testdata/protogetter => pkg/golinters/protogetter/testdata}/go.mod (100%) rename {test/testdata/protogetter => pkg/golinters/protogetter/testdata}/go.sum (100%) rename {test/testdata/protogetter => pkg/golinters/protogetter/testdata}/proto/test.go (100%) rename {test/testdata/protogetter => pkg/golinters/protogetter/testdata}/proto/test.pb.go (100%) rename {test/testdata/protogetter => pkg/golinters/protogetter/testdata}/proto/test.proto (100%) rename {test/testdata/protogetter => pkg/golinters/protogetter/testdata}/proto/test_grpc.pb.go (100%) rename {test/testdata/protogetter => pkg/golinters/protogetter/testdata}/protogetter.go (100%) rename pkg/golinters/{ => reassign}/reassign.go (86%) create mode 100644 pkg/golinters/reassign/reassign_integration_test.go rename {test => pkg/golinters/reassign}/testdata/reassign.go (100%) rename {test => pkg/golinters/reassign}/testdata/reassign_patterns.go (82%) rename {test/testdata/configs => pkg/golinters/reassign/testdata}/reassign_patterns.yml (100%) rename pkg/golinters/{ => revive}/revive.go (96%) create mode 100644 pkg/golinters/revive/revive_integration_test.go rename {test => pkg/golinters/revive}/testdata/revive.go (91%) rename {test/testdata/configs => pkg/golinters/revive/testdata}/revive.yml (100%) rename {test => pkg/golinters/revive}/testdata/revive_default.go (100%) rename pkg/golinters/{ => rowserrcheck}/rowserrcheck.go (83%) create mode 100644 pkg/golinters/rowserrcheck/rowserrcheck_integration_test.go rename {test => pkg/golinters/rowserrcheck}/testdata/rowserrcheck.go (100%) rename pkg/golinters/{ => sloglint}/sloglint.go (89%) create mode 100644 pkg/golinters/sloglint/sloglint_integration_test.go rename {test => pkg/golinters/sloglint}/testdata/sloglint.go (100%) rename {test => pkg/golinters/sloglint}/testdata/sloglint_args_on_sep_lines.go (78%) rename {test/testdata/configs => pkg/golinters/sloglint/testdata}/sloglint_args_on_sep_lines.yml (100%) rename {test => pkg/golinters/sloglint}/testdata/sloglint_attr_only.go (78%) rename {test/testdata/configs => pkg/golinters/sloglint/testdata}/sloglint_attr_only.yml (100%) rename {test => pkg/golinters/sloglint}/testdata/sloglint_context_only.go (77%) rename {test/testdata/configs => pkg/golinters/sloglint/testdata}/sloglint_context_only.yml (100%) rename {test => pkg/golinters/sloglint}/testdata/sloglint_key_naming_case.go (90%) rename {test/testdata/configs => pkg/golinters/sloglint/testdata}/sloglint_key_naming_case.yml (100%) rename {test => pkg/golinters/sloglint}/testdata/sloglint_kv_only.go (78%) rename {test/testdata/configs => pkg/golinters/sloglint/testdata}/sloglint_kv_only.yml (100%) rename {test => pkg/golinters/sloglint}/testdata/sloglint_no_raw_keys.go (85%) rename {test/testdata/configs => pkg/golinters/sloglint/testdata}/sloglint_no_raw_keys.yml (100%) rename {test => pkg/golinters/sloglint}/testdata/sloglint_static_msg.go (79%) rename {test/testdata/configs => pkg/golinters/sloglint/testdata}/sloglint_static_msg.yml (100%) rename pkg/golinters/{ => spancheck}/spancheck.go (86%) create mode 100644 pkg/golinters/spancheck/spancheck_integration_test.go rename {test/testdata/spancheck => pkg/golinters/spancheck/testdata}/go.mod (100%) rename {test/testdata/spancheck => pkg/golinters/spancheck/testdata}/go.sum (100%) rename {test/testdata/spancheck => pkg/golinters/spancheck/testdata}/spancheck_default.go (100%) rename {test/testdata/spancheck => pkg/golinters/spancheck/testdata}/spancheck_enable_all.go (98%) rename {test/testdata/spancheck/configs => pkg/golinters/spancheck/testdata}/spancheck_enable_all.yml (100%) rename pkg/golinters/{ => sqlclosecheck}/sqlclosecheck.go (83%) create mode 100644 pkg/golinters/sqlclosecheck/sqlclosecheck_integration_test.go rename {test => pkg/golinters/sqlclosecheck}/testdata/sqlclosecheck.go (100%) rename pkg/golinters/{ => staticcheck}/staticcheck.go (87%) create mode 100644 pkg/golinters/staticcheck/staticcheck_integration_test.go rename {test => pkg/golinters/staticcheck}/testdata/staticcheck.go (100%) rename {test => pkg/golinters/staticcheck}/testdata/staticcheck_in_megacheck.go (100%) rename pkg/golinters/{ => stylecheck}/stylecheck.go (91%) create mode 100644 pkg/golinters/stylecheck/stylecheck_integration_test.go rename {test => pkg/golinters/stylecheck}/testdata/stylecheck.go (100%) rename {test => pkg/golinters/stylecheck}/testdata/stylecheck_not_in_megacheck.go (100%) rename pkg/golinters/{ => tagalign}/tagalign.go (95%) create mode 100644 pkg/golinters/tagalign/tagalign_integration_test.go rename {test => pkg/golinters/tagalign}/testdata/fix/in/tagalign.go (83%) rename {test => pkg/golinters/tagalign}/testdata/fix/out/tagalign.go (85%) rename {test => pkg/golinters/tagalign}/testdata/tagalign.go (100%) rename {test => pkg/golinters/tagalign}/testdata/tagalign_align_only.go (96%) rename {test/testdata/configs => pkg/golinters/tagalign/testdata}/tagalign_align_only.yml (100%) rename {test => pkg/golinters/tagalign}/testdata/tagalign_order_only.go (92%) rename {test/testdata/configs => pkg/golinters/tagalign/testdata}/tagalign_order_only.yml (100%) rename {test => pkg/golinters/tagalign}/testdata/tagalign_sort_only.go (92%) rename {test/testdata/configs => pkg/golinters/tagalign/testdata}/tagalign_sort_only.yml (100%) rename {test => pkg/golinters/tagalign}/testdata/tagalign_strict.go (90%) rename {test/testdata/configs => pkg/golinters/tagalign/testdata}/tagalign_strict.yml (100%) rename pkg/golinters/{ => tagliatelle}/tagliatelle.go (86%) create mode 100644 pkg/golinters/tagliatelle/tagliatelle_integration_test.go rename {test => pkg/golinters/tagliatelle}/testdata/tagliatelle.go (100%) rename pkg/golinters/{ => tenv}/tenv.go (84%) create mode 100644 pkg/golinters/tenv/tenv_integration_test.go rename {test => pkg/golinters/tenv}/testdata/tenv.go (96%) rename {test => pkg/golinters/tenv}/testdata/tenv_all.go (96%) rename {test/testdata/configs => pkg/golinters/tenv/testdata}/tenv_all.yml (100%) rename {test => pkg/golinters/tenv}/testdata/tenv_all_test.go (96%) rename {test => pkg/golinters/tenv}/testdata/tenv_fuzz.go (100%) rename {test => pkg/golinters/tenv}/testdata/tenv_test.go (100%) rename pkg/golinters/{ => testableexamples}/testableexamples.go (83%) create mode 100644 pkg/golinters/testableexamples/testableexamples_integration_test.go rename {test => pkg/golinters/testableexamples}/testdata/testableexamples_test.go (100%) rename {test => pkg/golinters/testifylint}/testdata/testifylint.go (100%) rename {test => pkg/golinters/testifylint}/testdata/testifylint_bool_compare_only.go (79%) rename {test/testdata/configs => pkg/golinters/testifylint/testdata}/testifylint_bool_compare_only.yml (100%) rename {test => pkg/golinters/testifylint}/testdata/testifylint_require_error_only.go (95%) rename {test/testdata/configs => pkg/golinters/testifylint/testdata}/testifylint_require_error_only.yml (100%) rename pkg/golinters/{ => testifylint}/testifylint.go (92%) create mode 100644 pkg/golinters/testifylint/testifylint_integration_test.go rename {test => pkg/golinters/testpackage}/testdata/testpackage_test.go (100%) rename pkg/golinters/{ => testpackage}/testpackage.go (87%) create mode 100644 pkg/golinters/testpackage/testpackage_integration_test.go rename {test => pkg/golinters/thelper}/testdata/thelper.go (100%) rename {test/testdata/configs => pkg/golinters/thelper/testdata}/thelper.yml (100%) rename {test => pkg/golinters/thelper}/testdata/thelper_fuzz.go (100%) rename {test => pkg/golinters/thelper}/testdata/thelper_with_options.go (87%) rename pkg/golinters/{ => thelper}/thelper.go (94%) create mode 100644 pkg/golinters/thelper/thelper_integration_test.go rename {test => pkg/golinters/tparallel}/testdata/tparallel_happy_path_test.go (100%) rename {test => pkg/golinters/tparallel}/testdata/tparallel_missing_subtest_test.go (100%) rename {test => pkg/golinters/tparallel}/testdata/tparallel_missing_toplevel_test.go (100%) rename pkg/golinters/{ => tparallel}/tparallel.go (82%) create mode 100644 pkg/golinters/tparallel/tparallel_integration_test.go rename {test => pkg/golinters/unconvert}/testdata/unconvert.go (100%) rename pkg/golinters/{ => unconvert}/unconvert.go (86%) create mode 100644 pkg/golinters/unconvert/unconvert_integration_test.go rename {test => pkg/golinters/unparam}/testdata/unparam.go (100%) rename pkg/golinters/{ => unparam}/unparam.go (91%) create mode 100644 pkg/golinters/unparam/unparam_integration_test.go rename {test => pkg/golinters/unused}/testdata/unused.go (100%) rename pkg/golinters/{ => unused}/unused.go (93%) create mode 100644 pkg/golinters/unused/unused_integration_test.go rename {test => pkg/golinters/usestdlibvars}/testdata/usestdlibvars.go (100%) rename {test => pkg/golinters/usestdlibvars}/testdata/usestdlibvars_non_default.go (95%) rename {test/testdata/configs => pkg/golinters/usestdlibvars/testdata}/usestdlibvars_non_default.yml (100%) rename pkg/golinters/{ => usestdlibvars}/usestdlibvars.go (92%) create mode 100644 pkg/golinters/usestdlibvars/usestdlibvars_integration_test.go rename {test => pkg/golinters/varnamelen}/testdata/varnamelen.go (100%) rename pkg/golinters/{ => varnamelen}/varnamelen.go (93%) create mode 100644 pkg/golinters/varnamelen/varnamelen_integration_test.go rename {test => pkg/golinters/wastedassign}/testdata/wastedassign.go (100%) rename pkg/golinters/{ => wastedassign}/wastedassign.go (84%) create mode 100644 pkg/golinters/wastedassign/wastedassign_integration_test.go rename {test => pkg/golinters/whitespace}/testdata/fix/in/whitespace.go (93%) rename {test => pkg/golinters/whitespace}/testdata/fix/out/whitespace.go (93%) rename {test/testdata/configs => pkg/golinters/whitespace/testdata}/whitespace-fix.yml (100%) rename pkg/golinters/{ => whitespace}/whitespace.go (93%) create mode 100644 pkg/golinters/whitespace/whitespace_integration_test.go rename {test => pkg/golinters/wrapcheck}/testdata/wrapcheck.go (100%) rename pkg/golinters/{ => wrapcheck}/wrapcheck.go (89%) create mode 100644 pkg/golinters/wrapcheck/wrapcheck_integration_test.go rename {test => pkg/golinters/wsl}/testdata/wsl.go (98%) rename {test/testdata/configs => pkg/golinters/wsl/testdata}/wsl.yml (100%) rename pkg/golinters/{ => wsl}/wsl.go (94%) create mode 100644 pkg/golinters/wsl/wsl_integration_test.go rename {test/testdata/zerologlint => pkg/golinters/zerologlint/testdata}/go.mod (100%) rename {test/testdata/zerologlint => pkg/golinters/zerologlint/testdata}/go.sum (100%) rename {test/testdata/zerologlint => pkg/golinters/zerologlint/testdata}/zerologlint.go (100%) rename pkg/golinters/{ => zerologlint}/zerologlint.go (82%) create mode 100644 pkg/golinters/zerologlint/zerologlint_integration_test.go delete mode 100644 test/testdata/configs/gocritic-fix.yml create mode 100644 test/testdata/configs/output.yml create mode 100644 test/testdata/output.go create mode 100644 test/testshared/install.go create mode 100644 test/testshared/integration/fix.go create mode 100644 test/testshared/integration/run.go diff --git a/.gitignore b/.gitignore index 827702fbb926..19c7ab47f1be 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /*.pdf /*.pprof /*.txt +/test.lock /.idea/ /.vscode/ /dist/ diff --git a/.golangci.yml b/.golangci.yml index c093452a27de..98bf1563935f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -163,27 +163,27 @@ issues: text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead." # Deprecated linter options. - - path: pkg/golinters/errcheck.go + - path: pkg/golinters/errcheck/errcheck.go linters: [staticcheck] text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead" - - path: pkg/golinters/govet.go + - path: pkg/golinters/govet/govet.go linters: [staticcheck] text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable." - - path: pkg/golinters/godot.go + - path: pkg/golinters/godot/godot.go linters: [staticcheck] text: "SA1019: settings.CheckAll is deprecated: use Scope instead" - - path: pkg/golinters/gci.go + - path: pkg/golinters/gci/gci.go linters: [staticcheck] text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead." - - path: pkg/golinters/mnd.go + - path: pkg/golinters/mnd/mnd.go linters: [staticcheck] text: "SA1019: settings.Settings is deprecated: use root level settings instead." - - path: pkg/golinters/mnd.go + - path: pkg/golinters/mnd/mnd.go linters: [staticcheck] text: "SA1019: config.GoMndSettings is deprecated: use MndSettings." # Related to `run.go`, it cannot be removed. - - path: pkg/golinters/gofumpt.go + - path: pkg/golinters/gofumpt/gofumpt.go linters: [staticcheck] text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead." - path: pkg/golinters/internal/staticcheck_common.go @@ -194,7 +194,7 @@ issues: text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead." # Based on existing code, the modifications should be limited to make maintenance easier. - - path: pkg/golinters/unused.go + - path: pkg/golinters/unused/unused.go linters: [gocritic] text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)" diff --git a/Makefile b/Makefile index 9d14ab5ccf0c..2554acb9c07b 100644 --- a/Makefile +++ b/Makefile @@ -33,23 +33,21 @@ test: build GL_TEST_RUN=1 go test -v -parallel 2 ./... .PHONY: test -# ex: T=gofmt.go make test_fix -# the value of `T` is the name of a file from `test/testdata/fix` -test_fix: build - GL_TEST_RUN=1 go test -v ./test -count 1 -run TestFix/$T -.PHONY: test_fix - test_race: build_race GL_TEST_RUN=1 ./$(BINARY) run -v --timeout=5m .PHONY: test_race -test_linters: +# ex: T=output.go make test_integration +# the value of `T` is the name of a file from `test/testdata` +test_integration: GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdata/$T -.PHONY: test_linters +.PHONY: test_integration -test_linters_sub: - GL_TEST_RUN=1 go test -v ./test -count 1 -run TestSourcesFromTestdataSubDir/$T -.PHONY: test_linters_sub +# ex: T=multiple-issues-fix.go make test_integration_fix +# the value of `T` is the name of a file from `test/testdata/fix` +test_integration_fix: build + GL_TEST_RUN=1 go test -v ./test -count 1 -run TestFix/$T +.PHONY: test_integration_fix # Maintenance diff --git a/docs/src/docs/contributing/new-linters.mdx b/docs/src/docs/contributing/new-linters.mdx index 6886bc653cde..67359caada01 100644 --- a/docs/src/docs/contributing/new-linters.mdx +++ b/docs/src/docs/contributing/new-linters.mdx @@ -15,19 +15,16 @@ We don't accept non `go/analysis` linters. After that: 1. Implement functional tests for the linter: - - Add one file into directory [`test/testdata`](https://github.com/golangci/golangci-lint/tree/master/test/testdata). - - Run the test to ensure that test fails: - ```bash - T=yourlintername.go make test_linters - ``` + - Add one file into directory `pkg/golinters/{yourlintername}/testdata/`. + - Run the test to ensure that test fails. - Run: ```bash - go run ./cmd/golangci-lint/ run --no-config --disable-all --enable=yourlintername ./test/testdata/yourlintername.go + go run ./cmd/golangci-lint/ run --no-config --disable-all --enable={yourlintername} ./pkg/golinters/{yourlintername}/testdata/{yourlintername}.go ``` -2. Add a new file `pkg/golinters/{yourlintername}.go`. +2. Add a new file `pkg/golinters/{yourlintername}/{yourlintername}.go`. Look at other linters in this directory. Implement linter integration and check that test passes. -3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}.go`) to the +3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}/{yourlintername}.go`) to the list of all supported linters in [`pkg/lint/lintersdb/builder_linter.go`](https://github.com/golangci/golangci-lint/blob/master/pkg/lint/lintersdb/builder_linter.go) to the method `LinterBuilder.Build`. - Add `WithSince("next_version")`, where `next_version` must be replaced by the next minor version. (ex: v1.2.0 if the current version is v1.1.0) diff --git a/pkg/golinters/asasalint.go b/pkg/golinters/asasalint/asasalint.go similarity index 88% rename from pkg/golinters/asasalint.go rename to pkg/golinters/asasalint/asasalint.go index d783d33653e3..653a2d514250 100644 --- a/pkg/golinters/asasalint.go +++ b/pkg/golinters/asasalint/asasalint.go @@ -1,4 +1,4 @@ -package golinters +package asasalint import ( "github.com/alingse/asasalint" @@ -9,7 +9,7 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/internal" ) -func NewAsasalint(setting *config.AsasalintSettings) *goanalysis.Linter { +func New(setting *config.AsasalintSettings) *goanalysis.Linter { cfg := asasalint.LinterSetting{} if setting != nil { cfg.Exclude = setting.Exclude diff --git a/pkg/golinters/asasalint/asasalint_integration_test.go b/pkg/golinters/asasalint/asasalint_integration_test.go new file mode 100644 index 000000000000..b6431cae3649 --- /dev/null +++ b/pkg/golinters/asasalint/asasalint_integration_test.go @@ -0,0 +1,11 @@ +package asasalint + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/asasalint.go b/pkg/golinters/asasalint/testdata/asasalint.go similarity index 100% rename from test/testdata/asasalint.go rename to pkg/golinters/asasalint/testdata/asasalint.go diff --git a/pkg/golinters/asciicheck.go b/pkg/golinters/asciicheck/asciicheck.go similarity index 83% rename from pkg/golinters/asciicheck.go rename to pkg/golinters/asciicheck/asciicheck.go index 64c2e1fb3159..675dfc478087 100644 --- a/pkg/golinters/asciicheck.go +++ b/pkg/golinters/asciicheck/asciicheck.go @@ -1,4 +1,4 @@ -package golinters +package asciicheck import ( "github.com/tdakkota/asciicheck" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewAsciicheck() *goanalysis.Linter { +func New() *goanalysis.Linter { a := asciicheck.NewAnalyzer() return goanalysis.NewLinter( diff --git a/pkg/golinters/asciicheck/asciicheck_integration_test.go b/pkg/golinters/asciicheck/asciicheck_integration_test.go new file mode 100644 index 000000000000..dca7e1698ec1 --- /dev/null +++ b/pkg/golinters/asciicheck/asciicheck_integration_test.go @@ -0,0 +1,11 @@ +package asciicheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/asciicheck.go b/pkg/golinters/asciicheck/testdata/asciicheck.go similarity index 100% rename from test/testdata/asciicheck.go rename to pkg/golinters/asciicheck/testdata/asciicheck.go diff --git a/pkg/golinters/bidichk.go b/pkg/golinters/bidichk/bidichk.go similarity index 94% rename from pkg/golinters/bidichk.go rename to pkg/golinters/bidichk/bidichk.go index 62c60e8cec4c..4ced901e8fae 100644 --- a/pkg/golinters/bidichk.go +++ b/pkg/golinters/bidichk/bidichk.go @@ -1,4 +1,4 @@ -package golinters +package bidichk import ( "strings" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewBiDiChk(cfg *config.BiDiChkSettings) *goanalysis.Linter { +func New(cfg *config.BiDiChkSettings) *goanalysis.Linter { a := bidichk.NewAnalyzer() cfgMap := map[string]map[string]any{} diff --git a/pkg/golinters/bidichk/bidichk_integration_test.go b/pkg/golinters/bidichk/bidichk_integration_test.go new file mode 100644 index 000000000000..142ffe1b12be --- /dev/null +++ b/pkg/golinters/bidichk/bidichk_integration_test.go @@ -0,0 +1,11 @@ +package bidichk + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/bidichk.go b/pkg/golinters/bidichk/testdata/bidichk.go similarity index 100% rename from test/testdata/bidichk.go rename to pkg/golinters/bidichk/testdata/bidichk.go diff --git a/pkg/golinters/bodyclose.go b/pkg/golinters/bodyclose/bodyclose.go similarity index 85% rename from pkg/golinters/bodyclose.go rename to pkg/golinters/bodyclose/bodyclose.go index 97c768de13d9..f39814edc590 100644 --- a/pkg/golinters/bodyclose.go +++ b/pkg/golinters/bodyclose/bodyclose.go @@ -1,4 +1,4 @@ -package golinters +package bodyclose import ( "github.com/timakin/bodyclose/passes/bodyclose" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewBodyclose() *goanalysis.Linter { +func New() *goanalysis.Linter { a := bodyclose.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/bodyclose/bodyclose_integration_test.go b/pkg/golinters/bodyclose/bodyclose_integration_test.go new file mode 100644 index 000000000000..e4b47c90c66f --- /dev/null +++ b/pkg/golinters/bodyclose/bodyclose_integration_test.go @@ -0,0 +1,11 @@ +package bodyclose + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/bodyclose.go b/pkg/golinters/bodyclose/testdata/bodyclose.go similarity index 100% rename from test/testdata/bodyclose.go rename to pkg/golinters/bodyclose/testdata/bodyclose.go diff --git a/pkg/golinters/containedctx.go b/pkg/golinters/containedctx/containedctx.go similarity index 82% rename from pkg/golinters/containedctx.go rename to pkg/golinters/containedctx/containedctx.go index ac2d96ef64d4..6fdb4ea6e186 100644 --- a/pkg/golinters/containedctx.go +++ b/pkg/golinters/containedctx/containedctx.go @@ -1,4 +1,4 @@ -package golinters +package containedctx import ( "github.com/sivchari/containedctx" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewContainedCtx() *goanalysis.Linter { +func New() *goanalysis.Linter { a := containedctx.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/containedctx/containedctx_integration_test.go b/pkg/golinters/containedctx/containedctx_integration_test.go new file mode 100644 index 000000000000..9bc23d88ed4d --- /dev/null +++ b/pkg/golinters/containedctx/containedctx_integration_test.go @@ -0,0 +1,11 @@ +package containedctx + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/containedctx.go b/pkg/golinters/containedctx/testdata/containedctx.go similarity index 100% rename from test/testdata/containedctx.go rename to pkg/golinters/containedctx/testdata/containedctx.go diff --git a/pkg/golinters/contextcheck.go b/pkg/golinters/contextcheck/contextcheck.go similarity index 89% rename from pkg/golinters/contextcheck.go rename to pkg/golinters/contextcheck/contextcheck.go index 0ab5750dad7c..a34c518b2c0f 100644 --- a/pkg/golinters/contextcheck.go +++ b/pkg/golinters/contextcheck/contextcheck.go @@ -1,4 +1,4 @@ -package golinters +package contextcheck import ( "github.com/kkHAIKE/contextcheck" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) -func NewContextCheck() *goanalysis.Linter { +func New() *goanalysis.Linter { analyzer := contextcheck.NewAnalyzer(contextcheck.Configuration{}) return goanalysis.NewLinter( diff --git a/pkg/golinters/contextcheck/contextcheck_integration_test.go b/pkg/golinters/contextcheck/contextcheck_integration_test.go new file mode 100644 index 000000000000..e5a1cdc09fef --- /dev/null +++ b/pkg/golinters/contextcheck/contextcheck_integration_test.go @@ -0,0 +1,11 @@ +package contextcheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/contextcheck.go b/pkg/golinters/contextcheck/testdata/contextcheck.go similarity index 100% rename from test/testdata/contextcheck.go rename to pkg/golinters/contextcheck/testdata/contextcheck.go diff --git a/pkg/golinters/copyloopvar.go b/pkg/golinters/copyloopvar/copyloopvar.go similarity index 84% rename from pkg/golinters/copyloopvar.go rename to pkg/golinters/copyloopvar/copyloopvar.go index fa49cbd84b8b..14d0271f248e 100644 --- a/pkg/golinters/copyloopvar.go +++ b/pkg/golinters/copyloopvar/copyloopvar.go @@ -1,4 +1,4 @@ -package golinters +package copyloopvar import ( "github.com/karamaru-alpha/copyloopvar" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewCopyLoopVar(settings *config.CopyLoopVarSettings) *goanalysis.Linter { +func New(settings *config.CopyLoopVarSettings) *goanalysis.Linter { a := copyloopvar.NewAnalyzer() var cfg map[string]map[string]any diff --git a/pkg/golinters/copyloopvar/copyloopvar_integration_test.go b/pkg/golinters/copyloopvar/copyloopvar_integration_test.go new file mode 100644 index 000000000000..d26700d9dfd9 --- /dev/null +++ b/pkg/golinters/copyloopvar/copyloopvar_integration_test.go @@ -0,0 +1,11 @@ +package copyloopvar + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/copyloopvar.go b/pkg/golinters/copyloopvar/testdata/copyloopvar.go similarity index 100% rename from test/testdata/copyloopvar.go rename to pkg/golinters/copyloopvar/testdata/copyloopvar.go diff --git a/test/testdata/configs/copyloopvar.yml b/pkg/golinters/copyloopvar/testdata/copyloopvar.yml similarity index 100% rename from test/testdata/configs/copyloopvar.yml rename to pkg/golinters/copyloopvar/testdata/copyloopvar.yml diff --git a/test/testdata/copyloopvar_custom.go b/pkg/golinters/copyloopvar/testdata/copyloopvar_custom.go similarity index 93% rename from test/testdata/copyloopvar_custom.go rename to pkg/golinters/copyloopvar/testdata/copyloopvar_custom.go index 9ee37c6c005e..a7ee6238768f 100644 --- a/test/testdata/copyloopvar_custom.go +++ b/pkg/golinters/copyloopvar/testdata/copyloopvar_custom.go @@ -1,7 +1,7 @@ //go:build go1.22 //golangcitest:args -Ecopyloopvar -//golangcitest:config_path testdata/configs/copyloopvar.yml +//golangcitest:config_path testdata/copyloopvar.yml package testdata import "fmt" diff --git a/pkg/golinters/cyclop.go b/pkg/golinters/cyclop/cyclop.go similarity index 90% rename from pkg/golinters/cyclop.go rename to pkg/golinters/cyclop/cyclop.go index 2b4a4a0ba45a..eb8c0577a5a2 100644 --- a/pkg/golinters/cyclop.go +++ b/pkg/golinters/cyclop/cyclop.go @@ -1,4 +1,4 @@ -package golinters +package cyclop import ( "github.com/bkielbasa/cyclop/pkg/analyzer" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewCyclop(settings *config.Cyclop) *goanalysis.Linter { +func New(settings *config.Cyclop) *goanalysis.Linter { a := analyzer.NewAnalyzer() var cfg map[string]map[string]any diff --git a/pkg/golinters/cyclop/cyclop_integration_test.go b/pkg/golinters/cyclop/cyclop_integration_test.go new file mode 100644 index 000000000000..2e1568142ea0 --- /dev/null +++ b/pkg/golinters/cyclop/cyclop_integration_test.go @@ -0,0 +1,11 @@ +package cyclop + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/cyclop.go b/pkg/golinters/cyclop/testdata/cyclop.go similarity index 89% rename from test/testdata/cyclop.go rename to pkg/golinters/cyclop/testdata/cyclop.go index e954d3fcbf05..49f47be40cdb 100644 --- a/test/testdata/cyclop.go +++ b/pkg/golinters/cyclop/testdata/cyclop.go @@ -1,5 +1,5 @@ //golangcitest:args -Ecyclop -//golangcitest:config_path testdata/configs/cyclop.yml +//golangcitest:config_path testdata/cyclop.yml package testdata func cyclopComplexFunc(s string) { // want "calculated cyclomatic complexity for function cyclopComplexFunc is 22, max is 15" diff --git a/test/testdata/configs/cyclop.yml b/pkg/golinters/cyclop/testdata/cyclop.yml similarity index 100% rename from test/testdata/configs/cyclop.yml rename to pkg/golinters/cyclop/testdata/cyclop.yml diff --git a/pkg/golinters/decorder.go b/pkg/golinters/decorder/decorder.go similarity index 93% rename from pkg/golinters/decorder.go rename to pkg/golinters/decorder/decorder.go index e41482ee1005..a05f6a32573f 100644 --- a/pkg/golinters/decorder.go +++ b/pkg/golinters/decorder/decorder.go @@ -1,4 +1,4 @@ -package golinters +package decorder import ( "strings" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewDecorder(settings *config.DecorderSettings) *goanalysis.Linter { +func New(settings *config.DecorderSettings) *goanalysis.Linter { a := decorder.Analyzer // disable all rules/checks by default diff --git a/pkg/golinters/decorder/decorder_integration_test.go b/pkg/golinters/decorder/decorder_integration_test.go new file mode 100644 index 000000000000..78d7a1a9a453 --- /dev/null +++ b/pkg/golinters/decorder/decorder_integration_test.go @@ -0,0 +1,11 @@ +package decorder + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/decorder.go b/pkg/golinters/decorder/testdata/decorder.go similarity index 100% rename from test/testdata/decorder.go rename to pkg/golinters/decorder/testdata/decorder.go diff --git a/test/testdata/decorder_custom.go b/pkg/golinters/decorder/testdata/decorder_custom.go similarity index 85% rename from test/testdata/decorder_custom.go rename to pkg/golinters/decorder/testdata/decorder_custom.go index 4379df50bc37..06cadcd7369a 100644 --- a/test/testdata/decorder_custom.go +++ b/pkg/golinters/decorder/testdata/decorder_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Edecorder -//golangcitest:config_path testdata/configs/decorder_custom.yml +//golangcitest:config_path testdata/decorder_custom.yml package testdata import "math" diff --git a/test/testdata/configs/decorder_custom.yml b/pkg/golinters/decorder/testdata/decorder_custom.yml similarity index 100% rename from test/testdata/configs/decorder_custom.yml rename to pkg/golinters/decorder/testdata/decorder_custom.yml diff --git a/pkg/golinters/depguard.go b/pkg/golinters/depguard/depguard.go similarity index 92% rename from pkg/golinters/depguard.go rename to pkg/golinters/depguard/depguard.go index 484d33d7273c..d2aedf252446 100644 --- a/pkg/golinters/depguard.go +++ b/pkg/golinters/depguard/depguard.go @@ -1,4 +1,4 @@ -package golinters +package depguard import ( "github.com/OpenPeeDeeP/depguard/v2" @@ -9,7 +9,7 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) -func NewDepguard(settings *config.DepGuardSettings) *goanalysis.Linter { +func New(settings *config.DepGuardSettings) *goanalysis.Linter { conf := depguard.LinterSettings{} if settings != nil { diff --git a/pkg/golinters/depguard/depguard_integration_test.go b/pkg/golinters/depguard/depguard_integration_test.go new file mode 100644 index 000000000000..4c541f2e6555 --- /dev/null +++ b/pkg/golinters/depguard/depguard_integration_test.go @@ -0,0 +1,11 @@ +package depguard + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/depguard.go b/pkg/golinters/depguard/testdata/depguard.go similarity index 89% rename from test/testdata/depguard.go rename to pkg/golinters/depguard/testdata/depguard.go index 5aa20fded6ec..4c1166796545 100644 --- a/test/testdata/depguard.go +++ b/pkg/golinters/depguard/testdata/depguard.go @@ -1,5 +1,5 @@ //golangcitest:args -Edepguard -//golangcitest:config_path testdata/configs/depguard.yml +//golangcitest:config_path testdata/depguard.yml package testdata import ( diff --git a/test/testdata/configs/depguard.yml b/pkg/golinters/depguard/testdata/depguard.yml similarity index 100% rename from test/testdata/configs/depguard.yml rename to pkg/golinters/depguard/testdata/depguard.yml diff --git a/test/testdata/depguard_additional_guards.go b/pkg/golinters/depguard/testdata/depguard_additional_guards.go similarity index 90% rename from test/testdata/depguard_additional_guards.go rename to pkg/golinters/depguard/testdata/depguard_additional_guards.go index 01e85c01f58c..f06805f6f173 100644 --- a/test/testdata/depguard_additional_guards.go +++ b/pkg/golinters/depguard/testdata/depguard_additional_guards.go @@ -1,5 +1,5 @@ //golangcitest:args -Edepguard -//golangcitest:config_path testdata/configs/depguard_additional_guards.yml +//golangcitest:config_path testdata/depguard_additional_guards.yml package testdata import ( diff --git a/test/testdata/configs/depguard_additional_guards.yml b/pkg/golinters/depguard/testdata/depguard_additional_guards.yml similarity index 100% rename from test/testdata/configs/depguard_additional_guards.yml rename to pkg/golinters/depguard/testdata/depguard_additional_guards.yml diff --git a/test/testdata/depguard_ignore_file_rules.go b/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.go similarity index 79% rename from test/testdata/depguard_ignore_file_rules.go rename to pkg/golinters/depguard/testdata/depguard_ignore_file_rules.go index d7b9401dcf4f..773474d7fcc9 100644 --- a/test/testdata/depguard_ignore_file_rules.go +++ b/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.go @@ -1,5 +1,5 @@ //golangcitest:args -Edepguard -//golangcitest:config_path testdata/configs/depguard_ignore_file_rules.yml +//golangcitest:config_path testdata/depguard_ignore_file_rules.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/configs/depguard_ignore_file_rules.yml b/pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml similarity index 100% rename from test/testdata/configs/depguard_ignore_file_rules.yml rename to pkg/golinters/depguard/testdata/depguard_ignore_file_rules.yml diff --git a/pkg/golinters/dogsled.go b/pkg/golinters/dogsled/dogsled.go similarity index 91% rename from pkg/golinters/dogsled.go rename to pkg/golinters/dogsled/dogsled.go index 11a3c3a9f4ca..02705eb1b395 100644 --- a/pkg/golinters/dogsled.go +++ b/pkg/golinters/dogsled/dogsled.go @@ -1,4 +1,4 @@ -package golinters +package dogsled import ( "fmt" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const dogsledName = "dogsled" +const name = "dogsled" -func NewDogsled(settings *config.DogsledSettings) *goanalysis.Linter { +func New(settings *config.DogsledSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: dogsledName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues := runDogsled(pass, settings) @@ -39,7 +39,7 @@ func NewDogsled(settings *config.DogsledSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - dogsledName, + name, "Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())", []*analysis.Analyzer{analyzer}, nil, @@ -100,7 +100,7 @@ func (v *returnsVisitor) Visit(node ast.Node) ast.Visitor { if numBlank > v.maxBlanks { v.issues = append(v.issues, result.Issue{ - FromLinter: dogsledName, + FromLinter: name, Text: fmt.Sprintf("declaration has %v blank identifiers", numBlank), Pos: v.f.Position(assgnStmt.Pos()), }) diff --git a/pkg/golinters/dogsled/dogsled_integration_test.go b/pkg/golinters/dogsled/dogsled_integration_test.go new file mode 100644 index 000000000000..b84b5529941e --- /dev/null +++ b/pkg/golinters/dogsled/dogsled_integration_test.go @@ -0,0 +1,11 @@ +package dogsled + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/dogsled.go b/pkg/golinters/dogsled/testdata/dogsled.go similarity index 100% rename from test/testdata/dogsled.go rename to pkg/golinters/dogsled/testdata/dogsled.go diff --git a/pkg/golinters/dupl.go b/pkg/golinters/dupl/dupl.go similarity index 92% rename from pkg/golinters/dupl.go rename to pkg/golinters/dupl/dupl.go index 9ec5d38083ad..6268e04a3145 100644 --- a/pkg/golinters/dupl.go +++ b/pkg/golinters/dupl/dupl.go @@ -1,4 +1,4 @@ -package golinters +package dupl import ( "fmt" @@ -16,14 +16,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const duplName = "dupl" +const name = "dupl" -func NewDupl(settings *config.DuplSettings) *goanalysis.Linter { +func New(settings *config.DuplSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: duplName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runDupl(pass, settings) @@ -44,7 +44,7 @@ func NewDupl(settings *config.DuplSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - duplName, + name, "Tool for code clone detection", []*analysis.Analyzer{analyzer}, nil, @@ -88,7 +88,7 @@ func runDupl(pass *analysis.Pass, settings *config.DuplSettings) ([]goanalysis.I To: i.From.LineEnd(), }, Text: text, - FromLinter: duplName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/dupl/dupl_integration_test.go b/pkg/golinters/dupl/dupl_integration_test.go new file mode 100644 index 000000000000..ea0a14a964e5 --- /dev/null +++ b/pkg/golinters/dupl/dupl_integration_test.go @@ -0,0 +1,11 @@ +package dupl + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/dupl.go b/pkg/golinters/dupl/testdata/dupl.go similarity index 93% rename from test/testdata/dupl.go rename to pkg/golinters/dupl/testdata/dupl.go index 31a9cdd64034..d22cac401e10 100644 --- a/test/testdata/dupl.go +++ b/pkg/golinters/dupl/testdata/dupl.go @@ -1,5 +1,5 @@ //golangcitest:args -Edupl -//golangcitest:config_path testdata/configs/dupl.yml +//golangcitest:config_path testdata/dupl.yml package testdata type DuplLogger struct{} diff --git a/test/testdata/configs/dupl.yml b/pkg/golinters/dupl/testdata/dupl.yml similarity index 100% rename from test/testdata/configs/dupl.yml rename to pkg/golinters/dupl/testdata/dupl.yml diff --git a/pkg/golinters/dupword.go b/pkg/golinters/dupword/dupword.go similarity index 87% rename from pkg/golinters/dupword.go rename to pkg/golinters/dupword/dupword.go index 3d5242696dc2..bba4fc9e1995 100644 --- a/pkg/golinters/dupword.go +++ b/pkg/golinters/dupword/dupword.go @@ -1,4 +1,4 @@ -package golinters +package dupword import ( "strings" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewDupWord(setting *config.DupWordSettings) *goanalysis.Linter { +func New(setting *config.DupWordSettings) *goanalysis.Linter { a := dupword.NewAnalyzer() cfgMap := map[string]map[string]any{} diff --git a/pkg/golinters/dupword/dupword_integration_test.go b/pkg/golinters/dupword/dupword_integration_test.go new file mode 100644 index 000000000000..9a5c50606e16 --- /dev/null +++ b/pkg/golinters/dupword/dupword_integration_test.go @@ -0,0 +1,11 @@ +package dupword + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/dupword.go b/pkg/golinters/dupword/testdata/dupword.go similarity index 100% rename from test/testdata/dupword.go rename to pkg/golinters/dupword/testdata/dupword.go diff --git a/test/testdata/dupword_ignore_the.go b/pkg/golinters/dupword/testdata/dupword_ignore_the.go similarity index 86% rename from test/testdata/dupword_ignore_the.go rename to pkg/golinters/dupword/testdata/dupword_ignore_the.go index f321b005fa93..b00d19b22803 100644 --- a/test/testdata/dupword_ignore_the.go +++ b/pkg/golinters/dupword/testdata/dupword_ignore_the.go @@ -1,5 +1,5 @@ //golangcitest:args -Edupword -//golangcitest:config_path testdata/configs/dupword_ignore_the.yml +//golangcitest:config_path testdata/dupword_ignore_the.yml package testdata import "fmt" diff --git a/test/testdata/configs/dupword_ignore_the.yml b/pkg/golinters/dupword/testdata/dupword_ignore_the.yml similarity index 100% rename from test/testdata/configs/dupword_ignore_the.yml rename to pkg/golinters/dupword/testdata/dupword_ignore_the.yml diff --git a/pkg/golinters/durationcheck.go b/pkg/golinters/durationcheck/durationcheck.go similarity index 82% rename from pkg/golinters/durationcheck.go rename to pkg/golinters/durationcheck/durationcheck.go index c3324776521c..88f22c27c029 100644 --- a/pkg/golinters/durationcheck.go +++ b/pkg/golinters/durationcheck/durationcheck.go @@ -1,4 +1,4 @@ -package golinters +package durationcheck import ( "github.com/charithe/durationcheck" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewDurationCheck() *goanalysis.Linter { +func New() *goanalysis.Linter { a := durationcheck.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/durationcheck/durationcheck_integration_test.go b/pkg/golinters/durationcheck/durationcheck_integration_test.go new file mode 100644 index 000000000000..f684f9c2f660 --- /dev/null +++ b/pkg/golinters/durationcheck/durationcheck_integration_test.go @@ -0,0 +1,11 @@ +package durationcheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/durationcheck.go b/pkg/golinters/durationcheck/testdata/durationcheck.go similarity index 100% rename from test/testdata/durationcheck.go rename to pkg/golinters/durationcheck/testdata/durationcheck.go diff --git a/pkg/golinters/err113.go b/pkg/golinters/err113/err113.go similarity index 85% rename from pkg/golinters/err113.go rename to pkg/golinters/err113/err113.go index 32060a3462bc..2600128be155 100644 --- a/pkg/golinters/err113.go +++ b/pkg/golinters/err113/err113.go @@ -1,4 +1,4 @@ -package golinters +package err113 import ( "github.com/Djarvur/go-err113" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewErr113() *goanalysis.Linter { +func New() *goanalysis.Linter { a := err113.NewAnalyzer() return goanalysis.NewLinter( diff --git a/pkg/golinters/err113/err113_integration_test.go b/pkg/golinters/err113/err113_integration_test.go new file mode 100644 index 000000000000..70a66dd1d1fb --- /dev/null +++ b/pkg/golinters/err113/err113_integration_test.go @@ -0,0 +1,11 @@ +package err113 + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/err113.go b/pkg/golinters/err113/testdata/err113.go similarity index 100% rename from test/testdata/err113.go rename to pkg/golinters/err113/testdata/err113.go diff --git a/pkg/golinters/errcheck.go b/pkg/golinters/errcheck/errcheck.go similarity index 96% rename from pkg/golinters/errcheck.go rename to pkg/golinters/errcheck/errcheck.go index b945012edf9e..d546bab793b2 100644 --- a/pkg/golinters/errcheck.go +++ b/pkg/golinters/errcheck/errcheck.go @@ -1,4 +1,4 @@ -package golinters +package errcheck import ( "bufio" @@ -22,20 +22,20 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const errcheckName = "errcheck" +const name = "errcheck" -func NewErrcheck(settings *config.ErrcheckSettings) *goanalysis.Linter { +func New(settings *config.ErrcheckSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: errcheckName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: goanalysis.DummyRun, } return goanalysis.NewLinter( - errcheckName, + name, "errcheck is a program for checking for unchecked errors in Go code. "+ "These unchecked errors can be critical bugs in some cases", []*analysis.Analyzer{analyzer}, @@ -100,7 +100,7 @@ func runErrCheck(lintCtx *linter.Context, pass *analysis.Pass, checker *errcheck issues[i] = goanalysis.NewIssue( &result.Issue{ - FromLinter: errcheckName, + FromLinter: name, Text: text, Pos: err.Pos, }, diff --git a/pkg/golinters/errcheck/errcheck_integration_test.go b/pkg/golinters/errcheck/errcheck_integration_test.go new file mode 100644 index 000000000000..704b382354d3 --- /dev/null +++ b/pkg/golinters/errcheck/errcheck_integration_test.go @@ -0,0 +1,11 @@ +package errcheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/errcheck.go b/pkg/golinters/errcheck/testdata/errcheck.go similarity index 100% rename from test/testdata/errcheck.go rename to pkg/golinters/errcheck/testdata/errcheck.go diff --git a/test/testdata/errcheck_exclude.go b/pkg/golinters/errcheck/testdata/errcheck_exclude.go similarity index 82% rename from test/testdata/errcheck_exclude.go rename to pkg/golinters/errcheck/testdata/errcheck_exclude.go index 9b9907c2f8aa..427e33d6fd44 100644 --- a/test/testdata/errcheck_exclude.go +++ b/pkg/golinters/errcheck/testdata/errcheck_exclude.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/configs/errcheck_exclude.yml +//golangcitest:config_path testdata/errcheck_exclude.yml package testdata import ( diff --git a/test/testdata/configs/errcheck_exclude.txt b/pkg/golinters/errcheck/testdata/errcheck_exclude.txt similarity index 100% rename from test/testdata/configs/errcheck_exclude.txt rename to pkg/golinters/errcheck/testdata/errcheck_exclude.txt diff --git a/test/testdata/configs/errcheck_exclude.yml b/pkg/golinters/errcheck/testdata/errcheck_exclude.yml similarity index 100% rename from test/testdata/configs/errcheck_exclude.yml rename to pkg/golinters/errcheck/testdata/errcheck_exclude.yml diff --git a/test/testdata/errcheck_exclude_functions.go b/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.go similarity index 82% rename from test/testdata/errcheck_exclude_functions.go rename to pkg/golinters/errcheck/testdata/errcheck_exclude_functions.go index 787b84c6a808..dda6e3d7de26 100644 --- a/test/testdata/errcheck_exclude_functions.go +++ b/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/configs/errcheck_exclude_functions.yml +//golangcitest:config_path testdata/errcheck_exclude_functions.yml package testdata import ( diff --git a/test/testdata/configs/errcheck_exclude_functions.yml b/pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml similarity index 100% rename from test/testdata/configs/errcheck_exclude_functions.yml rename to pkg/golinters/errcheck/testdata/errcheck_exclude_functions.yml diff --git a/test/testdata/errcheck_ignore.go b/pkg/golinters/errcheck/testdata/errcheck_ignore.go similarity index 86% rename from test/testdata/errcheck_ignore.go rename to pkg/golinters/errcheck/testdata/errcheck_ignore.go index 0f8e2dcd27e1..7919de145502 100644 --- a/test/testdata/errcheck_ignore.go +++ b/pkg/golinters/errcheck/testdata/errcheck_ignore.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/configs/errcheck_ignore_config.yml +//golangcitest:config_path testdata/errcheck_ignore_config.yml package testdata import ( diff --git a/test/testdata/configs/errcheck_ignore_config.yml b/pkg/golinters/errcheck/testdata/errcheck_ignore_config.yml similarity index 100% rename from test/testdata/configs/errcheck_ignore_config.yml rename to pkg/golinters/errcheck/testdata/errcheck_ignore_config.yml diff --git a/test/testdata/errcheck_ignore_default.go b/pkg/golinters/errcheck/testdata/errcheck_ignore_default.go similarity index 85% rename from test/testdata/errcheck_ignore_default.go rename to pkg/golinters/errcheck/testdata/errcheck_ignore_default.go index 6052433cbf32..002931efdd30 100644 --- a/test/testdata/errcheck_ignore_default.go +++ b/pkg/golinters/errcheck/testdata/errcheck_ignore_default.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/configs/errcheck_ignore_default.yml +//golangcitest:config_path testdata/errcheck_ignore_default.yml package testdata import ( diff --git a/test/testdata/configs/errcheck_ignore_default.yml b/pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml similarity index 100% rename from test/testdata/configs/errcheck_ignore_default.yml rename to pkg/golinters/errcheck/testdata/errcheck_ignore_default.yml diff --git a/test/testdata/errcheck_type_assertions.go b/pkg/golinters/errcheck/testdata/errcheck_type_assertions.go similarity index 75% rename from test/testdata/errcheck_type_assertions.go rename to pkg/golinters/errcheck/testdata/errcheck_type_assertions.go index e3c19441507b..983c5c3f0e2e 100644 --- a/test/testdata/errcheck_type_assertions.go +++ b/pkg/golinters/errcheck/testdata/errcheck_type_assertions.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config_path testdata/configs/errcheck_type_assertions.yml +//golangcitest:config_path testdata/errcheck_type_assertions.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/configs/errcheck_type_assertions.yml b/pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml similarity index 100% rename from test/testdata/configs/errcheck_type_assertions.yml rename to pkg/golinters/errcheck/testdata/errcheck_type_assertions.yml diff --git a/pkg/golinters/errchkjson.go b/pkg/golinters/errchkjson/errchkjson.go similarity index 87% rename from pkg/golinters/errchkjson.go rename to pkg/golinters/errchkjson/errchkjson.go index 641e87010483..8389a750c6c8 100644 --- a/pkg/golinters/errchkjson.go +++ b/pkg/golinters/errchkjson/errchkjson.go @@ -1,4 +1,4 @@ -package golinters +package errchkjson import ( "github.com/breml/errchkjson" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewErrChkJSON(cfg *config.ErrChkJSONSettings) *goanalysis.Linter { +func New(cfg *config.ErrChkJSONSettings) *goanalysis.Linter { a := errchkjson.NewAnalyzer() cfgMap := map[string]map[string]any{} diff --git a/pkg/golinters/errchkjson/errchkjson_integration_test.go b/pkg/golinters/errchkjson/errchkjson_integration_test.go new file mode 100644 index 000000000000..4e89dab86e68 --- /dev/null +++ b/pkg/golinters/errchkjson/errchkjson_integration_test.go @@ -0,0 +1,11 @@ +package errchkjson + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/errchkjson.go b/pkg/golinters/errchkjson/testdata/errchkjson.go similarity index 99% rename from test/testdata/errchkjson.go rename to pkg/golinters/errchkjson/testdata/errchkjson.go index f641597b62da..00a60f443ac0 100644 --- a/test/testdata/errchkjson.go +++ b/pkg/golinters/errchkjson/testdata/errchkjson.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrchkjson -//golangcitest:config_path testdata/configs/errchkjson.yml +//golangcitest:config_path testdata/errchkjson.yml package testdata import ( diff --git a/test/testdata/configs/errchkjson.yml b/pkg/golinters/errchkjson/testdata/errchkjson.yml similarity index 100% rename from test/testdata/configs/errchkjson.yml rename to pkg/golinters/errchkjson/testdata/errchkjson.yml diff --git a/test/testdata/errchkjson_check_error_free_encoding.go b/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.go similarity index 99% rename from test/testdata/errchkjson_check_error_free_encoding.go rename to pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.go index c14521c75e75..c20cf4538338 100644 --- a/test/testdata/errchkjson_check_error_free_encoding.go +++ b/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrchkjson -//golangcitest:config_path testdata/configs/errchkjson_check_error_free_encoding.yml +//golangcitest:config_path testdata/errchkjson_check_error_free_encoding.yml package testdata import ( diff --git a/test/testdata/configs/errchkjson_check_error_free_encoding.yml b/pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml similarity index 100% rename from test/testdata/configs/errchkjson_check_error_free_encoding.yml rename to pkg/golinters/errchkjson/testdata/errchkjson_check_error_free_encoding.yml diff --git a/test/testdata/errchkjson_no_exported.go b/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.go similarity index 92% rename from test/testdata/errchkjson_no_exported.go rename to pkg/golinters/errchkjson/testdata/errchkjson_no_exported.go index e609de0da21b..d1d0008b71d4 100644 --- a/test/testdata/errchkjson_no_exported.go +++ b/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrchkjson -//golangcitest:config_path testdata/configs/errchkjson_no_exported.yml +//golangcitest:config_path testdata/errchkjson_no_exported.yml package testdata import ( diff --git a/test/testdata/configs/errchkjson_no_exported.yml b/pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml similarity index 100% rename from test/testdata/configs/errchkjson_no_exported.yml rename to pkg/golinters/errchkjson/testdata/errchkjson_no_exported.yml diff --git a/pkg/golinters/errname.go b/pkg/golinters/errname/errname.go similarity index 83% rename from pkg/golinters/errname.go rename to pkg/golinters/errname/errname.go index ce64f374c8a5..f868854c1286 100644 --- a/pkg/golinters/errname.go +++ b/pkg/golinters/errname/errname.go @@ -1,4 +1,4 @@ -package golinters +package errname import ( "github.com/Antonboom/errname/pkg/analyzer" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewErrName() *goanalysis.Linter { +func New() *goanalysis.Linter { a := analyzer.New() return goanalysis.NewLinter( diff --git a/pkg/golinters/errname/errname_integration_test.go b/pkg/golinters/errname/errname_integration_test.go new file mode 100644 index 000000000000..62b0422c7f78 --- /dev/null +++ b/pkg/golinters/errname/errname_integration_test.go @@ -0,0 +1,11 @@ +package errname + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/errname.go b/pkg/golinters/errname/testdata/errname.go similarity index 100% rename from test/testdata/errname.go rename to pkg/golinters/errname/testdata/errname.go diff --git a/pkg/golinters/errorlint.go b/pkg/golinters/errorlint/errorlint.go similarity index 89% rename from pkg/golinters/errorlint.go rename to pkg/golinters/errorlint/errorlint.go index adc3eadf270a..5eb78f192828 100644 --- a/pkg/golinters/errorlint.go +++ b/pkg/golinters/errorlint/errorlint.go @@ -1,4 +1,4 @@ -package golinters +package errorlint import ( "github.com/polyfloyd/go-errorlint/errorlint" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter { +func New(cfg *config.ErrorLintSettings) *goanalysis.Linter { a := errorlint.NewAnalyzer() cfgMap := map[string]map[string]any{} diff --git a/pkg/golinters/errorlint/errorlint_integration_test.go b/pkg/golinters/errorlint/errorlint_integration_test.go new file mode 100644 index 000000000000..b25d3914d425 --- /dev/null +++ b/pkg/golinters/errorlint/errorlint_integration_test.go @@ -0,0 +1,11 @@ +package errorlint + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/errorlint.go b/pkg/golinters/errorlint/testdata/errorlint.go similarity index 100% rename from test/testdata/errorlint.go rename to pkg/golinters/errorlint/testdata/errorlint.go diff --git a/test/testdata/errorlint_asserts.go b/pkg/golinters/errorlint/testdata/errorlint_asserts.go similarity index 94% rename from test/testdata/errorlint_asserts.go rename to pkg/golinters/errorlint/testdata/errorlint_asserts.go index f3357eb35a0e..46e889d9d6e3 100644 --- a/test/testdata/errorlint_asserts.go +++ b/pkg/golinters/errorlint/testdata/errorlint_asserts.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrorlint -//golangcitest:config_path testdata/configs/errorlint_asserts.yml +//golangcitest:config_path testdata/errorlint_asserts.yml package testdata import ( diff --git a/test/testdata/configs/errorlint_asserts.yml b/pkg/golinters/errorlint/testdata/errorlint_asserts.yml similarity index 100% rename from test/testdata/configs/errorlint_asserts.yml rename to pkg/golinters/errorlint/testdata/errorlint_asserts.yml diff --git a/test/testdata/errorlint_comparison.go b/pkg/golinters/errorlint/testdata/errorlint_comparison.go similarity index 95% rename from test/testdata/errorlint_comparison.go rename to pkg/golinters/errorlint/testdata/errorlint_comparison.go index 41ef591d7ffc..7e0e31136734 100644 --- a/test/testdata/errorlint_comparison.go +++ b/pkg/golinters/errorlint/testdata/errorlint_comparison.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrorlint -//golangcitest:config_path testdata/configs/errorlint_comparison.yml +//golangcitest:config_path testdata/errorlint_comparison.yml package testdata import ( diff --git a/test/testdata/configs/errorlint_comparison.yml b/pkg/golinters/errorlint/testdata/errorlint_comparison.yml similarity index 100% rename from test/testdata/configs/errorlint_comparison.yml rename to pkg/golinters/errorlint/testdata/errorlint_comparison.yml diff --git a/test/testdata/errorlint_errorf.go b/pkg/golinters/errorlint/testdata/errorlint_errorf.go similarity index 90% rename from test/testdata/errorlint_errorf.go rename to pkg/golinters/errorlint/testdata/errorlint_errorf.go index 3b727f630c11..9f1a7b28eeb3 100644 --- a/test/testdata/errorlint_errorf.go +++ b/pkg/golinters/errorlint/testdata/errorlint_errorf.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrorlint -//golangcitest:config_path testdata/configs/errorlint_errorf.yml +//golangcitest:config_path testdata/errorlint_errorf.yml package testdata import ( diff --git a/test/testdata/configs/errorlint_errorf.yml b/pkg/golinters/errorlint/testdata/errorlint_errorf.yml similarity index 100% rename from test/testdata/configs/errorlint_errorf.yml rename to pkg/golinters/errorlint/testdata/errorlint_errorf.yml diff --git a/pkg/golinters/execinquery.go b/pkg/golinters/execinquery/execinquery.go similarity index 82% rename from pkg/golinters/execinquery.go rename to pkg/golinters/execinquery/execinquery.go index 6c5bcb63129c..3832873c6367 100644 --- a/pkg/golinters/execinquery.go +++ b/pkg/golinters/execinquery/execinquery.go @@ -1,4 +1,4 @@ -package golinters +package execinquery import ( "github.com/lufeee/execinquery" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewExecInQuery() *goanalysis.Linter { +func New() *goanalysis.Linter { a := execinquery.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/execinquery/execinquery_integration_test.go b/pkg/golinters/execinquery/execinquery_integration_test.go new file mode 100644 index 000000000000..4ee2ca919656 --- /dev/null +++ b/pkg/golinters/execinquery/execinquery_integration_test.go @@ -0,0 +1,11 @@ +package execinquery + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/execinquery.go b/pkg/golinters/execinquery/testdata/execinquery.go similarity index 100% rename from test/testdata/execinquery.go rename to pkg/golinters/execinquery/testdata/execinquery.go diff --git a/pkg/golinters/exhaustive.go b/pkg/golinters/exhaustive/exhaustive.go similarity index 92% rename from pkg/golinters/exhaustive.go rename to pkg/golinters/exhaustive/exhaustive.go index 6280cbb5629c..9249efb69a38 100644 --- a/pkg/golinters/exhaustive.go +++ b/pkg/golinters/exhaustive/exhaustive.go @@ -1,4 +1,4 @@ -package golinters +package exhaustive import ( "github.com/nishanths/exhaustive" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter { +func New(settings *config.ExhaustiveSettings) *goanalysis.Linter { a := exhaustive.Analyzer var cfg map[string]map[string]any diff --git a/pkg/golinters/exhaustive/exhaustive_integration_test.go b/pkg/golinters/exhaustive/exhaustive_integration_test.go new file mode 100644 index 000000000000..2c06bc619f7d --- /dev/null +++ b/pkg/golinters/exhaustive/exhaustive_integration_test.go @@ -0,0 +1,11 @@ +package exhaustive + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/exhaustive.go b/pkg/golinters/exhaustive/testdata/exhaustive.go similarity index 100% rename from test/testdata/exhaustive.go rename to pkg/golinters/exhaustive/testdata/exhaustive.go diff --git a/test/testdata/exhaustive_default.go b/pkg/golinters/exhaustive/testdata/exhaustive_default.go similarity index 87% rename from test/testdata/exhaustive_default.go rename to pkg/golinters/exhaustive/testdata/exhaustive_default.go index 6732f3dab886..d887b7298dd0 100644 --- a/test/testdata/exhaustive_default.go +++ b/pkg/golinters/exhaustive/testdata/exhaustive_default.go @@ -1,5 +1,5 @@ //golangcitest:args -Eexhaustive -//golangcitest:config_path testdata/configs/exhaustive_default.yml +//golangcitest:config_path testdata/exhaustive_default.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/configs/exhaustive_default.yml b/pkg/golinters/exhaustive/testdata/exhaustive_default.yml similarity index 100% rename from test/testdata/configs/exhaustive_default.yml rename to pkg/golinters/exhaustive/testdata/exhaustive_default.yml diff --git a/test/testdata/exhaustive_generated.go b/pkg/golinters/exhaustive/testdata/exhaustive_generated.go similarity index 100% rename from test/testdata/exhaustive_generated.go rename to pkg/golinters/exhaustive/testdata/exhaustive_generated.go diff --git a/test/testdata/exhaustive_ignore_enum_members.go b/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.go similarity index 83% rename from test/testdata/exhaustive_ignore_enum_members.go rename to pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.go index 0ad9798cbcb9..b18aab3bbb0d 100644 --- a/test/testdata/exhaustive_ignore_enum_members.go +++ b/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.go @@ -1,5 +1,5 @@ //golangcitest:args -Eexhaustive -//golangcitest:config_path testdata/configs/exhaustive_ignore_enum_members.yml +//golangcitest:config_path testdata/exhaustive_ignore_enum_members.yml package testdata type Direction int diff --git a/test/testdata/configs/exhaustive_ignore_enum_members.yml b/pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml similarity index 100% rename from test/testdata/configs/exhaustive_ignore_enum_members.yml rename to pkg/golinters/exhaustive/testdata/exhaustive_ignore_enum_members.yml diff --git a/pkg/golinters/exhaustruct.go b/pkg/golinters/exhaustruct/exhaustruct.go similarity index 87% rename from pkg/golinters/exhaustruct.go rename to pkg/golinters/exhaustruct/exhaustruct.go index 4621b7bf5779..53ad87154fef 100644 --- a/pkg/golinters/exhaustruct.go +++ b/pkg/golinters/exhaustruct/exhaustruct.go @@ -1,4 +1,4 @@ -package golinters +package exhaustruct import ( "github.com/GaijinEntertainment/go-exhaustruct/v3/analyzer" @@ -9,7 +9,7 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/internal" ) -func NewExhaustruct(settings *config.ExhaustructSettings) *goanalysis.Linter { +func New(settings *config.ExhaustructSettings) *goanalysis.Linter { var include, exclude []string if settings != nil { include = settings.Include diff --git a/pkg/golinters/exhaustruct/exhaustruct_integration_test.go b/pkg/golinters/exhaustruct/exhaustruct_integration_test.go new file mode 100644 index 000000000000..5d094b1a394b --- /dev/null +++ b/pkg/golinters/exhaustruct/exhaustruct_integration_test.go @@ -0,0 +1,11 @@ +package exhaustruct + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/exhaustruct.go b/pkg/golinters/exhaustruct/testdata/exhaustruct.go similarity index 100% rename from test/testdata/exhaustruct.go rename to pkg/golinters/exhaustruct/testdata/exhaustruct.go diff --git a/test/testdata/configs/exhaustruct.yml b/pkg/golinters/exhaustruct/testdata/exhaustruct.yml similarity index 100% rename from test/testdata/configs/exhaustruct.yml rename to pkg/golinters/exhaustruct/testdata/exhaustruct.yml diff --git a/test/testdata/exhaustruct_custom.go b/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.go similarity index 96% rename from test/testdata/exhaustruct_custom.go rename to pkg/golinters/exhaustruct/testdata/exhaustruct_custom.go index 11105af0c48a..6e79856a2f62 100644 --- a/test/testdata/exhaustruct_custom.go +++ b/pkg/golinters/exhaustruct/testdata/exhaustruct_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Eexhaustruct -//golangcitest:config_path testdata/configs/exhaustruct.yml +//golangcitest:config_path testdata/exhaustruct.yml package testdata import "time" diff --git a/pkg/golinters/exportloopref.go b/pkg/golinters/exportloopref/exportloopref.go similarity index 82% rename from pkg/golinters/exportloopref.go rename to pkg/golinters/exportloopref/exportloopref.go index 30bdeedaa987..e232f8045d3f 100644 --- a/pkg/golinters/exportloopref.go +++ b/pkg/golinters/exportloopref/exportloopref.go @@ -1,4 +1,4 @@ -package golinters +package exportloopref import ( "github.com/kyoh86/exportloopref" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewExportLoopRef() *goanalysis.Linter { +func New() *goanalysis.Linter { a := exportloopref.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/exportloopref/exportloopref_integration_test.go b/pkg/golinters/exportloopref/exportloopref_integration_test.go new file mode 100644 index 000000000000..e2696afe9e4f --- /dev/null +++ b/pkg/golinters/exportloopref/exportloopref_integration_test.go @@ -0,0 +1,11 @@ +package exportloopref + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/exportloopref.go b/pkg/golinters/exportloopref/testdata/exportloopref.go similarity index 100% rename from test/testdata/exportloopref.go rename to pkg/golinters/exportloopref/testdata/exportloopref.go diff --git a/pkg/golinters/fatcontext.go b/pkg/golinters/fatcontext/fatcontext.go similarity index 83% rename from pkg/golinters/fatcontext.go rename to pkg/golinters/fatcontext/fatcontext.go index 8ea3102920f1..378025a8cc5e 100644 --- a/pkg/golinters/fatcontext.go +++ b/pkg/golinters/fatcontext/fatcontext.go @@ -1,4 +1,4 @@ -package golinters +package fatcontext import ( "github.com/Crocmagnon/fatcontext/pkg/analyzer" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewFatContext() *goanalysis.Linter { +func New() *goanalysis.Linter { a := analyzer.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/fatcontext/fatcontext_integration_test.go b/pkg/golinters/fatcontext/fatcontext_integration_test.go new file mode 100644 index 000000000000..e036cde55e10 --- /dev/null +++ b/pkg/golinters/fatcontext/fatcontext_integration_test.go @@ -0,0 +1,11 @@ +package fatcontext + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/fatcontext.go b/pkg/golinters/fatcontext/testdata/fatcontext.go similarity index 100% rename from test/testdata/fatcontext.go rename to pkg/golinters/fatcontext/testdata/fatcontext.go diff --git a/pkg/golinters/forbidigo.go b/pkg/golinters/forbidigo/forbidigo.go similarity index 90% rename from pkg/golinters/forbidigo.go rename to pkg/golinters/forbidigo/forbidigo.go index 194d4fa033ed..c25b5d09af44 100644 --- a/pkg/golinters/forbidigo.go +++ b/pkg/golinters/forbidigo/forbidigo.go @@ -1,4 +1,4 @@ -package golinters +package forbidigo import ( "fmt" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const forbidigoName = "forbidigo" +const name = "forbidigo" -func NewForbidigo(settings *config.ForbidigoSettings) *goanalysis.Linter { +func New(settings *config.ForbidigoSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: forbidigoName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runForbidigo(pass, settings) @@ -44,7 +44,7 @@ func NewForbidigo(settings *config.ForbidigoSettings) *goanalysis.Linter { // But we cannot make this depend on the settings and have to mirror the mode chosen in GetAllSupportedLinterConfigs, // therefore we have to use LoadModeTypesInfo in all cases. return goanalysis.NewLinter( - forbidigoName, + name, "Forbids identifiers", []*analysis.Analyzer{analyzer}, nil, @@ -73,7 +73,7 @@ func runForbidigo(pass *analysis.Pass, settings *config.ForbidigoSettings) ([]go forbid, err := forbidigo.NewLinter(patterns, options...) if err != nil { - return nil, fmt.Errorf("failed to create linter %q: %w", forbidigoName, err) + return nil, fmt.Errorf("failed to create linter %q: %w", name, err) } var issues []goanalysis.Issue @@ -94,7 +94,7 @@ func runForbidigo(pass *analysis.Pass, settings *config.ForbidigoSettings) ([]go issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: hint.Position(), Text: hint.Details(), - FromLinter: forbidigoName, + FromLinter: name, }, pass)) } } diff --git a/pkg/golinters/forbidigo/forbidigo_integration_test.go b/pkg/golinters/forbidigo/forbidigo_integration_test.go new file mode 100644 index 000000000000..180b1f4ed6f3 --- /dev/null +++ b/pkg/golinters/forbidigo/forbidigo_integration_test.go @@ -0,0 +1,11 @@ +package forbidigo + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/configs/forbidigo.yml b/pkg/golinters/forbidigo/testdata/forbidigo.yml similarity index 100% rename from test/testdata/configs/forbidigo.yml rename to pkg/golinters/forbidigo/testdata/forbidigo.yml diff --git a/test/testdata/forbidigo_example.go b/pkg/golinters/forbidigo/testdata/forbidigo_example.go similarity index 86% rename from test/testdata/forbidigo_example.go rename to pkg/golinters/forbidigo/testdata/forbidigo_example.go index 52114a4474b1..87132a6ee433 100644 --- a/test/testdata/forbidigo_example.go +++ b/pkg/golinters/forbidigo/testdata/forbidigo_example.go @@ -1,5 +1,5 @@ //golangcitest:args -Eforbidigo -//golangcitest:config_path testdata/configs/forbidigo.yml +//golangcitest:config_path testdata/forbidigo.yml package testdata import ( diff --git a/test/testdata/forbidigo_example_test.go b/pkg/golinters/forbidigo/testdata/forbidigo_example_test.go similarity index 78% rename from test/testdata/forbidigo_example_test.go rename to pkg/golinters/forbidigo/testdata/forbidigo_example_test.go index 18abb36dd461..7ec27cc13553 100644 --- a/test/testdata/forbidigo_example_test.go +++ b/pkg/golinters/forbidigo/testdata/forbidigo_example_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Eforbidigo -//golangcitest:config_path testdata/configs/forbidigo.yml +//golangcitest:config_path testdata/forbidigo.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/configs/forbidigo_include_godoc_examples.yml b/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml similarity index 100% rename from test/testdata/configs/forbidigo_include_godoc_examples.yml rename to pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples.yml diff --git a/test/testdata/forbidigo_include_godoc_examples_test.go b/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples_test.go similarity index 68% rename from test/testdata/forbidigo_include_godoc_examples_test.go rename to pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples_test.go index e44fa3fe9f40..d7b65bce0465 100644 --- a/test/testdata/forbidigo_include_godoc_examples_test.go +++ b/pkg/golinters/forbidigo/testdata/forbidigo_include_godoc_examples_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Eforbidigo -//golangcitest:config_path testdata/configs/forbidigo_include_godoc_examples.yml +//golangcitest:config_path testdata/forbidigo_include_godoc_examples.yml package testdata import "fmt" diff --git a/test/testdata/configs/forbidigo_struct.yml b/pkg/golinters/forbidigo/testdata/forbidigo_struct.yml similarity index 100% rename from test/testdata/configs/forbidigo_struct.yml rename to pkg/golinters/forbidigo/testdata/forbidigo_struct.yml diff --git a/test/testdata/forbidigo_struct_config.go b/pkg/golinters/forbidigo/testdata/forbidigo_struct_config.go similarity index 80% rename from test/testdata/forbidigo_struct_config.go rename to pkg/golinters/forbidigo/testdata/forbidigo_struct_config.go index c39ba208cee4..4bb9106e6932 100644 --- a/test/testdata/forbidigo_struct_config.go +++ b/pkg/golinters/forbidigo/testdata/forbidigo_struct_config.go @@ -1,5 +1,5 @@ //golangcitest:args -Eforbidigo -//golangcitest:config_path testdata/configs/forbidigo_struct.yml +//golangcitest:config_path testdata/forbidigo_struct.yml package testdata import ( diff --git a/pkg/golinters/forcetypeassert.go b/pkg/golinters/forcetypeassert/forcetypeassert.go similarity index 83% rename from pkg/golinters/forcetypeassert.go rename to pkg/golinters/forcetypeassert/forcetypeassert.go index 574e53c71970..741b57ceacbe 100644 --- a/pkg/golinters/forcetypeassert.go +++ b/pkg/golinters/forcetypeassert/forcetypeassert.go @@ -1,4 +1,4 @@ -package golinters +package forcetypeassert import ( "github.com/gostaticanalysis/forcetypeassert" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewForceTypeAssert() *goanalysis.Linter { +func New() *goanalysis.Linter { a := forcetypeassert.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/forcetypeassert/forcetypeassert_integration_test.go b/pkg/golinters/forcetypeassert/forcetypeassert_integration_test.go new file mode 100644 index 000000000000..e412f9f60b08 --- /dev/null +++ b/pkg/golinters/forcetypeassert/forcetypeassert_integration_test.go @@ -0,0 +1,11 @@ +package forcetypeassert + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/forcetypeassert.go b/pkg/golinters/forcetypeassert/testdata/forcetypeassert.go similarity index 100% rename from test/testdata/forcetypeassert.go rename to pkg/golinters/forcetypeassert/testdata/forcetypeassert.go diff --git a/pkg/golinters/funlen.go b/pkg/golinters/funlen/funlen.go similarity index 90% rename from pkg/golinters/funlen.go rename to pkg/golinters/funlen/funlen.go index 084028a754ad..403906676286 100644 --- a/pkg/golinters/funlen.go +++ b/pkg/golinters/funlen/funlen.go @@ -1,4 +1,4 @@ -package golinters +package funlen import ( "go/token" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const funlenName = "funlen" +const name = "funlen" -func NewFunlen(settings *config.FunlenSettings) *goanalysis.Linter { +func New(settings *config.FunlenSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: funlenName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues := runFunlen(pass, settings) @@ -39,7 +39,7 @@ func NewFunlen(settings *config.FunlenSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - funlenName, + name, "Tool for detection of long functions", []*analysis.Analyzer{analyzer}, nil, @@ -67,7 +67,7 @@ func runFunlen(pass *analysis.Pass, settings *config.FunlenSettings) []goanalysi Line: i.Pos.Line, }, Text: strings.TrimRight(i.Message, "\n"), - FromLinter: funlenName, + FromLinter: name, }, pass) } diff --git a/pkg/golinters/funlen/funlen_integration_test.go b/pkg/golinters/funlen/funlen_integration_test.go new file mode 100644 index 000000000000..f84d390c715c --- /dev/null +++ b/pkg/golinters/funlen/funlen_integration_test.go @@ -0,0 +1,11 @@ +package funlen + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/funlen.go b/pkg/golinters/funlen/testdata/funlen.go similarity index 90% rename from test/testdata/funlen.go rename to pkg/golinters/funlen/testdata/funlen.go index 4dd92c80f535..37ce5ceb1bcf 100644 --- a/test/testdata/funlen.go +++ b/pkg/golinters/funlen/testdata/funlen.go @@ -1,5 +1,5 @@ //golangcitest:args -Efunlen -//golangcitest:config_path testdata/configs/funlen.yml +//golangcitest:config_path testdata/funlen.yml package testdata func TooManyLines() { // want `Function 'TooManyLines' is too long \(22 > 20\)` diff --git a/test/testdata/configs/funlen.yml b/pkg/golinters/funlen/testdata/funlen.yml similarity index 100% rename from test/testdata/configs/funlen.yml rename to pkg/golinters/funlen/testdata/funlen.yml diff --git a/pkg/golinters/gci.go b/pkg/golinters/gci/gci.go similarity index 96% rename from pkg/golinters/gci.go rename to pkg/golinters/gci/gci.go index 9fe75aa99ebd..a132633fce68 100644 --- a/pkg/golinters/gci.go +++ b/pkg/golinters/gci/gci.go @@ -1,4 +1,4 @@ -package golinters +package gci import ( "fmt" @@ -23,14 +23,14 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) -const gciName = "gci" +const name = "gci" -func NewGci(settings *config.GciSettings) *goanalysis.Linter { +func New(settings *config.GciSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: gciName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: goanalysis.DummyRun, Requires: []*analysis.Analyzer{ @@ -63,7 +63,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter { var lock sync.Mutex return goanalysis.NewLinter( - gciName, + name, "Gci controls Go package import order and makes it always deterministic.", []*analysis.Analyzer{analyzer}, nil, @@ -111,7 +111,7 @@ func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gcicfg.Config, lo continue } - is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, gciName, getIssuedTextGci) + is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, name, getIssuedTextGci) if err != nil { return nil, fmt.Errorf("can't extract issues from gci diff output %s: %w", diff, err) } diff --git a/pkg/golinters/gci/gci_integration_test.go b/pkg/golinters/gci/gci_integration_test.go new file mode 100644 index 000000000000..8d099b7b5af2 --- /dev/null +++ b/pkg/golinters/gci/gci_integration_test.go @@ -0,0 +1,19 @@ +package gci + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/out/gci.go b/pkg/golinters/gci/testdata/fix/in/gci.go similarity index 86% rename from test/testdata/fix/out/gci.go rename to pkg/golinters/gci/testdata/fix/in/gci.go index 0f1fc812f7f9..4e40da136c7f 100644 --- a/test/testdata/fix/out/gci.go +++ b/pkg/golinters/gci/testdata/fix/in/gci.go @@ -1,15 +1,15 @@ //golangcitest:args -Egci -//golangcitest:config_path testdata/configs/gci.yml +//golangcitest:config_path testdata/gci.yml //golangcitest:expected_exitcode 0 package gci import ( + "github.com/golangci/golangci-lint/pkg/config" + "golang.org/x/tools/go/analysis" + "fmt" gcicfg "github.com/daixiang0/gci/pkg/config" - "github.com/golangci/golangci-lint/pkg/config" - - "golang.org/x/tools/go/analysis" ) func GoimportsLocalTest() { diff --git a/test/testdata/fix/in/gci.go b/pkg/golinters/gci/testdata/fix/out/gci.go similarity index 86% rename from test/testdata/fix/in/gci.go rename to pkg/golinters/gci/testdata/fix/out/gci.go index 6fd16389f769..a45e13bc1193 100644 --- a/test/testdata/fix/in/gci.go +++ b/pkg/golinters/gci/testdata/fix/out/gci.go @@ -1,15 +1,15 @@ //golangcitest:args -Egci -//golangcitest:config_path testdata/configs/gci.yml +//golangcitest:config_path testdata/gci.yml //golangcitest:expected_exitcode 0 package gci import ( - "github.com/golangci/golangci-lint/pkg/config" - "golang.org/x/tools/go/analysis" - "fmt" gcicfg "github.com/daixiang0/gci/pkg/config" + "github.com/golangci/golangci-lint/pkg/config" + + "golang.org/x/tools/go/analysis" ) func GoimportsLocalTest() { diff --git a/test/testdata/gci.go b/pkg/golinters/gci/testdata/gci.go similarity index 92% rename from test/testdata/gci.go rename to pkg/golinters/gci/testdata/gci.go index cf0b7dea3693..4fa6c9e4b034 100644 --- a/test/testdata/gci.go +++ b/pkg/golinters/gci/testdata/gci.go @@ -1,5 +1,5 @@ //golangcitest:args -Egci -//golangcitest:config_path testdata/configs/gci.yml +//golangcitest:config_path testdata/gci.yml package testdata import ( diff --git a/test/testdata/configs/gci.yml b/pkg/golinters/gci/testdata/gci.yml similarity index 100% rename from test/testdata/configs/gci.yml rename to pkg/golinters/gci/testdata/gci.yml diff --git a/pkg/golinters/ginkgolinter.go b/pkg/golinters/ginkgolinter/ginkgolinter.go similarity index 93% rename from pkg/golinters/ginkgolinter.go rename to pkg/golinters/ginkgolinter/ginkgolinter.go index 182b001d51b3..54d20725701f 100644 --- a/pkg/golinters/ginkgolinter.go +++ b/pkg/golinters/ginkgolinter/ginkgolinter.go @@ -1,4 +1,4 @@ -package golinters +package ginkgolinter import ( "github.com/nunnatsa/ginkgolinter" @@ -9,7 +9,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewGinkgoLinter(settings *config.GinkgoLinterSettings) *goanalysis.Linter { +func New(settings *config.GinkgoLinterSettings) *goanalysis.Linter { cfg := &types.Config{} if settings != nil { diff --git a/pkg/golinters/ginkgolinter/ginkgolinter_integration_test.go b/pkg/golinters/ginkgolinter/ginkgolinter_integration_test.go new file mode 100644 index 000000000000..23fd75794469 --- /dev/null +++ b/pkg/golinters/ginkgolinter/ginkgolinter_integration_test.go @@ -0,0 +1,11 @@ +package ginkgolinter + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/ginkgolinter/ginkgolinter.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter.go similarity index 100% rename from test/testdata/ginkgolinter/ginkgolinter.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter.go diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_allow_havelen0.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_allow_havelen0.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_allow_havelen0.yml diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_default.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_default.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_default.yml diff --git a/test/testdata/ginkgolinter/ginkgolinter_havelen0.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_havelen0.go similarity index 98% rename from test/testdata/ginkgolinter/ginkgolinter_havelen0.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_havelen0.go index 0cc043456d81..ac91a708de66 100644 --- a/test/testdata/ginkgolinter/ginkgolinter_havelen0.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_havelen0.go @@ -1,4 +1,4 @@ -//golangcitest:config_path configs/ginkgolinter_allow_havelen0.yml +//golangcitest:config_path testdata/ginkgolinter_allow_havelen0.yml //golangcitest:args --disable-all -Eginkgolinter package ginkgolinter diff --git a/test/testdata/ginkgolinter/ginkgolinter_suppress_async.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.go similarity index 98% rename from test/testdata/ginkgolinter/ginkgolinter_suppress_async.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.go index ed6895276231..69531b7da300 100644 --- a/test/testdata/ginkgolinter/ginkgolinter_suppress_async.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.go @@ -1,4 +1,4 @@ -//golangcitest:config_path configs/ginkgolinter_suppress_async.yml +//golangcitest:config_path testdata/ginkgolinter_suppress_async.yml //golangcitest:args --disable-all -Eginkgolinter package ginkgolinter diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_suppress_async.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_suppress_async.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_async.yml diff --git a/test/testdata/ginkgolinter/ginkgolinter_suppress_compare.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.go similarity index 98% rename from test/testdata/ginkgolinter/ginkgolinter_suppress_compare.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.go index 4a3e8d953040..fdb02c782b37 100644 --- a/test/testdata/ginkgolinter/ginkgolinter_suppress_compare.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.go @@ -1,4 +1,4 @@ -//golangcitest:config_path configs/ginkgolinter_suppress_compare.yml +//golangcitest:config_path testdata/ginkgolinter_suppress_compare.yml //golangcitest:args --disable-all -Eginkgolinter package ginkgolinter diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_suppress_compare.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_suppress_compare.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_compare.yml diff --git a/test/testdata/ginkgolinter/ginkgolinter_suppress_err.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.go similarity index 98% rename from test/testdata/ginkgolinter/ginkgolinter_suppress_err.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.go index f74d1e5e2d8d..b24f20b83cb7 100644 --- a/test/testdata/ginkgolinter/ginkgolinter_suppress_err.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.go @@ -1,4 +1,4 @@ -//golangcitest:config_path configs/ginkgolinter_suppress_err.yml +//golangcitest:config_path testdata/ginkgolinter_suppress_err.yml //golangcitest:args --disable-all -Eginkgolinter package ginkgolinter diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_suppress_err.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_suppress_err.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_err.yml diff --git a/test/testdata/ginkgolinter/ginkgolinter_suppress_focused_containers.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.go similarity index 98% rename from test/testdata/ginkgolinter/ginkgolinter_suppress_focused_containers.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.go index eeae3aa54e04..ff4fd05797a2 100644 --- a/test/testdata/ginkgolinter/ginkgolinter_suppress_focused_containers.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.go @@ -1,5 +1,5 @@ //golangcitest:args --disable-all -Eginkgolinter -//golangcitest:config_path configs/ginkgolinter_suppress_focused_containers.yml +//golangcitest:config_path testdata/ginkgolinter_suppress_focused_containers.yml package ginkgolinter import ( diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_suppress_focused_containers.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_suppress_focused_containers.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_focused_containers.yml diff --git a/test/testdata/ginkgolinter/ginkgolinter_suppress_len.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.go similarity index 98% rename from test/testdata/ginkgolinter/ginkgolinter_suppress_len.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.go index 6d9ce85b45a8..ad8d8fdba3e2 100644 --- a/test/testdata/ginkgolinter/ginkgolinter_suppress_len.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.go @@ -1,4 +1,4 @@ -//golangcitest:config_path configs/ginkgolinter_suppress_len.yml +//golangcitest:config_path testdata/ginkgolinter_suppress_len.yml //golangcitest:args --disable-all -Eginkgolinter package ginkgolinter diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_suppress_len.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_suppress_len.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_len.yml diff --git a/test/testdata/ginkgolinter/ginkgolinter_suppress_nil.go b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.go similarity index 98% rename from test/testdata/ginkgolinter/ginkgolinter_suppress_nil.go rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.go index ea4454e38344..44b59f301ff8 100644 --- a/test/testdata/ginkgolinter/ginkgolinter_suppress_nil.go +++ b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.go @@ -1,5 +1,5 @@ //golangcitest:args --disable-all -Eginkgolinter -//golangcitest:config_path configs/ginkgolinter_suppress_nil.yml +//golangcitest:config_path testdata/ginkgolinter_suppress_nil.yml package ginkgolinter import ( diff --git a/test/testdata/ginkgolinter/configs/ginkgolinter_suppress_nil.yml b/pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml similarity index 100% rename from test/testdata/ginkgolinter/configs/ginkgolinter_suppress_nil.yml rename to pkg/golinters/ginkgolinter/testdata/ginkgolinter_suppress_nil.yml diff --git a/test/testdata/ginkgolinter/go.mod b/pkg/golinters/ginkgolinter/testdata/go.mod similarity index 100% rename from test/testdata/ginkgolinter/go.mod rename to pkg/golinters/ginkgolinter/testdata/go.mod diff --git a/test/testdata/ginkgolinter/go.sum b/pkg/golinters/ginkgolinter/testdata/go.sum similarity index 100% rename from test/testdata/ginkgolinter/go.sum rename to pkg/golinters/ginkgolinter/testdata/go.sum diff --git a/pkg/golinters/gocheckcompilerdirectives.go b/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go similarity index 81% rename from pkg/golinters/gocheckcompilerdirectives.go rename to pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go index d2e302a285a0..be604d805b4b 100644 --- a/pkg/golinters/gocheckcompilerdirectives.go +++ b/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives.go @@ -1,4 +1,4 @@ -package golinters +package gocheckcompilerdirectives import ( "4d63.com/gocheckcompilerdirectives/checkcompilerdirectives" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewGoCheckCompilerDirectives() *goanalysis.Linter { +func New() *goanalysis.Linter { a := checkcompilerdirectives.Analyzer() return goanalysis.NewLinter( diff --git a/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives_integration_test.go b/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives_integration_test.go new file mode 100644 index 000000000000..bc441dcc3bb3 --- /dev/null +++ b/pkg/golinters/gocheckcompilerdirectives/gocheckcompilerdirectives_integration_test.go @@ -0,0 +1,11 @@ +package gocheckcompilerdirectives + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gocheckcompilerdirectives.go b/pkg/golinters/gocheckcompilerdirectives/testdata/gocheckcompilerdirectives.go similarity index 100% rename from test/testdata/gocheckcompilerdirectives.go rename to pkg/golinters/gocheckcompilerdirectives/testdata/gocheckcompilerdirectives.go diff --git a/pkg/golinters/gochecknoglobals.go b/pkg/golinters/gochecknoglobals/gochecknoglobals.go similarity index 91% rename from pkg/golinters/gochecknoglobals.go rename to pkg/golinters/gochecknoglobals/gochecknoglobals.go index a35876d995af..af22b2f8e964 100644 --- a/pkg/golinters/gochecknoglobals.go +++ b/pkg/golinters/gochecknoglobals/gochecknoglobals.go @@ -1,4 +1,4 @@ -package golinters +package gochecknoglobals import ( "4d63.com/gochecknoglobals/checknoglobals" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewGochecknoglobals() *goanalysis.Linter { +func New() *goanalysis.Linter { a := checknoglobals.Analyzer() // gochecknoglobals only lints test files if the `-t` flag is passed, diff --git a/pkg/golinters/gochecknoglobals/gochecknoglobals_integration_test.go b/pkg/golinters/gochecknoglobals/gochecknoglobals_integration_test.go new file mode 100644 index 000000000000..98aa5bbdf172 --- /dev/null +++ b/pkg/golinters/gochecknoglobals/gochecknoglobals_integration_test.go @@ -0,0 +1,11 @@ +package gochecknoglobals + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gochecknoglobals.go b/pkg/golinters/gochecknoglobals/testdata/gochecknoglobals.go similarity index 100% rename from test/testdata/gochecknoglobals.go rename to pkg/golinters/gochecknoglobals/testdata/gochecknoglobals.go diff --git a/pkg/golinters/gochecknoinits.go b/pkg/golinters/gochecknoinits/gochecknoinits.go similarity index 89% rename from pkg/golinters/gochecknoinits.go rename to pkg/golinters/gochecknoinits/gochecknoinits.go index 28f025943156..9bce275577a8 100644 --- a/pkg/golinters/gochecknoinits.go +++ b/pkg/golinters/gochecknoinits/gochecknoinits.go @@ -1,4 +1,4 @@ -package golinters +package gochecknoinits import ( "fmt" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const gochecknoinitsName = "gochecknoinits" +const name = "gochecknoinits" -func NewGochecknoinits() *goanalysis.Linter { +func New() *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: gochecknoinitsName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { var res []goanalysis.Issue @@ -44,7 +44,7 @@ func NewGochecknoinits() *goanalysis.Linter { } return goanalysis.NewLinter( - gochecknoinitsName, + name, "Checks that no init functions are present in Go code", []*analysis.Analyzer{analyzer}, nil, @@ -66,7 +66,7 @@ func checkFileForInits(f *ast.File, fset *token.FileSet) []result.Issue { res = append(res, result.Issue{ Pos: fset.Position(funcDecl.Pos()), Text: fmt.Sprintf("don't use %s function", internal.FormatCode(name, nil)), - FromLinter: gochecknoinitsName, + FromLinter: name, }) } } diff --git a/pkg/golinters/gochecknoinits/gochecknoinits_integration_test.go b/pkg/golinters/gochecknoinits/gochecknoinits_integration_test.go new file mode 100644 index 000000000000..0a819b96af86 --- /dev/null +++ b/pkg/golinters/gochecknoinits/gochecknoinits_integration_test.go @@ -0,0 +1,11 @@ +package gochecknoinits + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gochecknoinits.go b/pkg/golinters/gochecknoinits/testdata/gochecknoinits.go similarity index 100% rename from test/testdata/gochecknoinits.go rename to pkg/golinters/gochecknoinits/testdata/gochecknoinits.go diff --git a/pkg/golinters/gochecksumtype.go b/pkg/golinters/gochecksumtype/gochecksumtype.go similarity index 89% rename from pkg/golinters/gochecksumtype.go rename to pkg/golinters/gochecksumtype/gochecksumtype.go index a022abae9709..2ce3b4c8fa52 100644 --- a/pkg/golinters/gochecksumtype.go +++ b/pkg/golinters/gochecksumtype/gochecksumtype.go @@ -1,4 +1,4 @@ -package golinters +package gochecksumtype import ( "strings" @@ -13,14 +13,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const goCheckSumTypeName = "gochecksumtype" +const name = "gochecksumtype" -func NewGoCheckSumType() *goanalysis.Linter { +func New() *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: goCheckSumTypeName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runGoCheckSumType(pass) @@ -41,7 +41,7 @@ func NewGoCheckSumType() *goanalysis.Linter { } return goanalysis.NewLinter( - goCheckSumTypeName, + name, `Run exhaustiveness checks on Go "sum types"`, []*analysis.Analyzer{analyzer}, nil, @@ -70,7 +70,7 @@ func runGoCheckSumType(pass *analysis.Pass) ([]goanalysis.Issue, error) { } resIssues = append(resIssues, goanalysis.NewIssue(&result.Issue{ - FromLinter: goCheckSumTypeName, + FromLinter: name, Text: strings.TrimPrefix(err.Error(), err.Pos().String()+": "), Pos: err.Pos(), }, pass)) diff --git a/pkg/golinters/gochecksumtype/gochecksumtype_integration_test.go b/pkg/golinters/gochecksumtype/gochecksumtype_integration_test.go new file mode 100644 index 000000000000..bc78a3bf64e1 --- /dev/null +++ b/pkg/golinters/gochecksumtype/gochecksumtype_integration_test.go @@ -0,0 +1,11 @@ +package gochecksumtype + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gochecksumtype.go b/pkg/golinters/gochecksumtype/testdata/gochecksumtype.go similarity index 100% rename from test/testdata/gochecksumtype.go rename to pkg/golinters/gochecksumtype/testdata/gochecksumtype.go diff --git a/pkg/golinters/gocognit.go b/pkg/golinters/gocognit/gocognit.go similarity index 91% rename from pkg/golinters/gocognit.go rename to pkg/golinters/gocognit/gocognit.go index 00cd26b091d0..d23c60795067 100644 --- a/pkg/golinters/gocognit.go +++ b/pkg/golinters/gocognit/gocognit.go @@ -1,4 +1,4 @@ -package golinters +package gocognit import ( "fmt" @@ -15,9 +15,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const gocognitName = "gocognit" +const name = "gocognit" -func NewGocognit(settings *config.GocognitSettings) *goanalysis.Linter { +func New(settings *config.GocognitSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -40,7 +40,7 @@ func NewGocognit(settings *config.GocognitSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - gocognitName, + name, "Computes and checks the cognitive complexity of functions", []*analysis.Analyzer{analyzer}, nil, @@ -72,7 +72,7 @@ func runGocognit(pass *analysis.Pass, settings *config.GocognitSettings) []goana Pos: s.Pos, Text: fmt.Sprintf("cognitive complexity %d of func %s is high (> %d)", s.Complexity, internal.FormatCode(s.FuncName, nil), settings.MinComplexity), - FromLinter: gocognitName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/gocognit/gocognit_integration_test.go b/pkg/golinters/gocognit/gocognit_integration_test.go new file mode 100644 index 000000000000..6786f500d72f --- /dev/null +++ b/pkg/golinters/gocognit/gocognit_integration_test.go @@ -0,0 +1,11 @@ +package gocognit + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gocognit.go b/pkg/golinters/gocognit/testdata/gocognit.go similarity index 95% rename from test/testdata/gocognit.go rename to pkg/golinters/gocognit/testdata/gocognit.go index 454c39d95ea7..1ea290329f1d 100644 --- a/test/testdata/gocognit.go +++ b/pkg/golinters/gocognit/testdata/gocognit.go @@ -1,5 +1,5 @@ //golangcitest:args -Egocognit -//golangcitest:config_path testdata/configs/gocognit.yml +//golangcitest:config_path testdata/gocognit.yml package testdata func GoCognit_CC4_GetWords(number int) string { // want "cognitive complexity 4 of func .* is high .*" diff --git a/test/testdata/configs/gocognit.yml b/pkg/golinters/gocognit/testdata/gocognit.yml similarity index 100% rename from test/testdata/configs/gocognit.yml rename to pkg/golinters/gocognit/testdata/gocognit.yml diff --git a/pkg/golinters/goconst.go b/pkg/golinters/goconst/goconst.go similarity index 92% rename from pkg/golinters/goconst.go rename to pkg/golinters/goconst/goconst.go index 553f6be9741a..de52ba054718 100644 --- a/pkg/golinters/goconst.go +++ b/pkg/golinters/goconst/goconst.go @@ -1,4 +1,4 @@ -package golinters +package goconst import ( "fmt" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const goconstName = "goconst" +const name = "goconst" -func NewGoconst(settings *config.GoConstSettings) *goanalysis.Linter { +func New(settings *config.GoConstSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: goconstName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runGoconst(pass, settings) @@ -42,7 +42,7 @@ func NewGoconst(settings *config.GoConstSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - goconstName, + name, "Finds repeated strings that could be replaced by a constant", []*analysis.Analyzer{analyzer}, nil, @@ -90,7 +90,7 @@ func runGoconst(pass *analysis.Pass, settings *config.GoConstSettings) ([]goanal res = append(res, goanalysis.NewIssue(&result.Issue{ Pos: i.Pos, Text: text, - FromLinter: goconstName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/goconst/goconst_integration_test.go b/pkg/golinters/goconst/goconst_integration_test.go new file mode 100644 index 000000000000..d115170dcb78 --- /dev/null +++ b/pkg/golinters/goconst/goconst_integration_test.go @@ -0,0 +1,11 @@ +package goconst + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/goconst.go b/pkg/golinters/goconst/testdata/goconst.go similarity index 100% rename from test/testdata/goconst.go rename to pkg/golinters/goconst/testdata/goconst.go diff --git a/test/testdata/goconst_calls_enabled.go b/pkg/golinters/goconst/testdata/goconst_calls_enabled.go similarity index 80% rename from test/testdata/goconst_calls_enabled.go rename to pkg/golinters/goconst/testdata/goconst_calls_enabled.go index ea2a85f3ddb6..1e326c5052d3 100644 --- a/test/testdata/goconst_calls_enabled.go +++ b/pkg/golinters/goconst/testdata/goconst_calls_enabled.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoconst -//golangcitest:config_path testdata/configs/goconst_calls_enabled.yml +//golangcitest:config_path testdata/goconst_calls_enabled.yml package testdata import "fmt" diff --git a/test/testdata/configs/goconst_calls_enabled.yml b/pkg/golinters/goconst/testdata/goconst_calls_enabled.yml similarity index 100% rename from test/testdata/configs/goconst_calls_enabled.yml rename to pkg/golinters/goconst/testdata/goconst_calls_enabled.yml diff --git a/test/testdata/configs/goconst_dont_ignore.yml b/pkg/golinters/goconst/testdata/goconst_dont_ignore.yml similarity index 100% rename from test/testdata/configs/goconst_dont_ignore.yml rename to pkg/golinters/goconst/testdata/goconst_dont_ignore.yml diff --git a/test/testdata/goconst_dont_ignore_test.go b/pkg/golinters/goconst/testdata/goconst_dont_ignore_test.go similarity index 91% rename from test/testdata/goconst_dont_ignore_test.go rename to pkg/golinters/goconst/testdata/goconst_dont_ignore_test.go index 333e67feff15..5c31cce3741c 100644 --- a/test/testdata/goconst_dont_ignore_test.go +++ b/pkg/golinters/goconst/testdata/goconst_dont_ignore_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoconst -//golangcitest:config_path testdata/configs/goconst_dont_ignore.yml +//golangcitest:config_path testdata/goconst_dont_ignore.yml package testdata import ( diff --git a/test/testdata/configs/goconst_ignore.yml b/pkg/golinters/goconst/testdata/goconst_ignore.yml similarity index 100% rename from test/testdata/configs/goconst_ignore.yml rename to pkg/golinters/goconst/testdata/goconst_ignore.yml diff --git a/test/testdata/goconst_ignore_test.go b/pkg/golinters/goconst/testdata/goconst_ignore_test.go similarity index 90% rename from test/testdata/goconst_ignore_test.go rename to pkg/golinters/goconst/testdata/goconst_ignore_test.go index bc538bf11e0d..549e9cc7b868 100644 --- a/test/testdata/goconst_ignore_test.go +++ b/pkg/golinters/goconst/testdata/goconst_ignore_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoconst -//golangcitest:config_path testdata/configs/goconst_ignore.yml +//golangcitest:config_path testdata/goconst_ignore.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/pkg/golinters/gocritic.go b/pkg/golinters/gocritic/gocritic.go similarity index 81% rename from pkg/golinters/gocritic.go rename to pkg/golinters/gocritic/gocritic.go index 5f5d34393a6a..837f517ff967 100644 --- a/pkg/golinters/gocritic.go +++ b/pkg/golinters/gocritic/gocritic.go @@ -1,4 +1,4 @@ -package golinters +package gocritic import ( "errors" @@ -14,6 +14,7 @@ import ( "github.com/go-critic/go-critic/checkers" gocriticlinter "github.com/go-critic/go-critic/linter" + _ "github.com/quasilyte/go-ruleguard/dsl" "golang.org/x/exp/maps" "golang.org/x/exp/slices" "golang.org/x/tools/go/analysis" @@ -25,14 +26,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const goCriticName = "gocritic" +const name = "gocritic" var ( - goCriticDebugf = logutils.Debug(logutils.DebugKeyGoCritic) - isGoCriticDebug = logutils.HaveDebugTag(logutils.DebugKeyGoCritic) + debugf = logutils.Debug(logutils.DebugKeyGoCritic) + isDebug = logutils.HaveDebugTag(logutils.DebugKeyGoCritic) ) -func NewGoCritic(settings *config.GoCriticSettings) *goanalysis.Linter { +func New(settings *config.GoCriticSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -41,7 +42,7 @@ func NewGoCritic(settings *config.GoCriticSettings) *goanalysis.Linter { } analyzer := &analysis.Analyzer{ - Name: goCriticName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := wrapper.run(pass) @@ -62,7 +63,7 @@ func NewGoCritic(settings *config.GoCriticSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - goCriticName, + name, `Provides diagnostics that check for bugs, performance and style issues. Extensible without recompilation through dynamic rules. Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`, @@ -81,7 +82,7 @@ Dynamic rules are written declaratively with AST patterns, filters, report messa } type goCriticWrapper struct { - settingsWrapper *goCriticSettingsWrapper + settingsWrapper *settingsWrapper configDir string sizes types.Sizes once sync.Once @@ -95,16 +96,16 @@ func (w *goCriticWrapper) init(logger logutils.Log, settings *config.GoCriticSet w.once.Do(func() { err := checkers.InitEmbeddedRules() if err != nil { - logger.Fatalf("%s: %v: setting an explicit GOROOT can fix this problem", goCriticName, err) + logger.Fatalf("%s: %v: setting an explicit GOROOT can fix this problem", name, err) } }) - settingsWrapper := newGoCriticSettingsWrapper(settings, logger) + settingsWrapper := newSettingsWrapper(settings, logger) settingsWrapper.InferEnabledChecks() // Validate must be after InferEnabledChecks, not before. // Because it uses gathered information about tags set and finally enabled checks. if err := settingsWrapper.Validate(); err != nil { - logger.Fatalf("%s: invalid settings: %s", goCriticName, err) + logger.Fatalf("%s: invalid settings: %s", name, err) } w.settingsWrapper = settingsWrapper @@ -126,7 +127,7 @@ func (w *goCriticWrapper) run(pass *analysis.Pass) ([]goanalysis.Issue, error) { linterCtx.SetPackageInfo(pass.TypesInfo, pass.Pkg) - pkgIssues := runGoCriticOnPackage(linterCtx, enabledCheckers, pass.Files) + pkgIssues := runOnPackage(linterCtx, enabledCheckers, pass.Files) issues := make([]goanalysis.Issue, 0, len(pkgIssues)) for i := range pkgIssues { @@ -213,19 +214,19 @@ func (w *goCriticWrapper) normalizeCheckerParamsValue(p any) any { } } -func runGoCriticOnPackage(linterCtx *gocriticlinter.Context, checks []*gocriticlinter.Checker, files []*ast.File) []result.Issue { +func runOnPackage(linterCtx *gocriticlinter.Context, checks []*gocriticlinter.Checker, files []*ast.File) []result.Issue { var res []result.Issue for _, f := range files { filename := filepath.Base(linterCtx.FileSet.Position(f.Pos()).Filename) linterCtx.SetFileInfo(filename, f) - issues := runGoCriticOnFile(linterCtx, f, checks) + issues := runOnFile(linterCtx, f, checks) res = append(res, issues...) } return res } -func runGoCriticOnFile(linterCtx *gocriticlinter.Context, f *ast.File, checks []*gocriticlinter.Checker) []result.Issue { +func runOnFile(linterCtx *gocriticlinter.Context, f *ast.File, checks []*gocriticlinter.Checker) []result.Issue { var res []result.Issue for _, c := range checks { @@ -236,7 +237,7 @@ func runGoCriticOnFile(linterCtx *gocriticlinter.Context, f *ast.File, checks [] issue := result.Issue{ Pos: pos, Text: fmt.Sprintf("%s: %s", c.Info.Name, warn.Text), - FromLinter: goCriticName, + FromLinter: name, } if warn.HasQuickFix() { @@ -263,7 +264,7 @@ func (m goCriticChecks[T]) has(name string) bool { return ok } -type goCriticSettingsWrapper struct { +type settingsWrapper struct { *config.GoCriticSettings logger logutils.Log @@ -281,7 +282,7 @@ type goCriticSettingsWrapper struct { inferredEnabledChecksLowerCased goCriticChecks[struct{}] } -func newGoCriticSettingsWrapper(settings *config.GoCriticSettings, logger logutils.Log) *goCriticSettingsWrapper { +func newSettingsWrapper(settings *config.GoCriticSettings, logger logutils.Log) *settingsWrapper { allCheckers := gocriticlinter.GetCheckersInfo() allChecks := make(goCriticChecks[struct{}], len(allCheckers)) @@ -299,7 +300,7 @@ func newGoCriticSettingsWrapper(settings *config.GoCriticSettings, logger loguti allTagsSorted := maps.Keys(allChecksByTag) sort.Strings(allTagsSorted) - return &goCriticSettingsWrapper{ + return &settingsWrapper{ GoCriticSettings: settings, logger: logger, allCheckers: allCheckers, @@ -312,16 +313,16 @@ func newGoCriticSettingsWrapper(settings *config.GoCriticSettings, logger loguti } } -func (s *goCriticSettingsWrapper) IsCheckEnabled(name string) bool { +func (s *settingsWrapper) IsCheckEnabled(name string) bool { return s.inferredEnabledChecks.has(name) } -func (s *goCriticSettingsWrapper) GetLowerCasedParams() map[string]config.GoCriticCheckSettings { +func (s *settingsWrapper) GetLowerCasedParams() map[string]config.GoCriticCheckSettings { return normalizeMap(s.SettingsPerCheck) } -// InferEnabledChecks tries to be consistent with (lintersdb.EnabledSet).build. -func (s *goCriticSettingsWrapper) InferEnabledChecks() { +// InferEnabledChecks tries to be consistent with (lintersdb.Manager).build. +func (s *settingsWrapper) InferEnabledChecks() { s.debugChecksInitialState() enabledByDefaultChecks, disabledByDefaultChecks := s.buildEnabledAndDisabledByDefaultChecks() @@ -357,7 +358,7 @@ func (s *goCriticSettingsWrapper) InferEnabledChecks() { for _, check := range s.EnabledChecks { if enabledChecks.has(check) { - s.logger.Warnf("%s: no need to enable check %q: it's already enabled", goCriticName, check) + s.logger.Warnf("%s: no need to enable check %q: it's already enabled", name, check) continue } enabledChecks[check] = struct{}{} @@ -378,7 +379,7 @@ func (s *goCriticSettingsWrapper) InferEnabledChecks() { for _, check := range s.DisabledChecks { if !enabledChecks.has(check) { - s.logger.Warnf("%s: no need to disable check %q: it's already disabled", goCriticName, check) + s.logger.Warnf("%s: no need to disable check %q: it's already disabled", name, check) continue } delete(enabledChecks, check) @@ -390,7 +391,7 @@ func (s *goCriticSettingsWrapper) InferEnabledChecks() { s.debugChecksFinalState() } -func (s *goCriticSettingsWrapper) buildEnabledAndDisabledByDefaultChecks() (enabled, disabled []string) { +func (s *settingsWrapper) buildEnabledAndDisabledByDefaultChecks() (enabled, disabled []string) { for _, info := range s.allCheckers { if enabledByDef := isEnabledByDefaultGoCriticChecker(info); enabledByDef { enabled = append(enabled, info.Name) @@ -401,7 +402,7 @@ func (s *goCriticSettingsWrapper) buildEnabledAndDisabledByDefaultChecks() (enab return enabled, disabled } -func (s *goCriticSettingsWrapper) expandTagsToChecks(tags []string) []string { +func (s *settingsWrapper) expandTagsToChecks(tags []string) []string { var checks []string for _, tag := range tags { checks = append(checks, s.allChecksByTag[tag]...) @@ -409,19 +410,19 @@ func (s *goCriticSettingsWrapper) expandTagsToChecks(tags []string) []string { return checks } -func (s *goCriticSettingsWrapper) debugChecksInitialState() { - if !isGoCriticDebug { +func (s *settingsWrapper) debugChecksInitialState() { + if !isDebug { return } - goCriticDebugf("All gocritic existing tags and checks:") + debugf("All gocritic existing tags and checks:") for _, tag := range s.allTagsSorted { debugChecksListf(s.allChecksByTag[tag], " tag %q", tag) } } -func (s *goCriticSettingsWrapper) debugChecksFinalState() { - if !isGoCriticDebug { +func (s *settingsWrapper) debugChecksFinalState() { + if !isDebug { return } @@ -429,25 +430,25 @@ func (s *goCriticSettingsWrapper) debugChecksFinalState() { var disabledChecks []string for _, checker := range s.allCheckers { - name := checker.Name - if s.inferredEnabledChecks.has(name) { - enabledChecks = append(enabledChecks, name) + check := checker.Name + if s.inferredEnabledChecks.has(check) { + enabledChecks = append(enabledChecks, check) } else { - disabledChecks = append(disabledChecks, name) + disabledChecks = append(disabledChecks, check) } } debugChecksListf(enabledChecks, "Final used") if len(disabledChecks) == 0 { - goCriticDebugf("All checks are enabled") + debugf("All checks are enabled") } else { debugChecksListf(disabledChecks, "Final not used") } } // Validate tries to be consistent with (lintersdb.Validator).validateEnabledDisabledLintersConfig. -func (s *goCriticSettingsWrapper) Validate() error { +func (s *settingsWrapper) Validate() error { for _, v := range []func() error{ s.validateOptionsCombinations, s.validateCheckerTags, @@ -462,7 +463,7 @@ func (s *goCriticSettingsWrapper) Validate() error { return nil } -func (s *goCriticSettingsWrapper) validateOptionsCombinations() error { +func (s *settingsWrapper) validateOptionsCombinations() error { if s.EnableAll { if s.DisableAll { return errors.New("enable-all and disable-all options must not be combined") @@ -494,49 +495,49 @@ func (s *goCriticSettingsWrapper) validateOptionsCombinations() error { return nil } -func (s *goCriticSettingsWrapper) validateCheckerTags() error { +func (s *settingsWrapper) validateCheckerTags() error { for _, tag := range s.EnabledTags { if !s.allChecksByTag.has(tag) { - return fmt.Errorf("enabled tag %q doesn't exist, see %s's documentation", tag, goCriticName) + return fmt.Errorf("enabled tag %q doesn't exist, see %s's documentation", tag, name) } } for _, tag := range s.DisabledTags { if !s.allChecksByTag.has(tag) { - return fmt.Errorf("disabled tag %q doesn't exist, see %s's documentation", tag, goCriticName) + return fmt.Errorf("disabled tag %q doesn't exist, see %s's documentation", tag, name) } } return nil } -func (s *goCriticSettingsWrapper) validateCheckerNames() error { - for _, name := range s.EnabledChecks { - if !s.allChecks.has(name) { - return fmt.Errorf("enabled check %q doesn't exist, see %s's documentation", name, goCriticName) +func (s *settingsWrapper) validateCheckerNames() error { + for _, check := range s.EnabledChecks { + if !s.allChecks.has(check) { + return fmt.Errorf("enabled check %q doesn't exist, see %s's documentation", check, name) } } - for _, name := range s.DisabledChecks { - if !s.allChecks.has(name) { - return fmt.Errorf("disabled check %q doesn't exist, see %s documentation", name, goCriticName) + for _, check := range s.DisabledChecks { + if !s.allChecks.has(check) { + return fmt.Errorf("disabled check %q doesn't exist, see %s documentation", check, name) } } - for name := range s.SettingsPerCheck { - lcName := strings.ToLower(name) + for check := range s.SettingsPerCheck { + lcName := strings.ToLower(check) if !s.allChecksLowerCased.has(lcName) { - return fmt.Errorf("invalid check settings: check %q doesn't exist, see %s documentation", name, goCriticName) + return fmt.Errorf("invalid check settings: check %q doesn't exist, see %s documentation", check, name) } if !s.inferredEnabledChecksLowerCased.has(lcName) { - s.logger.Warnf("%s: settings were provided for disabled check %q", goCriticName, name) + s.logger.Warnf("%s: settings were provided for disabled check %q", check, name) } } return nil } -func (s *goCriticSettingsWrapper) validateDisabledAndEnabledAtOneMoment() error { +func (s *settingsWrapper) validateDisabledAndEnabledAtOneMoment() error { for _, tag := range s.DisabledTags { if slices.Contains(s.EnabledTags, tag) { return fmt.Errorf("tag %q disabled and enabled at one moment", tag) @@ -552,7 +553,7 @@ func (s *goCriticSettingsWrapper) validateDisabledAndEnabledAtOneMoment() error return nil } -func (s *goCriticSettingsWrapper) validateAtLeastOneCheckerEnabled() error { +func (s *settingsWrapper) validateAtLeastOneCheckerEnabled() error { if len(s.inferredEnabledChecks) == 0 { return errors.New("eventually all checks were disabled: at least one must be enabled") } @@ -576,11 +577,11 @@ func isEnabledByDefaultGoCriticChecker(info *gocriticlinter.CheckerInfo) bool { } func debugChecksListf(checks []string, format string, args ...any) { - if !isGoCriticDebug { + if !isDebug { return } - goCriticDebugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), sprintSortedStrings(checks)) + debugf("%s checks (%d): %s", fmt.Sprintf(format, args...), len(checks), sprintSortedStrings(checks)) } func sprintSortedStrings(v []string) string { diff --git a/pkg/golinters/gocritic/gocritic_integration_test.go b/pkg/golinters/gocritic/gocritic_integration_test.go new file mode 100644 index 000000000000..f029679ddb6a --- /dev/null +++ b/pkg/golinters/gocritic/gocritic_integration_test.go @@ -0,0 +1,19 @@ +package gocritic + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/pkg/golinters/gocritic_test.go b/pkg/golinters/gocritic/gocritic_test.go similarity index 98% rename from pkg/golinters/gocritic_test.go rename to pkg/golinters/gocritic/gocritic_test.go index 957b34b695da..2a8d6088ead0 100644 --- a/pkg/golinters/gocritic_test.go +++ b/pkg/golinters/gocritic/gocritic_test.go @@ -1,4 +1,4 @@ -package golinters +package gocritic import ( "strings" @@ -16,7 +16,7 @@ import ( ) // https://go-critic.com/overview.html -func Test_goCriticSettingsWrapper_InferEnabledChecks(t *testing.T) { +func Test_settingsWrapper_InferEnabledChecks(t *testing.T) { err := checkers.InitEmbeddedRules() require.NoError(t, err) @@ -267,7 +267,7 @@ func Test_goCriticSettingsWrapper_InferEnabledChecks(t *testing.T) { t.Parallel() lg := logutils.NewStderrLog("Test_goCriticSettingsWrapper_InferEnabledChecks") - wr := newGoCriticSettingsWrapper(tt.sett, lg) + wr := newSettingsWrapper(tt.sett, lg) wr.InferEnabledChecks() assert.ElementsMatch(t, tt.expectedEnabledChecks, maps.Keys(wr.inferredEnabledChecks)) @@ -276,7 +276,7 @@ func Test_goCriticSettingsWrapper_InferEnabledChecks(t *testing.T) { } } -func Test_goCriticSettingsWrapper_Validate(t *testing.T) { +func Test_settingsWrapper_Validate(t *testing.T) { cases := []struct { name string sett *config.GoCriticSettings @@ -439,7 +439,7 @@ func Test_goCriticSettingsWrapper_Validate(t *testing.T) { t.Parallel() lg := logutils.NewStderrLog("Test_goCriticSettingsWrapper_Validate") - wr := newGoCriticSettingsWrapper(tt.sett, lg) + wr := newSettingsWrapper(tt.sett, lg) wr.InferEnabledChecks() diff --git a/test/testdata/fix/in/gocritic.go b/pkg/golinters/gocritic/testdata/fix/in/gocritic.go similarity index 84% rename from test/testdata/fix/in/gocritic.go rename to pkg/golinters/gocritic/testdata/fix/in/gocritic.go index a4a4fcfd6420..40e058460d9b 100644 --- a/test/testdata/fix/in/gocritic.go +++ b/pkg/golinters/gocritic/testdata/fix/in/gocritic.go @@ -1,5 +1,5 @@ //golangcitest:args -Egocritic -//golangcitest:config_path testdata/configs/gocritic-fix.yml +//golangcitest:config_path testdata/gocritic-fix.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/fix/out/gocritic.go b/pkg/golinters/gocritic/testdata/fix/out/gocritic.go similarity index 84% rename from test/testdata/fix/out/gocritic.go rename to pkg/golinters/gocritic/testdata/fix/out/gocritic.go index 93005ab4a253..9be16c950361 100644 --- a/test/testdata/fix/out/gocritic.go +++ b/pkg/golinters/gocritic/testdata/fix/out/gocritic.go @@ -1,5 +1,5 @@ //golangcitest:args -Egocritic -//golangcitest:config_path testdata/configs/gocritic-fix.yml +//golangcitest:config_path testdata/gocritic-fix.yml //golangcitest:expected_exitcode 0 package p diff --git a/pkg/golinters/gocritic/testdata/gocritic-fix.yml b/pkg/golinters/gocritic/testdata/gocritic-fix.yml new file mode 100644 index 000000000000..c9f662b13a07 --- /dev/null +++ b/pkg/golinters/gocritic/testdata/gocritic-fix.yml @@ -0,0 +1,8 @@ +linters-settings: + gocritic: + enabled-checks: + - ruleguard + settings: + ruleguard: + failOn: dsl,import + rules: '${configDir}/ruleguard/rangeExprCopy.go,${configDir}/ruleguard/stringsSimplify.go' diff --git a/test/testdata/gocritic.go b/pkg/golinters/gocritic/testdata/gocritic.go similarity index 96% rename from test/testdata/gocritic.go rename to pkg/golinters/gocritic/testdata/gocritic.go index a87a193d075f..94171fb1293c 100644 --- a/test/testdata/gocritic.go +++ b/pkg/golinters/gocritic/testdata/gocritic.go @@ -1,5 +1,5 @@ //golangcitest:args -Egocritic -//golangcitest:config_path testdata/configs/gocritic.yml +//golangcitest:config_path testdata/gocritic.yml package testdata import ( diff --git a/test/testdata/configs/gocritic.yml b/pkg/golinters/gocritic/testdata/gocritic.yml similarity index 86% rename from test/testdata/configs/gocritic.yml rename to pkg/golinters/gocritic/testdata/gocritic.yml index d424cb1798b3..aa3a7a95fe89 100644 --- a/test/testdata/configs/gocritic.yml +++ b/pkg/golinters/gocritic/testdata/gocritic.yml @@ -17,4 +17,4 @@ linters-settings: # The ruleguard files used in functional tests cannot be under the 'testdata' directory. # This is because they import the 'github.com/quasilyte/go-ruleguard/dsl' package, # which needs to be added to go.mod. The testdata directory is ignored by go mod. - rules: '${configDir}/../../ruleguard/preferWriteString.go,${configDir}/../../ruleguard/stringsSimplify.go' + rules: '${configDir}/ruleguard/preferWriteString.go,${configDir}/ruleguard/stringsSimplify.go' diff --git a/test/ruleguard/README.md b/pkg/golinters/gocritic/testdata/ruleguard/README.md similarity index 66% rename from test/ruleguard/README.md rename to pkg/golinters/gocritic/testdata/ruleguard/README.md index 35797144a3ee..0a6b5459081f 100644 --- a/test/ruleguard/README.md +++ b/pkg/golinters/gocritic/testdata/ruleguard/README.md @@ -1,12 +1,4 @@ -This directory contains ruleguard files that are used in functional tests: - -```bash -T=gocritic.go make test_linters -``` - -```bash -T=gocritic.go make test_fix -``` +This directory contains ruleguard files that are used in functional tests. Helpful: diff --git a/test/ruleguard/preferWriteString.go b/pkg/golinters/gocritic/testdata/ruleguard/preferWriteString.go similarity index 100% rename from test/ruleguard/preferWriteString.go rename to pkg/golinters/gocritic/testdata/ruleguard/preferWriteString.go diff --git a/test/ruleguard/rangeExprCopy.go b/pkg/golinters/gocritic/testdata/ruleguard/rangeExprCopy.go similarity index 100% rename from test/ruleguard/rangeExprCopy.go rename to pkg/golinters/gocritic/testdata/ruleguard/rangeExprCopy.go diff --git a/test/ruleguard/stringsSimplify.go b/pkg/golinters/gocritic/testdata/ruleguard/stringsSimplify.go similarity index 100% rename from test/ruleguard/stringsSimplify.go rename to pkg/golinters/gocritic/testdata/ruleguard/stringsSimplify.go diff --git a/pkg/golinters/gocyclo.go b/pkg/golinters/gocyclo/gocyclo.go similarity index 90% rename from pkg/golinters/gocyclo.go rename to pkg/golinters/gocyclo/gocyclo.go index cbf05fff0ce4..385a141d6d64 100644 --- a/pkg/golinters/gocyclo.go +++ b/pkg/golinters/gocyclo/gocyclo.go @@ -1,4 +1,4 @@ -package golinters +package gocyclo import ( "fmt" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const gocycloName = "gocyclo" +const name = "gocyclo" -func NewGocyclo(settings *config.GoCycloSettings) *goanalysis.Linter { +func New(settings *config.GoCycloSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: gocycloName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues := runGoCyclo(pass, settings) @@ -39,7 +39,7 @@ func NewGocyclo(settings *config.GoCycloSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - gocycloName, + name, "Computes and checks the cyclomatic complexity of functions", []*analysis.Analyzer{analyzer}, nil, @@ -68,7 +68,7 @@ func runGoCyclo(pass *analysis.Pass, settings *config.GoCycloSettings) []goanaly issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: s.Pos, Text: text, - FromLinter: gocycloName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/gocyclo/gocyclo_integration_test.go b/pkg/golinters/gocyclo/gocyclo_integration_test.go new file mode 100644 index 000000000000..f32502c922de --- /dev/null +++ b/pkg/golinters/gocyclo/gocyclo_integration_test.go @@ -0,0 +1,11 @@ +package gocyclo + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gocyclo.go b/pkg/golinters/gocyclo/testdata/gocyclo.go similarity index 89% rename from test/testdata/gocyclo.go rename to pkg/golinters/gocyclo/testdata/gocyclo.go index b37c8f89fdb1..8ec25e6c188f 100644 --- a/test/testdata/gocyclo.go +++ b/pkg/golinters/gocyclo/testdata/gocyclo.go @@ -1,5 +1,5 @@ //golangcitest:args -Egocyclo -//golangcitest:config_path testdata/configs/gocyclo.yml +//golangcitest:config_path testdata/gocyclo.yml package testdata import "net/http" diff --git a/test/testdata/configs/gocyclo.yml b/pkg/golinters/gocyclo/testdata/gocyclo.yml similarity index 100% rename from test/testdata/configs/gocyclo.yml rename to pkg/golinters/gocyclo/testdata/gocyclo.yml diff --git a/pkg/golinters/godot.go b/pkg/golinters/godot/godot.go similarity index 92% rename from pkg/golinters/godot.go rename to pkg/golinters/godot/godot.go index 614ea410249e..fc3584c48a52 100644 --- a/pkg/golinters/godot.go +++ b/pkg/golinters/godot/godot.go @@ -1,4 +1,4 @@ -package golinters +package godot import ( "sync" @@ -12,9 +12,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const godotName = "godot" +const name = "godot" -func NewGodot(settings *config.GodotSettings) *goanalysis.Linter { +func New(settings *config.GodotSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -39,7 +39,7 @@ func NewGodot(settings *config.GodotSettings) *goanalysis.Linter { } analyzer := &analysis.Analyzer{ - Name: godotName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runGodot(pass, dotSettings) @@ -60,7 +60,7 @@ func NewGodot(settings *config.GodotSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - godotName, + name, "Check if comments end in a period", []*analysis.Analyzer{analyzer}, nil, @@ -88,7 +88,7 @@ func runGodot(pass *analysis.Pass, settings godot.Settings) ([]goanalysis.Issue, issue := result.Issue{ Pos: i.Pos, Text: i.Message, - FromLinter: godotName, + FromLinter: name, Replacement: &result.Replacement{ NewLines: []string{i.Replacement}, }, diff --git a/pkg/golinters/godot/godot_integration_test.go b/pkg/golinters/godot/godot_integration_test.go new file mode 100644 index 000000000000..bec8b7bb7b0d --- /dev/null +++ b/pkg/golinters/godot/godot_integration_test.go @@ -0,0 +1,19 @@ +package godot + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/in/godot.go b/pkg/golinters/godot/testdata/fix/in/godot.go similarity index 100% rename from test/testdata/fix/in/godot.go rename to pkg/golinters/godot/testdata/fix/in/godot.go diff --git a/test/testdata/fix/out/godot.go b/pkg/golinters/godot/testdata/fix/out/godot.go similarity index 100% rename from test/testdata/fix/out/godot.go rename to pkg/golinters/godot/testdata/fix/out/godot.go diff --git a/test/testdata/godot.go b/pkg/golinters/godot/testdata/godot.go similarity index 100% rename from test/testdata/godot.go rename to pkg/golinters/godot/testdata/godot.go diff --git a/pkg/golinters/godox.go b/pkg/golinters/godox/godox.go similarity index 90% rename from pkg/golinters/godox.go rename to pkg/golinters/godox/godox.go index afe997bd2887..e3bc47181494 100644 --- a/pkg/golinters/godox.go +++ b/pkg/golinters/godox/godox.go @@ -1,4 +1,4 @@ -package golinters +package godox import ( "go/token" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const godoxName = "godox" +const name = "godox" -func NewGodox(settings *config.GodoxSettings) *goanalysis.Linter { +func New(settings *config.GodoxSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: godoxName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues := runGodox(pass, settings) @@ -39,7 +39,7 @@ func NewGodox(settings *config.GodoxSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - godoxName, + name, "Tool for detection of FIXME, TODO and other comment keywords", []*analysis.Analyzer{analyzer}, nil, @@ -67,7 +67,7 @@ func runGodox(pass *analysis.Pass, settings *config.GodoxSettings) []goanalysis. Line: i.Pos.Line, }, Text: strings.TrimRight(i.Message, "\n"), - FromLinter: godoxName, + FromLinter: name, }, pass) } diff --git a/pkg/golinters/godox/godox_integration_test.go b/pkg/golinters/godox/godox_integration_test.go new file mode 100644 index 000000000000..88e5b2c2c8f8 --- /dev/null +++ b/pkg/golinters/godox/godox_integration_test.go @@ -0,0 +1,11 @@ +package godox + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/godox.go b/pkg/golinters/godox/testdata/godox.go similarity index 91% rename from test/testdata/godox.go rename to pkg/golinters/godox/testdata/godox.go index 05dc554b3f4e..8919897db86a 100644 --- a/test/testdata/godox.go +++ b/pkg/golinters/godox/testdata/godox.go @@ -1,5 +1,5 @@ //golangcitest:args -Egodox -//golangcitest:config_path testdata/configs/godox.yml +//golangcitest:config_path testdata/godox.yml package testdata func todoLeftInCode() { diff --git a/test/testdata/configs/godox.yml b/pkg/golinters/godox/testdata/godox.yml similarity index 100% rename from test/testdata/configs/godox.yml rename to pkg/golinters/godox/testdata/godox.yml diff --git a/pkg/golinters/gofmt.go b/pkg/golinters/gofmt/gofmt.go similarity index 92% rename from pkg/golinters/gofmt.go rename to pkg/golinters/gofmt/gofmt.go index 9a00694440ec..bcdf833637c5 100644 --- a/pkg/golinters/gofmt.go +++ b/pkg/golinters/gofmt/gofmt.go @@ -1,4 +1,4 @@ -package golinters +package gofmt import ( "fmt" @@ -13,20 +13,20 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) -const gofmtName = "gofmt" +const name = "gofmt" -func NewGofmt(settings *config.GoFmtSettings) *goanalysis.Linter { +func New(settings *config.GoFmtSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: gofmtName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: goanalysis.DummyRun, } return goanalysis.NewLinter( - gofmtName, + name, "Gofmt checks whether code was gofmt-ed. By default "+ "this tool runs with -s option to check for code simplification", []*analysis.Analyzer{analyzer}, @@ -72,7 +72,7 @@ func runGofmt(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoF continue } - is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, gofmtName, getIssuedTextGoFmt) + is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, name, getIssuedTextGoFmt) if err != nil { return nil, fmt.Errorf("can't extract issues from gofmt diff output %q: %w", string(diff), err) } diff --git a/pkg/golinters/gofmt/gofmt_integration_test.go b/pkg/golinters/gofmt/gofmt_integration_test.go new file mode 100644 index 000000000000..603bcb2c0eec --- /dev/null +++ b/pkg/golinters/gofmt/gofmt_integration_test.go @@ -0,0 +1,19 @@ +package gofmt + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/in/gofmt.go b/pkg/golinters/gofmt/testdata/fix/in/gofmt.go similarity index 100% rename from test/testdata/fix/in/gofmt.go rename to pkg/golinters/gofmt/testdata/fix/in/gofmt.go diff --git a/test/testdata/fix/in/gofmt_rewrite_rules.go b/pkg/golinters/gofmt/testdata/fix/in/gofmt_rewrite_rules.go similarity index 83% rename from test/testdata/fix/in/gofmt_rewrite_rules.go rename to pkg/golinters/gofmt/testdata/fix/in/gofmt_rewrite_rules.go index 655fd7690000..10225950b6be 100644 --- a/test/testdata/fix/in/gofmt_rewrite_rules.go +++ b/pkg/golinters/gofmt/testdata/fix/in/gofmt_rewrite_rules.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofmt -//golangcitest:config_path testdata/configs/gofmt_rewrite_rules.yml +//golangcitest:config_path testdata/gofmt_rewrite_rules.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/fix/out/gofmt.go b/pkg/golinters/gofmt/testdata/fix/out/gofmt.go similarity index 100% rename from test/testdata/fix/out/gofmt.go rename to pkg/golinters/gofmt/testdata/fix/out/gofmt.go diff --git a/test/testdata/fix/out/gofmt_rewrite_rules.go b/pkg/golinters/gofmt/testdata/fix/out/gofmt_rewrite_rules.go similarity index 82% rename from test/testdata/fix/out/gofmt_rewrite_rules.go rename to pkg/golinters/gofmt/testdata/fix/out/gofmt_rewrite_rules.go index f240700c216e..2a7e5902ebae 100644 --- a/test/testdata/fix/out/gofmt_rewrite_rules.go +++ b/pkg/golinters/gofmt/testdata/fix/out/gofmt_rewrite_rules.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofmt -//golangcitest:config_path testdata/configs/gofmt_rewrite_rules.yml +//golangcitest:config_path testdata/gofmt_rewrite_rules.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/gofmt.go b/pkg/golinters/gofmt/testdata/gofmt.go similarity index 100% rename from test/testdata/gofmt.go rename to pkg/golinters/gofmt/testdata/gofmt.go diff --git a/test/testdata/gofmt_no_simplify.go b/pkg/golinters/gofmt/testdata/gofmt_no_simplify.go similarity index 74% rename from test/testdata/gofmt_no_simplify.go rename to pkg/golinters/gofmt/testdata/gofmt_no_simplify.go index 0d68bf181c4a..5d1de6167ce4 100644 --- a/test/testdata/gofmt_no_simplify.go +++ b/pkg/golinters/gofmt/testdata/gofmt_no_simplify.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofmt -//golangcitest:config_path testdata/configs/gofmt_no_simplify.yml +//golangcitest:config_path testdata/gofmt_no_simplify.yml package testdata import "fmt" diff --git a/test/testdata/configs/gofmt_no_simplify.yml b/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml similarity index 100% rename from test/testdata/configs/gofmt_no_simplify.yml rename to pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml diff --git a/test/testdata/gofmt_rewrite_rules.go b/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.go similarity index 79% rename from test/testdata/gofmt_rewrite_rules.go rename to pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.go index c3e1671d752a..f2877a99747e 100644 --- a/test/testdata/gofmt_rewrite_rules.go +++ b/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofmt -//golangcitest:config_path testdata/configs/gofmt_rewrite_rules.yml +//golangcitest:config_path testdata/gofmt_rewrite_rules.yml package testdata import "fmt" diff --git a/test/testdata/configs/gofmt_rewrite_rules.yml b/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml similarity index 100% rename from test/testdata/configs/gofmt_rewrite_rules.yml rename to pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml diff --git a/pkg/golinters/gofumpt.go b/pkg/golinters/gofumpt/gofumpt.go similarity index 92% rename from pkg/golinters/gofumpt.go rename to pkg/golinters/gofumpt/gofumpt.go index 4c6a9cec10fb..a31cd573b761 100644 --- a/pkg/golinters/gofumpt.go +++ b/pkg/golinters/gofumpt/gofumpt.go @@ -1,4 +1,4 @@ -package golinters +package gofumpt import ( "bytes" @@ -17,13 +17,13 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) -const gofumptName = "gofumpt" +const name = "gofumpt" type differ interface { Diff(out io.Writer, a io.ReadSeeker, b io.ReadSeeker) error } -func NewGofumpt(settings *config.GofumptSettings) *goanalysis.Linter { +func New(settings *config.GofumptSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -40,13 +40,13 @@ func NewGofumpt(settings *config.GofumptSettings) *goanalysis.Linter { } analyzer := &analysis.Analyzer{ - Name: gofumptName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: goanalysis.DummyRun, } return goanalysis.NewLinter( - gofumptName, + name, "Gofumpt checks whether code was gofumpt-ed.", []*analysis.Analyzer{analyzer}, nil, @@ -97,7 +97,7 @@ func runGofumpt(lintCtx *linter.Context, pass *analysis.Pass, diff differ, optio } diff := out.String() - is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, gofumptName, getIssuedTextGoFumpt) + is, err := internal.ExtractIssuesFromPatch(diff, lintCtx, name, getIssuedTextGoFumpt) if err != nil { return nil, fmt.Errorf("can't extract issues from gofumpt diff output %q: %w", diff, err) } diff --git a/pkg/golinters/gofumpt/gofumpt_integration_test.go b/pkg/golinters/gofumpt/gofumpt_integration_test.go new file mode 100644 index 000000000000..c69953bd5992 --- /dev/null +++ b/pkg/golinters/gofumpt/gofumpt_integration_test.go @@ -0,0 +1,19 @@ +package gofumpt + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/in/gofumpt.go b/pkg/golinters/gofumpt/testdata/fix/in/gofumpt.go similarity index 72% rename from test/testdata/fix/in/gofumpt.go rename to pkg/golinters/gofumpt/testdata/fix/in/gofumpt.go index b8e0bcbc81bf..b9abc2a9ffdf 100644 --- a/test/testdata/fix/in/gofumpt.go +++ b/pkg/golinters/gofumpt/testdata/fix/in/gofumpt.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofumpt -//golangcitest:config_path testdata/configs/gofumpt-fix.yml +//golangcitest:config_path testdata/gofumpt-fix.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/fix/out/gofumpt.go b/pkg/golinters/gofumpt/testdata/fix/out/gofumpt.go similarity index 71% rename from test/testdata/fix/out/gofumpt.go rename to pkg/golinters/gofumpt/testdata/fix/out/gofumpt.go index 5fc02f674330..168a33a81f1a 100644 --- a/test/testdata/fix/out/gofumpt.go +++ b/pkg/golinters/gofumpt/testdata/fix/out/gofumpt.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofumpt -//golangcitest:config_path testdata/configs/gofumpt-fix.yml +//golangcitest:config_path testdata/gofumpt-fix.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/configs/gofumpt-fix.yml b/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml similarity index 100% rename from test/testdata/configs/gofumpt-fix.yml rename to pkg/golinters/gofumpt/testdata/gofumpt-fix.yml diff --git a/test/testdata/gofumpt.go b/pkg/golinters/gofumpt/testdata/gofumpt.go similarity index 100% rename from test/testdata/gofumpt.go rename to pkg/golinters/gofumpt/testdata/gofumpt.go diff --git a/test/testdata/gofumpt_with_extra.go b/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.go similarity index 72% rename from test/testdata/gofumpt_with_extra.go rename to pkg/golinters/gofumpt/testdata/gofumpt_with_extra.go index 4671f41e0ad8..6f01ba7e0fb7 100644 --- a/test/testdata/gofumpt_with_extra.go +++ b/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofumpt -//golangcitest:config_path testdata/configs/gofumpt_with_extra.yml +//golangcitest:config_path testdata/gofumpt_with_extra.yml package testdata import "fmt" diff --git a/test/testdata/configs/gofumpt_with_extra.yml b/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml similarity index 100% rename from test/testdata/configs/gofumpt_with_extra.yml rename to pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml diff --git a/pkg/golinters/goheader.go b/pkg/golinters/goheader/goheader.go similarity index 92% rename from pkg/golinters/goheader.go rename to pkg/golinters/goheader/goheader.go index b47f0304e65d..bb6e4040627c 100644 --- a/pkg/golinters/goheader.go +++ b/pkg/golinters/goheader/goheader.go @@ -1,4 +1,4 @@ -package golinters +package goheader import ( "go/token" @@ -13,9 +13,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const goHeaderName = "goheader" +const name = "goheader" -func NewGoHeader(settings *config.GoHeaderSettings) *goanalysis.Linter { +func New(settings *config.GoHeaderSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -29,7 +29,7 @@ func NewGoHeader(settings *config.GoHeaderSettings) *goanalysis.Linter { } analyzer := &analysis.Analyzer{ - Name: goHeaderName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runGoHeader(pass, conf) @@ -50,7 +50,7 @@ func NewGoHeader(settings *config.GoHeaderSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - goHeaderName, + name, "Checks is file header matches to pattern", []*analysis.Analyzer{analyzer}, nil, @@ -94,7 +94,7 @@ func runGoHeader(pass *analysis.Pass, conf *goheader.Configuration) ([]goanalysi Filename: path, }, Text: i.Message(), - FromLinter: goHeaderName, + FromLinter: name, } if fix := i.Fix(); fix != nil { diff --git a/pkg/golinters/goheader/goheader_integration_test.go b/pkg/golinters/goheader/goheader_integration_test.go new file mode 100644 index 000000000000..b34458b75444 --- /dev/null +++ b/pkg/golinters/goheader/goheader_integration_test.go @@ -0,0 +1,19 @@ +package goheader + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/in/goheader_1.go b/pkg/golinters/goheader/testdata/fix/in/goheader_1.go similarity index 66% rename from test/testdata/fix/in/goheader_1.go rename to pkg/golinters/goheader/testdata/fix/in/goheader_1.go index ab8b9b3e7b02..391b3c4629ae 100644 --- a/test/testdata/fix/in/goheader_1.go +++ b/pkg/golinters/goheader/testdata/fix/in/goheader_1.go @@ -2,5 +2,5 @@ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/goheader-fix.yml +//golangcitest:config_path testdata/goheader-fix.yml package p diff --git a/test/testdata/fix/in/goheader_2.go b/pkg/golinters/goheader/testdata/fix/in/goheader_2.go similarity index 72% rename from test/testdata/fix/in/goheader_2.go rename to pkg/golinters/goheader/testdata/fix/in/goheader_2.go index f00b31ab09b6..f42c45ed600f 100644 --- a/test/testdata/fix/in/goheader_2.go +++ b/pkg/golinters/goheader/testdata/fix/in/goheader_2.go @@ -4,5 +4,5 @@ Use of this source code is governed */ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/goheader-fix.yml +//golangcitest:config_path testdata/goheader-fix.yml package p diff --git a/test/testdata/fix/in/goheader_3.go b/pkg/golinters/goheader/testdata/fix/in/goheader_3.go similarity index 72% rename from test/testdata/fix/in/goheader_3.go rename to pkg/golinters/goheader/testdata/fix/in/goheader_3.go index 4d6012bb3e6a..cf440a315327 100644 --- a/test/testdata/fix/in/goheader_3.go +++ b/pkg/golinters/goheader/testdata/fix/in/goheader_3.go @@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/goheader-fix.yml +//golangcitest:config_path testdata/goheader-fix.yml package p diff --git a/test/testdata/fix/out/goheader_1.go b/pkg/golinters/goheader/testdata/fix/out/goheader_1.go similarity index 74% rename from test/testdata/fix/out/goheader_1.go rename to pkg/golinters/goheader/testdata/fix/out/goheader_1.go index 61288e337eeb..fbc9a7f3b1a6 100644 --- a/test/testdata/fix/out/goheader_1.go +++ b/pkg/golinters/goheader/testdata/fix/out/goheader_1.go @@ -4,5 +4,5 @@ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/goheader-fix.yml +//golangcitest:config_path testdata/goheader-fix.yml package p diff --git a/test/testdata/fix/out/goheader_2.go b/pkg/golinters/goheader/testdata/fix/out/goheader_2.go similarity index 74% rename from test/testdata/fix/out/goheader_2.go rename to pkg/golinters/goheader/testdata/fix/out/goheader_2.go index a09a0ba01a3a..4084bdab2090 100644 --- a/test/testdata/fix/out/goheader_2.go +++ b/pkg/golinters/goheader/testdata/fix/out/goheader_2.go @@ -4,5 +4,5 @@ Use of this source code is governed by LICENSE */ //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/goheader-fix.yml +//golangcitest:config_path testdata/goheader-fix.yml package p diff --git a/test/testdata/fix/out/goheader_3.go b/pkg/golinters/goheader/testdata/fix/out/goheader_3.go similarity index 74% rename from test/testdata/fix/out/goheader_3.go rename to pkg/golinters/goheader/testdata/fix/out/goheader_3.go index 8b2f9c4e9f68..2fc7637b7ae1 100644 --- a/test/testdata/fix/out/goheader_3.go +++ b/pkg/golinters/goheader/testdata/fix/out/goheader_3.go @@ -6,5 +6,5 @@ Use of this source code is governed by LICENSE //golangcitest:args -Egoheader //golangcitest:expected_exitcode 0 -//golangcitest:config_path testdata/configs/goheader-fix.yml +//golangcitest:config_path testdata/goheader-fix.yml package p diff --git a/test/testdata/configs/goheader-fix.yml b/pkg/golinters/goheader/testdata/goheader-fix.yml similarity index 100% rename from test/testdata/configs/goheader-fix.yml rename to pkg/golinters/goheader/testdata/goheader-fix.yml diff --git a/test/testdata/configs/goheader.yml b/pkg/golinters/goheader/testdata/goheader.yml similarity index 100% rename from test/testdata/configs/goheader.yml rename to pkg/golinters/goheader/testdata/goheader.yml diff --git a/test/testdata/goheader_bad.go b/pkg/golinters/goheader/testdata/goheader_bad.go similarity index 65% rename from test/testdata/goheader_bad.go rename to pkg/golinters/goheader/testdata/goheader_bad.go index 079e803d961f..73d7b8a77bca 100644 --- a/test/testdata/goheader_bad.go +++ b/pkg/golinters/goheader/testdata/goheader_bad.go @@ -1,5 +1,5 @@ /*MY TITLE!*/ // want `Expected:TITLE\., Actual: TITLE!` //golangcitest:args -Egoheader -//golangcitest:config_path testdata/configs/goheader.yml +//golangcitest:config_path testdata/goheader.yml package testdata diff --git a/test/testdata/goheader_good.go b/pkg/golinters/goheader/testdata/goheader_good.go similarity index 63% rename from test/testdata/goheader_good.go rename to pkg/golinters/goheader/testdata/goheader_good.go index e003b9491fd2..0446c8789e2a 100644 --- a/test/testdata/goheader_good.go +++ b/pkg/golinters/goheader/testdata/goheader_good.go @@ -1,6 +1,6 @@ /*MY TITLE.*/ //golangcitest:args -Egoheader -//golangcitest:config_path testdata/configs/goheader.yml +//golangcitest:config_path testdata/goheader.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/pkg/golinters/goimports.go b/pkg/golinters/goimports/goimports.go similarity index 90% rename from pkg/golinters/goimports.go rename to pkg/golinters/goimports/goimports.go index 224970f5ca90..8be50629142f 100644 --- a/pkg/golinters/goimports.go +++ b/pkg/golinters/goimports/goimports.go @@ -1,4 +1,4 @@ -package golinters +package goimports import ( "fmt" @@ -14,20 +14,20 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) -const goimportsName = "goimports" +const name = "goimports" -func NewGoimports(settings *config.GoImportsSettings) *goanalysis.Linter { +func New(settings *config.GoImportsSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: goimportsName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: goanalysis.DummyRun, } return goanalysis.NewLinter( - goimportsName, + name, "Check import statements are formatted according to the 'goimport' command. "+ "Reformat imports in autofix mode.", []*analysis.Analyzer{analyzer}, @@ -70,7 +70,7 @@ func runGoImports(lintCtx *linter.Context, pass *analysis.Pass) ([]goanalysis.Is continue } - is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, goimportsName, getIssuedTextGoImports) + is, err := internal.ExtractIssuesFromPatch(string(diff), lintCtx, name, getIssuedTextGoImports) if err != nil { return nil, fmt.Errorf("can't extract issues from gofmt diff output %q: %w", string(diff), err) } diff --git a/pkg/golinters/goimports/goimports_integration_test.go b/pkg/golinters/goimports/goimports_integration_test.go new file mode 100644 index 000000000000..08aa3cefc624 --- /dev/null +++ b/pkg/golinters/goimports/goimports_integration_test.go @@ -0,0 +1,19 @@ +package goimports + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/in/goimports.go b/pkg/golinters/goimports/testdata/fix/in/goimports.go similarity index 100% rename from test/testdata/fix/in/goimports.go rename to pkg/golinters/goimports/testdata/fix/in/goimports.go diff --git a/test/testdata/fix/out/goimports.go b/pkg/golinters/goimports/testdata/fix/out/goimports.go similarity index 100% rename from test/testdata/fix/out/goimports.go rename to pkg/golinters/goimports/testdata/fix/out/goimports.go diff --git a/test/testdata/goimports.go b/pkg/golinters/goimports/testdata/goimports.go similarity index 100% rename from test/testdata/goimports.go rename to pkg/golinters/goimports/testdata/goimports.go diff --git a/test/testdata/goimports_local.go b/pkg/golinters/goimports/testdata/goimports_local.go similarity index 83% rename from test/testdata/goimports_local.go rename to pkg/golinters/goimports/testdata/goimports_local.go index b89b4ded6045..3e330e9c850f 100644 --- a/test/testdata/goimports_local.go +++ b/pkg/golinters/goimports/testdata/goimports_local.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoimports -//golangcitest:config_path testdata/configs/goimports_local.yml +//golangcitest:config_path testdata/goimports_local.yml package testdata import ( diff --git a/test/testdata/configs/goimports_local.yml b/pkg/golinters/goimports/testdata/goimports_local.yml similarity index 100% rename from test/testdata/configs/goimports_local.yml rename to pkg/golinters/goimports/testdata/goimports_local.yml diff --git a/pkg/golinters/gomoddirectives.go b/pkg/golinters/gomoddirectives/gomoddirectives.go similarity index 83% rename from pkg/golinters/gomoddirectives.go rename to pkg/golinters/gomoddirectives/gomoddirectives.go index 6902b3207e3f..253faa017080 100644 --- a/pkg/golinters/gomoddirectives.go +++ b/pkg/golinters/gomoddirectives/gomoddirectives.go @@ -1,4 +1,4 @@ -package golinters +package gomoddirectives import ( "sync" @@ -12,10 +12,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const goModDirectivesName = "gomoddirectives" +const name = "gomoddirectives" -// NewGoModDirectives returns a new gomoddirectives linter. -func NewGoModDirectives(settings *config.GoModDirectivesSettings) *goanalysis.Linter { +func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter { var issues []goanalysis.Issue var once sync.Once @@ -34,7 +33,7 @@ func NewGoModDirectives(settings *config.GoModDirectivesSettings) *goanalysis.Li } return goanalysis.NewLinter( - goModDirectivesName, + name, "Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.", []*analysis.Analyzer{analyzer}, nil, @@ -44,13 +43,13 @@ func NewGoModDirectives(settings *config.GoModDirectivesSettings) *goanalysis.Li results, err := gomoddirectives.Analyze(opts) if err != nil { lintCtx.Log.Warnf("running %s failed: %s: "+ - "if you are not using go modules it is suggested to disable this linter", goModDirectivesName, err) + "if you are not using go modules it is suggested to disable this linter", name, err) return } for _, p := range results { issues = append(issues, goanalysis.NewIssue(&result.Issue{ - FromLinter: goModDirectivesName, + FromLinter: name, Pos: p.Start, Text: p.Reason, }, pass)) diff --git a/pkg/golinters/gomodguard.go b/pkg/golinters/gomodguard/gomodguard.go similarity index 88% rename from pkg/golinters/gomodguard.go rename to pkg/golinters/gomodguard/gomodguard.go index fe880b57fe8b..8f1036b0f13c 100644 --- a/pkg/golinters/gomodguard.go +++ b/pkg/golinters/gomodguard/gomodguard.go @@ -1,4 +1,4 @@ -package golinters +package gomodguard import ( "sync" @@ -14,14 +14,13 @@ import ( ) const ( - gomodguardName = "gomodguard" - gomodguardDesc = "Allow and block list linter for direct Go module dependencies. " + + name = "gomodguard" + desc = "Allow and block list linter for direct Go module dependencies. " + "This is different from depguard where there are different block " + "types for example version constraints and module recommendations." ) -// NewGomodguard returns a new Gomodguard linter. -func NewGomodguard(settings *config.GoModGuardSettings) *goanalysis.Linter { +func New(settings *config.GoModGuardSettings) *goanalysis.Linter { var issues []goanalysis.Issue var mu sync.Mutex @@ -61,8 +60,8 @@ func NewGomodguard(settings *config.GoModGuardSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - gomodguardName, - gomodguardDesc, + name, + desc, []*analysis.Analyzer{analyzer}, nil, ).WithContextSetter(func(lintCtx *linter.Context) { @@ -81,7 +80,7 @@ func NewGomodguard(settings *config.GoModGuardSettings) *goanalysis.Linter { for _, gomodguardIssue := range gomodguardIssues { issues = append(issues, goanalysis.NewIssue(&result.Issue{ - FromLinter: gomodguardName, + FromLinter: name, Pos: gomodguardIssue.Position, Text: gomodguardIssue.Reason, }, pass)) diff --git a/pkg/golinters/gomodguard/gomodguard_integration_test.go b/pkg/golinters/gomodguard/gomodguard_integration_test.go new file mode 100644 index 000000000000..2ac44b6be6cd --- /dev/null +++ b/pkg/golinters/gomodguard/gomodguard_integration_test.go @@ -0,0 +1,11 @@ +package gomodguard + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gomodguard.go b/pkg/golinters/gomodguard/testdata/gomodguard.go similarity index 91% rename from test/testdata/gomodguard.go rename to pkg/golinters/gomodguard/testdata/gomodguard.go index 9cb1cf68f67c..50e411a5e07f 100644 --- a/test/testdata/gomodguard.go +++ b/pkg/golinters/gomodguard/testdata/gomodguard.go @@ -1,5 +1,5 @@ //golangcitest:args -Egomodguard -//golangcitest:config_path testdata/configs/gomodguard.yml +//golangcitest:config_path testdata/gomodguard.yml package testdata import ( diff --git a/test/testdata/configs/gomodguard.yml b/pkg/golinters/gomodguard/testdata/gomodguard.yml similarity index 100% rename from test/testdata/configs/gomodguard.yml rename to pkg/golinters/gomodguard/testdata/gomodguard.yml diff --git a/pkg/golinters/goprintffuncname.go b/pkg/golinters/goprintffuncname/goprintffuncname.go similarity index 82% rename from pkg/golinters/goprintffuncname.go rename to pkg/golinters/goprintffuncname/goprintffuncname.go index 97df64051b41..85154a9b38ea 100644 --- a/pkg/golinters/goprintffuncname.go +++ b/pkg/golinters/goprintffuncname/goprintffuncname.go @@ -1,4 +1,4 @@ -package golinters +package goprintffuncname import ( "github.com/jirfag/go-printf-func-name/pkg/analyzer" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewGoPrintfFuncName() *goanalysis.Linter { +func New() *goanalysis.Linter { a := analyzer.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/goprintffuncname/goprintffuncname_integration_test.go b/pkg/golinters/goprintffuncname/goprintffuncname_integration_test.go new file mode 100644 index 000000000000..d8aade2ee840 --- /dev/null +++ b/pkg/golinters/goprintffuncname/goprintffuncname_integration_test.go @@ -0,0 +1,11 @@ +package goprintffuncname + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/goprintffuncname.go b/pkg/golinters/goprintffuncname/testdata/goprintffuncname.go similarity index 100% rename from test/testdata/goprintffuncname.go rename to pkg/golinters/goprintffuncname/testdata/goprintffuncname.go diff --git a/pkg/golinters/gosec.go b/pkg/golinters/gosec/gosec.go similarity index 97% rename from pkg/golinters/gosec.go rename to pkg/golinters/gosec/gosec.go index 3ce37cac48c2..d824090b57b2 100644 --- a/pkg/golinters/gosec.go +++ b/pkg/golinters/gosec/gosec.go @@ -1,4 +1,4 @@ -package golinters +package gosec import ( "fmt" @@ -21,9 +21,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const gosecName = "gosec" +const name = "gosec" -func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter { +func New(settings *config.GoSecSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -39,13 +39,13 @@ func NewGosec(settings *config.GoSecSettings) *goanalysis.Linter { ruleDefinitions := rules.Generate(false, filters...) analyzer := &analysis.Analyzer{ - Name: gosecName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: goanalysis.DummyRun, } return goanalysis.NewLinter( - gosecName, + name, "Inspects source code for security problems", []*analysis.Analyzer{analyzer}, nil, @@ -126,7 +126,7 @@ func runGoSec(lintCtx *linter.Context, pass *analysis.Pass, settings *config.GoS }, Text: text, LineRange: r, - FromLinter: gosecName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/gosec/gosec_integration_test.go b/pkg/golinters/gosec/gosec_integration_test.go new file mode 100644 index 000000000000..0642d7896297 --- /dev/null +++ b/pkg/golinters/gosec/gosec_integration_test.go @@ -0,0 +1,11 @@ +package gosec + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/pkg/golinters/gosec_test.go b/pkg/golinters/gosec/gosec_test.go similarity index 98% rename from pkg/golinters/gosec_test.go rename to pkg/golinters/gosec/gosec_test.go index 9b1b5faeff96..e8d6187e350d 100644 --- a/pkg/golinters/gosec_test.go +++ b/pkg/golinters/gosec/gosec_test.go @@ -1,4 +1,4 @@ -package golinters +package gosec import ( "testing" diff --git a/test/testdata/gosec.go b/pkg/golinters/gosec/testdata/gosec.go similarity index 100% rename from test/testdata/gosec.go rename to pkg/golinters/gosec/testdata/gosec.go diff --git a/test/testdata/configs/gosec.yml b/pkg/golinters/gosec/testdata/gosec.yml similarity index 100% rename from test/testdata/configs/gosec.yml rename to pkg/golinters/gosec/testdata/gosec.yml diff --git a/test/testdata/gosec_global_option.go b/pkg/golinters/gosec/testdata/gosec_global_option.go similarity index 79% rename from test/testdata/gosec_global_option.go rename to pkg/golinters/gosec/testdata/gosec_global_option.go index 0a9407ea75de..16516935f08c 100644 --- a/test/testdata/gosec_global_option.go +++ b/pkg/golinters/gosec/testdata/gosec_global_option.go @@ -1,5 +1,5 @@ //golangcitest:args -Egosec -//golangcitest:config_path testdata/configs/gosec_global_option.yml +//golangcitest:config_path testdata/gosec_global_option.yml package testdata import ( diff --git a/test/testdata/configs/gosec_global_option.yml b/pkg/golinters/gosec/testdata/gosec_global_option.yml similarity index 100% rename from test/testdata/configs/gosec_global_option.yml rename to pkg/golinters/gosec/testdata/gosec_global_option.yml diff --git a/test/testdata/gosec_rules_config.go b/pkg/golinters/gosec/testdata/gosec_rules_config.go similarity index 87% rename from test/testdata/gosec_rules_config.go rename to pkg/golinters/gosec/testdata/gosec_rules_config.go index 75845b6dd907..f36732d007fe 100644 --- a/test/testdata/gosec_rules_config.go +++ b/pkg/golinters/gosec/testdata/gosec_rules_config.go @@ -1,5 +1,5 @@ //golangcitest:args -Egosec -//golangcitest:config_path testdata/configs/gosec.yml +//golangcitest:config_path testdata/gosec.yml package testdata import "io/ioutil" diff --git a/test/testdata/gosec_severity_confidence.go b/pkg/golinters/gosec/testdata/gosec_severity_confidence.go similarity index 88% rename from test/testdata/gosec_severity_confidence.go rename to pkg/golinters/gosec/testdata/gosec_severity_confidence.go index ee1ed957b905..b9dcd83c0db4 100644 --- a/test/testdata/gosec_severity_confidence.go +++ b/pkg/golinters/gosec/testdata/gosec_severity_confidence.go @@ -1,5 +1,5 @@ //golangcitest:args -Egosec -//golangcitest:config_path testdata/configs/gosec_severity_confidence.yml +//golangcitest:config_path testdata/gosec_severity_confidence.yml package testdata import ( diff --git a/test/testdata/configs/gosec_severity_confidence.yml b/pkg/golinters/gosec/testdata/gosec_severity_confidence.yml similarity index 100% rename from test/testdata/configs/gosec_severity_confidence.yml rename to pkg/golinters/gosec/testdata/gosec_severity_confidence.yml diff --git a/pkg/golinters/gosimple.go b/pkg/golinters/gosimple/gosimple.go similarity index 85% rename from pkg/golinters/gosimple.go rename to pkg/golinters/gosimple/gosimple.go index b7930f0ee022..6a0d967232ab 100644 --- a/pkg/golinters/gosimple.go +++ b/pkg/golinters/gosimple/gosimple.go @@ -1,4 +1,4 @@ -package golinters +package gosimple import ( "honnef.co/go/tools/simple" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/internal" ) -func NewGosimple(settings *config.StaticCheckSettings) *goanalysis.Linter { +func New(settings *config.StaticCheckSettings) *goanalysis.Linter { cfg := internal.StaticCheckConfig(settings) analyzers := internal.SetupStaticCheckAnalyzers(simple.Analyzers, internal.GetGoVersion(settings), cfg.Checks) diff --git a/pkg/golinters/gosimple/gosimple_integration_test.go b/pkg/golinters/gosimple/gosimple_integration_test.go new file mode 100644 index 000000000000..34622960fb1b --- /dev/null +++ b/pkg/golinters/gosimple/gosimple_integration_test.go @@ -0,0 +1,11 @@ +package gosimple + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gosimple.go b/pkg/golinters/gosimple/testdata/gosimple.go similarity index 100% rename from test/testdata/gosimple.go rename to pkg/golinters/gosimple/testdata/gosimple.go diff --git a/pkg/golinters/gosmopolitan.go b/pkg/golinters/gosmopolitan/gosmopolitan.go similarity index 87% rename from pkg/golinters/gosmopolitan.go rename to pkg/golinters/gosmopolitan/gosmopolitan.go index f4c2114706ea..4f6fb80358ab 100644 --- a/pkg/golinters/gosmopolitan.go +++ b/pkg/golinters/gosmopolitan/gosmopolitan.go @@ -1,4 +1,4 @@ -package golinters +package gosmopolitan import ( "strings" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewGosmopolitan(s *config.GosmopolitanSettings) *goanalysis.Linter { +func New(s *config.GosmopolitanSettings) *goanalysis.Linter { a := gosmopolitan.NewAnalyzer() cfgMap := map[string]map[string]any{} diff --git a/pkg/golinters/gosmopolitan/gosmopolitan_integration_test.go b/pkg/golinters/gosmopolitan/gosmopolitan_integration_test.go new file mode 100644 index 000000000000..4c7f39d33080 --- /dev/null +++ b/pkg/golinters/gosmopolitan/gosmopolitan_integration_test.go @@ -0,0 +1,11 @@ +package gosmopolitan + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/gosmopolitan.go b/pkg/golinters/gosmopolitan/testdata/gosmopolitan.go similarity index 100% rename from test/testdata/gosmopolitan.go rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan.go diff --git a/test/testdata/gosmopolitan_allow_time_local.go b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.go similarity index 64% rename from test/testdata/gosmopolitan_allow_time_local.go rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.go index e2380740c91d..44859d368ba2 100644 --- a/test/testdata/gosmopolitan_allow_time_local.go +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.go @@ -1,5 +1,5 @@ //golangcitest:args -Egosmopolitan -//golangcitest:config_path testdata/configs/gosmopolitan_allow_time_local.yml +//golangcitest:config_path testdata/gosmopolitan_allow_time_local.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/configs/gosmopolitan_allow_time_local.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml similarity index 100% rename from test/testdata/configs/gosmopolitan_allow_time_local.yml rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_allow_time_local.yml diff --git a/test/testdata/gosmopolitan_dont_ignore_test.go b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_test.go similarity index 73% rename from test/testdata/gosmopolitan_dont_ignore_test.go rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_test.go index 36bdc56bf4e1..5a347af10a33 100644 --- a/test/testdata/gosmopolitan_dont_ignore_test.go +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Egosmopolitan -//golangcitest:config_path testdata/configs/gosmopolitan_dont_ignore_tests.yml +//golangcitest:config_path testdata/gosmopolitan_dont_ignore_tests.yml package testdata import ( diff --git a/test/testdata/configs/gosmopolitan_dont_ignore_tests.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_tests.yml similarity index 100% rename from test/testdata/configs/gosmopolitan_dont_ignore_tests.yml rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_dont_ignore_tests.yml diff --git a/test/testdata/gosmopolitan_escape_hatches.go b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.go similarity index 88% rename from test/testdata/gosmopolitan_escape_hatches.go rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.go index 85b96be745f0..59ab1dff4397 100644 --- a/test/testdata/gosmopolitan_escape_hatches.go +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.go @@ -1,5 +1,5 @@ //golangcitest:args -Egosmopolitan -//golangcitest:config_path testdata/configs/gosmopolitan_escape_hatches.yml +//golangcitest:config_path testdata/gosmopolitan_escape_hatches.yml package testdata import ( diff --git a/test/testdata/configs/gosmopolitan_escape_hatches.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml similarity index 100% rename from test/testdata/configs/gosmopolitan_escape_hatches.yml rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_escape_hatches.yml diff --git a/test/testdata/gosmopolitan_ignore_test.go b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_ignore_test.go similarity index 100% rename from test/testdata/gosmopolitan_ignore_test.go rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_ignore_test.go diff --git a/test/testdata/gosmopolitan_scripts.go b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.go similarity index 84% rename from test/testdata/gosmopolitan_scripts.go rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.go index 04702991640f..65ed0e72a33e 100644 --- a/test/testdata/gosmopolitan_scripts.go +++ b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.go @@ -1,5 +1,5 @@ //golangcitest:args -Egosmopolitan -//golangcitest:config_path testdata/configs/gosmopolitan_scripts.yml +//golangcitest:config_path testdata/gosmopolitan_scripts.yml package testdata import ( diff --git a/test/testdata/configs/gosmopolitan_scripts.yml b/pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml similarity index 100% rename from test/testdata/configs/gosmopolitan_scripts.yml rename to pkg/golinters/gosmopolitan/testdata/gosmopolitan_scripts.yml diff --git a/pkg/golinters/govet.go b/pkg/golinters/govet/govet.go similarity index 95% rename from pkg/golinters/govet.go rename to pkg/golinters/govet/govet.go index 6662c03e5d3a..1211a8833b5e 100644 --- a/pkg/golinters/govet.go +++ b/pkg/golinters/govet/govet.go @@ -1,4 +1,4 @@ -package golinters +package govet import ( "slices" @@ -139,11 +139,11 @@ var ( ) var ( - govetDebugf = logutils.Debug(logutils.DebugKeyGovet) - isGovetDebug = logutils.HaveDebugTag(logutils.DebugKeyGovet) + debugf = logutils.Debug(logutils.DebugKeyGovet) + isDebug = logutils.HaveDebugTag(logutils.DebugKeyGovet) ) -func NewGovet(settings *config.GovetSettings) *goanalysis.Linter { +func New(settings *config.GovetSettings) *goanalysis.Linter { var conf map[string]map[string]any if settings != nil { conf = settings.Settings @@ -208,7 +208,7 @@ func isAnalyzerEnabled(name string, cfg *config.GovetSettings, defaultAnalyzers } func debugAnalyzersListf(analyzers []*analysis.Analyzer, message string) { - if !isGovetDebug { + if !isDebug { return } @@ -219,5 +219,5 @@ func debugAnalyzersListf(analyzers []*analysis.Analyzer, message string) { sort.Strings(analyzerNames) - govetDebugf("%s (%d): %s", message, len(analyzerNames), analyzerNames) + debugf("%s (%d): %s", message, len(analyzerNames), analyzerNames) } diff --git a/pkg/golinters/govet/govet_integration_test.go b/pkg/golinters/govet/govet_integration_test.go new file mode 100644 index 000000000000..26cab9c8c3c7 --- /dev/null +++ b/pkg/golinters/govet/govet_integration_test.go @@ -0,0 +1,11 @@ +package govet + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/pkg/golinters/govet_test.go b/pkg/golinters/govet/govet_test.go similarity index 99% rename from pkg/golinters/govet_test.go rename to pkg/golinters/govet/govet_test.go index 91b5179243ae..47042ef37d99 100644 --- a/pkg/golinters/govet_test.go +++ b/pkg/golinters/govet/govet_test.go @@ -1,4 +1,4 @@ -package golinters +package govet import ( "slices" diff --git a/test/testdata/govet.go b/pkg/golinters/govet/testdata/govet.go similarity index 95% rename from test/testdata/govet.go rename to pkg/golinters/govet/testdata/govet.go index c09fd42fefc2..f472b3e66447 100644 --- a/test/testdata/govet.go +++ b/pkg/golinters/govet/testdata/govet.go @@ -1,5 +1,5 @@ //golangcitest:args -Egovet -//golangcitest:config_path testdata/configs/govet.yml +//golangcitest:config_path testdata/govet.yml package testdata import ( diff --git a/test/testdata/configs/govet.yml b/pkg/golinters/govet/testdata/govet.yml similarity index 100% rename from test/testdata/configs/govet.yml rename to pkg/golinters/govet/testdata/govet.yml diff --git a/test/testdata/govet_custom_formatter.go b/pkg/golinters/govet/testdata/govet_custom_formatter.go similarity index 100% rename from test/testdata/govet_custom_formatter.go rename to pkg/golinters/govet/testdata/govet_custom_formatter.go diff --git a/test/testdata/govet_fieldalignment.go b/pkg/golinters/govet/testdata/govet_fieldalignment.go similarity index 91% rename from test/testdata/govet_fieldalignment.go rename to pkg/golinters/govet/testdata/govet_fieldalignment.go index cb7f2af2a201..e29be101eb7c 100644 --- a/test/testdata/govet_fieldalignment.go +++ b/pkg/golinters/govet/testdata/govet_fieldalignment.go @@ -1,5 +1,5 @@ //golangcitest:args -Egovet -//golangcitest:config_path testdata/configs/govet_fieldalignment.yml +//golangcitest:config_path testdata/govet_fieldalignment.yml package testdata type gvfaGood struct { diff --git a/test/testdata/configs/govet_fieldalignment.yml b/pkg/golinters/govet/testdata/govet_fieldalignment.yml similarity index 100% rename from test/testdata/configs/govet_fieldalignment.yml rename to pkg/golinters/govet/testdata/govet_fieldalignment.yml diff --git a/test/testdata/govet_ifaceassert.go b/pkg/golinters/govet/testdata/govet_ifaceassert.go similarity index 81% rename from test/testdata/govet_ifaceassert.go rename to pkg/golinters/govet/testdata/govet_ifaceassert.go index f495719c1abd..8b0821b98f5a 100644 --- a/test/testdata/govet_ifaceassert.go +++ b/pkg/golinters/govet/testdata/govet_ifaceassert.go @@ -1,5 +1,5 @@ //golangcitest:args -Egovet -//golangcitest:config_path testdata/configs/govet_ifaceassert.yml +//golangcitest:config_path testdata/govet_ifaceassert.yml package testdata import ( diff --git a/test/testdata/configs/govet_ifaceassert.yml b/pkg/golinters/govet/testdata/govet_ifaceassert.yml similarity index 100% rename from test/testdata/configs/govet_ifaceassert.yml rename to pkg/golinters/govet/testdata/govet_ifaceassert.yml diff --git a/pkg/golinters/grouper.go b/pkg/golinters/grouper/grouper.go similarity index 92% rename from pkg/golinters/grouper.go rename to pkg/golinters/grouper/grouper.go index f4eb3c4271e9..aa6ce1cebb15 100644 --- a/pkg/golinters/grouper.go +++ b/pkg/golinters/grouper/grouper.go @@ -1,4 +1,4 @@ -package golinters +package grouper import ( grouper "github.com/leonklingele/grouper/pkg/analyzer" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewGrouper(settings *config.GrouperSettings) *goanalysis.Linter { +func New(settings *config.GrouperSettings) *goanalysis.Linter { a := grouper.New() linterCfg := map[string]map[string]any{} diff --git a/pkg/golinters/grouper/grouper_integration_test.go b/pkg/golinters/grouper/grouper_integration_test.go new file mode 100644 index 000000000000..2474f98c8895 --- /dev/null +++ b/pkg/golinters/grouper/grouper_integration_test.go @@ -0,0 +1,11 @@ +package grouper + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/grouper.go b/pkg/golinters/grouper/testdata/grouper.go similarity index 73% rename from test/testdata/grouper.go rename to pkg/golinters/grouper/testdata/grouper.go index a4081670b83b..4bf696136376 100644 --- a/test/testdata/grouper.go +++ b/pkg/golinters/grouper/testdata/grouper.go @@ -1,5 +1,5 @@ //golangcitest:args -Egrouper -//golangcitest:config_path testdata/configs/grouper.yml +//golangcitest:config_path testdata/grouper.yml package testdata import "fmt" // want "should only use grouped 'import' declarations" diff --git a/test/testdata/configs/grouper.yml b/pkg/golinters/grouper/testdata/grouper.yml similarity index 100% rename from test/testdata/configs/grouper.yml rename to pkg/golinters/grouper/testdata/grouper.yml diff --git a/pkg/golinters/importas.go b/pkg/golinters/importas/importas.go similarity index 95% rename from pkg/golinters/importas.go rename to pkg/golinters/importas/importas.go index f699edfc877c..45117c9a488b 100644 --- a/pkg/golinters/importas.go +++ b/pkg/golinters/importas/importas.go @@ -1,4 +1,4 @@ -package golinters +package importas import ( "fmt" @@ -13,7 +13,7 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) -func NewImportAs(settings *config.ImportAsSettings) *goanalysis.Linter { +func New(settings *config.ImportAsSettings) *goanalysis.Linter { analyzer := importas.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/importas/importas_integration_test.go b/pkg/golinters/importas/importas_integration_test.go new file mode 100644 index 000000000000..42de9e166bc0 --- /dev/null +++ b/pkg/golinters/importas/importas_integration_test.go @@ -0,0 +1,11 @@ +package importas + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/importas.go b/pkg/golinters/importas/testdata/importas.go similarity index 91% rename from test/testdata/importas.go rename to pkg/golinters/importas/testdata/importas.go index 18a43c5e5bec..0fecebc7fce7 100644 --- a/test/testdata/importas.go +++ b/pkg/golinters/importas/testdata/importas.go @@ -1,5 +1,5 @@ //golangcitest:args -Eimportas -//golangcitest:config_path testdata/configs/importas.yml +//golangcitest:config_path testdata/importas.yml package testdata import ( diff --git a/test/testdata/configs/importas.yml b/pkg/golinters/importas/testdata/importas.yml similarity index 100% rename from test/testdata/configs/importas.yml rename to pkg/golinters/importas/testdata/importas.yml diff --git a/test/testdata/importas_strict.go b/pkg/golinters/importas/testdata/importas_strict.go similarity index 91% rename from test/testdata/importas_strict.go rename to pkg/golinters/importas/testdata/importas_strict.go index 76f7fefe5c9c..9d1094406155 100644 --- a/test/testdata/importas_strict.go +++ b/pkg/golinters/importas/testdata/importas_strict.go @@ -1,5 +1,5 @@ //golangcitest:args -Eimportas -//golangcitest:config_path testdata/configs/importas_strict.yml +//golangcitest:config_path testdata/importas_strict.yml package testdata import ( diff --git a/test/testdata/configs/importas_strict.yml b/pkg/golinters/importas/testdata/importas_strict.yml similarity index 100% rename from test/testdata/configs/importas_strict.yml rename to pkg/golinters/importas/testdata/importas_strict.yml diff --git a/pkg/golinters/inamedparam.go b/pkg/golinters/inamedparam/inamedparam.go similarity index 83% rename from pkg/golinters/inamedparam.go rename to pkg/golinters/inamedparam/inamedparam.go index 293716dfd3b0..5cf06a08cc81 100644 --- a/pkg/golinters/inamedparam.go +++ b/pkg/golinters/inamedparam/inamedparam.go @@ -1,4 +1,4 @@ -package golinters +package inamedparam import ( "github.com/macabu/inamedparam" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewINamedParam(settings *config.INamedParamSettings) *goanalysis.Linter { +func New(settings *config.INamedParamSettings) *goanalysis.Linter { a := inamedparam.Analyzer var cfg map[string]map[string]any diff --git a/pkg/golinters/inamedparam/inamedparam_integration_test.go b/pkg/golinters/inamedparam/inamedparam_integration_test.go new file mode 100644 index 000000000000..97235458041e --- /dev/null +++ b/pkg/golinters/inamedparam/inamedparam_integration_test.go @@ -0,0 +1,11 @@ +package inamedparam + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/inamedparam.go b/pkg/golinters/inamedparam/testdata/inamedparam.go similarity index 100% rename from test/testdata/inamedparam.go rename to pkg/golinters/inamedparam/testdata/inamedparam.go diff --git a/test/testdata/inamedparam_skip_single_param.go b/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.go similarity index 84% rename from test/testdata/inamedparam_skip_single_param.go rename to pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.go index 3475f95b7232..cf585863e4dc 100644 --- a/test/testdata/inamedparam_skip_single_param.go +++ b/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.go @@ -1,5 +1,5 @@ //golangcitest:args -Einamedparam -//golangcitest:config_path testdata/configs/inamedparam_skip_single_param.yml +//golangcitest:config_path testdata/inamedparam_skip_single_param.yml package testdata import "context" diff --git a/test/testdata/configs/inamedparam_skip_single_param.yml b/pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml similarity index 100% rename from test/testdata/configs/inamedparam_skip_single_param.yml rename to pkg/golinters/inamedparam/testdata/inamedparam_skip_single_param.yml diff --git a/pkg/golinters/ineffassign.go b/pkg/golinters/ineffassign/ineffassign.go similarity index 85% rename from pkg/golinters/ineffassign.go rename to pkg/golinters/ineffassign/ineffassign.go index e4c2abf711f0..ba86fb90e374 100644 --- a/pkg/golinters/ineffassign.go +++ b/pkg/golinters/ineffassign/ineffassign.go @@ -1,4 +1,4 @@ -package golinters +package ineffassign import ( "github.com/gordonklaus/ineffassign/pkg/ineffassign" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewIneffassign() *goanalysis.Linter { +func New() *goanalysis.Linter { a := ineffassign.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/ineffassign/ineffassign_integration_test.go b/pkg/golinters/ineffassign/ineffassign_integration_test.go new file mode 100644 index 000000000000..d2bfc191bf9e --- /dev/null +++ b/pkg/golinters/ineffassign/ineffassign_integration_test.go @@ -0,0 +1,11 @@ +package ineffassign + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/ineffassign.go b/pkg/golinters/ineffassign/testdata/ineffassign.go similarity index 100% rename from test/testdata/ineffassign.go rename to pkg/golinters/ineffassign/testdata/ineffassign.go diff --git a/pkg/golinters/interfacebloat.go b/pkg/golinters/interfacebloat/interfacebloat.go similarity index 83% rename from pkg/golinters/interfacebloat.go rename to pkg/golinters/interfacebloat/interfacebloat.go index 93dfe338e9f0..88927a3d9bcf 100644 --- a/pkg/golinters/interfacebloat.go +++ b/pkg/golinters/interfacebloat/interfacebloat.go @@ -1,4 +1,4 @@ -package golinters +package interfacebloat import ( "github.com/sashamelentyev/interfacebloat/pkg/analyzer" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewInterfaceBloat(settings *config.InterfaceBloatSettings) *goanalysis.Linter { +func New(settings *config.InterfaceBloatSettings) *goanalysis.Linter { a := analyzer.New() var cfg map[string]map[string]any diff --git a/pkg/golinters/interfacebloat/interfacebloat_integration_test.go b/pkg/golinters/interfacebloat/interfacebloat_integration_test.go new file mode 100644 index 000000000000..031b62f90033 --- /dev/null +++ b/pkg/golinters/interfacebloat/interfacebloat_integration_test.go @@ -0,0 +1,11 @@ +package interfacebloat + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/interfacebloat.go b/pkg/golinters/interfacebloat/testdata/interfacebloat.go similarity index 100% rename from test/testdata/interfacebloat.go rename to pkg/golinters/interfacebloat/testdata/interfacebloat.go diff --git a/pkg/golinters/intrange.go b/pkg/golinters/intrange/intrange.go similarity index 83% rename from pkg/golinters/intrange.go rename to pkg/golinters/intrange/intrange.go index e204087f3dd4..a27569ebbcbe 100644 --- a/pkg/golinters/intrange.go +++ b/pkg/golinters/intrange/intrange.go @@ -1,4 +1,4 @@ -package golinters +package intrange import ( "github.com/ckaznocha/intrange" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewIntrange() *goanalysis.Linter { +func New() *goanalysis.Linter { a := intrange.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/intrange/intrange_integration_test.go b/pkg/golinters/intrange/intrange_integration_test.go new file mode 100644 index 000000000000..1120a2eca5ed --- /dev/null +++ b/pkg/golinters/intrange/intrange_integration_test.go @@ -0,0 +1,11 @@ +package intrange + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/intrange.go b/pkg/golinters/intrange/testdata/intrange.go similarity index 100% rename from test/testdata/intrange.go rename to pkg/golinters/intrange/testdata/intrange.go diff --git a/pkg/golinters/ireturn.go b/pkg/golinters/ireturn/ireturn.go similarity index 86% rename from pkg/golinters/ireturn.go rename to pkg/golinters/ireturn/ireturn.go index 44a72e83f92c..57de57111e0d 100644 --- a/pkg/golinters/ireturn.go +++ b/pkg/golinters/ireturn/ireturn.go @@ -1,4 +1,4 @@ -package golinters +package ireturn import ( "strings" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewIreturn(settings *config.IreturnSettings) *goanalysis.Linter { +func New(settings *config.IreturnSettings) *goanalysis.Linter { a := analyzer.NewAnalyzer() cfg := map[string]map[string]any{} diff --git a/pkg/golinters/ireturn/ireturn_integration_test.go b/pkg/golinters/ireturn/ireturn_integration_test.go new file mode 100644 index 000000000000..05f97a582cd0 --- /dev/null +++ b/pkg/golinters/ireturn/ireturn_integration_test.go @@ -0,0 +1,11 @@ +package ireturn + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/ireturn.go b/pkg/golinters/ireturn/testdata/ireturn.go similarity index 100% rename from test/testdata/ireturn.go rename to pkg/golinters/ireturn/testdata/ireturn.go diff --git a/test/testdata/ireturn_allow.go b/pkg/golinters/ireturn/testdata/ireturn_allow.go similarity index 84% rename from test/testdata/ireturn_allow.go rename to pkg/golinters/ireturn/testdata/ireturn_allow.go index 8a7c6075d098..0dd9f73fdb98 100644 --- a/test/testdata/ireturn_allow.go +++ b/pkg/golinters/ireturn/testdata/ireturn_allow.go @@ -1,5 +1,5 @@ //golangcitest:args -Eireturn -//golangcitest:config_path testdata/configs/ireturn_allow.yml +//golangcitest:config_path testdata/ireturn_allow.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/configs/ireturn_allow.yml b/pkg/golinters/ireturn/testdata/ireturn_allow.yml similarity index 100% rename from test/testdata/configs/ireturn_allow.yml rename to pkg/golinters/ireturn/testdata/ireturn_allow.yml diff --git a/test/testdata/ireturn_reject_generics.go b/pkg/golinters/ireturn/testdata/ireturn_reject_generics.go similarity index 82% rename from test/testdata/ireturn_reject_generics.go rename to pkg/golinters/ireturn/testdata/ireturn_reject_generics.go index ea5be6884c7d..e1fa78eaa8c7 100644 --- a/test/testdata/ireturn_reject_generics.go +++ b/pkg/golinters/ireturn/testdata/ireturn_reject_generics.go @@ -1,5 +1,5 @@ //golangcitest:args -Eireturn -//golangcitest:config_path testdata/configs/ireturn_reject_generics.yml +//golangcitest:config_path testdata/ireturn_reject_generics.yml package testdata import ( diff --git a/test/testdata/configs/ireturn_reject_generics.yml b/pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml similarity index 100% rename from test/testdata/configs/ireturn_reject_generics.yml rename to pkg/golinters/ireturn/testdata/ireturn_reject_generics.yml diff --git a/test/testdata/ireturn_reject_stdlib.go b/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.go similarity index 82% rename from test/testdata/ireturn_reject_stdlib.go rename to pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.go index 3c935b855b7e..063bbe922862 100644 --- a/test/testdata/ireturn_reject_stdlib.go +++ b/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.go @@ -1,5 +1,5 @@ //golangcitest:args -Eireturn -//golangcitest:config_path testdata/configs/ireturn_reject_stdlib.yml +//golangcitest:config_path testdata/ireturn_reject_stdlib.yml package testdata import ( diff --git a/test/testdata/configs/ireturn_reject_stdlib.yml b/pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml similarity index 100% rename from test/testdata/configs/ireturn_reject_stdlib.yml rename to pkg/golinters/ireturn/testdata/ireturn_reject_stdlib.yml diff --git a/pkg/golinters/lll.go b/pkg/golinters/lll/lll.go similarity index 95% rename from pkg/golinters/lll.go rename to pkg/golinters/lll/lll.go index 2c9ae9832811..f0556915236a 100644 --- a/pkg/golinters/lll.go +++ b/pkg/golinters/lll/lll.go @@ -1,4 +1,4 @@ -package golinters +package lll import ( "bufio" @@ -19,16 +19,16 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const lllName = "lll" +const name = "lll" const goCommentDirectivePrefix = "//go:" -func NewLLL(settings *config.LllSettings) *goanalysis.Linter { +func New(settings *config.LllSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: lllName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runLll(pass, settings) @@ -49,7 +49,7 @@ func NewLLL(settings *config.LllSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - lllName, + name, "Reports long lines", []*analysis.Analyzer{analyzer}, nil, @@ -122,7 +122,7 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r Line: lineNumber, }, Text: fmt.Sprintf("line is %d characters", lineLen), - FromLinter: lllName, + FromLinter: name, }) } } @@ -146,7 +146,7 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r Column: 1, }, Text: fmt.Sprintf("line is more than %d characters", bufio.MaxScanTokenSize), - FromLinter: lllName, + FromLinter: name, }) } else { return nil, fmt.Errorf("can't scan file %s: %w", filename, err) diff --git a/pkg/golinters/lll/lll_integration_test.go b/pkg/golinters/lll/lll_integration_test.go new file mode 100644 index 000000000000..25ebf40d9e03 --- /dev/null +++ b/pkg/golinters/lll/lll_integration_test.go @@ -0,0 +1,11 @@ +package lll + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/lll.go b/pkg/golinters/lll/testdata/lll.go similarity index 92% rename from test/testdata/lll.go rename to pkg/golinters/lll/testdata/lll.go index 89a143ab5f9a..729a6cc28809 100644 --- a/test/testdata/lll.go +++ b/pkg/golinters/lll/testdata/lll.go @@ -1,5 +1,5 @@ //golangcitest:args -Elll -//golangcitest:config_path testdata/configs/lll.yml +//golangcitest:config_path testdata/lll.yml package testdata import ( diff --git a/test/testdata/configs/lll.yml b/pkg/golinters/lll/testdata/lll.yml similarity index 100% rename from test/testdata/configs/lll.yml rename to pkg/golinters/lll/testdata/lll.yml diff --git a/test/testdata/configs/lll_import.yml b/pkg/golinters/lll/testdata/lll_import.yml similarity index 100% rename from test/testdata/configs/lll_import.yml rename to pkg/golinters/lll/testdata/lll_import.yml diff --git a/test/testdata/lll_import_multi.go b/pkg/golinters/lll/testdata/lll_import_multi.go similarity index 87% rename from test/testdata/lll_import_multi.go rename to pkg/golinters/lll/testdata/lll_import_multi.go index 4c2ab5ab477e..da39f72ee31f 100644 --- a/test/testdata/lll_import_multi.go +++ b/pkg/golinters/lll/testdata/lll_import_multi.go @@ -1,5 +1,5 @@ //golangcitest:args -Elll -//golangcitest:config_path testdata/configs/lll_import.yml +//golangcitest:config_path testdata/lll_import.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/lll_import_single.go b/pkg/golinters/lll/testdata/lll_import_single.go similarity index 80% rename from test/testdata/lll_import_single.go rename to pkg/golinters/lll/testdata/lll_import_single.go index ed86985aa568..dfd694c40f16 100644 --- a/test/testdata/lll_import_single.go +++ b/pkg/golinters/lll/testdata/lll_import_single.go @@ -1,5 +1,5 @@ //golangcitest:args -Elll -//golangcitest:config_path testdata/configs/lll_import.yml +//golangcitest:config_path testdata/lll_import.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/pkg/golinters/loggercheck.go b/pkg/golinters/loggercheck/loggercheck.go similarity index 90% rename from pkg/golinters/loggercheck.go rename to pkg/golinters/loggercheck/loggercheck.go index a4a63722c8ff..077e8a512f36 100644 --- a/pkg/golinters/loggercheck.go +++ b/pkg/golinters/loggercheck/loggercheck.go @@ -1,4 +1,4 @@ -package golinters +package loggercheck import ( "github.com/timonwong/loggercheck" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewLoggerCheck(settings *config.LoggerCheckSettings) *goanalysis.Linter { +func New(settings *config.LoggerCheckSettings) *goanalysis.Linter { var opts []loggercheck.Option if settings != nil { diff --git a/pkg/golinters/loggercheck/loggercheck_integration_test.go b/pkg/golinters/loggercheck/loggercheck_integration_test.go new file mode 100644 index 000000000000..7bbd1fe295ad --- /dev/null +++ b/pkg/golinters/loggercheck/loggercheck_integration_test.go @@ -0,0 +1,11 @@ +package loggercheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/loggercheck/go.mod b/pkg/golinters/loggercheck/testdata/go.mod similarity index 100% rename from test/testdata/loggercheck/go.mod rename to pkg/golinters/loggercheck/testdata/go.mod diff --git a/test/testdata/loggercheck/go.sum b/pkg/golinters/loggercheck/testdata/go.sum similarity index 100% rename from test/testdata/loggercheck/go.sum rename to pkg/golinters/loggercheck/testdata/go.sum diff --git a/test/testdata/loggercheck/loggercheck_custom.go b/pkg/golinters/loggercheck/testdata/loggercheck_custom.go similarity index 98% rename from test/testdata/loggercheck/loggercheck_custom.go rename to pkg/golinters/loggercheck/testdata/loggercheck_custom.go index 5182d373c1ad..118d70ccd194 100644 --- a/test/testdata/loggercheck/loggercheck_custom.go +++ b/pkg/golinters/loggercheck/testdata/loggercheck_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Eloggercheck -//golangcitest:config_path configs/loggercheck_custom.yml +//golangcitest:config_path testdata/loggercheck_custom.yml package loggercheck import ( diff --git a/test/testdata/loggercheck/configs/loggercheck_custom.yml b/pkg/golinters/loggercheck/testdata/loggercheck_custom.yml similarity index 100% rename from test/testdata/loggercheck/configs/loggercheck_custom.yml rename to pkg/golinters/loggercheck/testdata/loggercheck_custom.yml diff --git a/test/testdata/loggercheck/loggercheck_default.go b/pkg/golinters/loggercheck/testdata/loggercheck_default.go similarity index 100% rename from test/testdata/loggercheck/loggercheck_default.go rename to pkg/golinters/loggercheck/testdata/loggercheck_default.go diff --git a/test/testdata/loggercheck/loggercheck_kitlogonly.go b/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.go similarity index 93% rename from test/testdata/loggercheck/loggercheck_kitlogonly.go rename to pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.go index 50ee68f1d3cb..c9436714a175 100644 --- a/test/testdata/loggercheck/loggercheck_kitlogonly.go +++ b/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.go @@ -1,5 +1,5 @@ //golangcitest:args -Eloggercheck -//golangcitest:config_path configs/loggercheck_kitlogonly.yml +//golangcitest:config_path testdata/loggercheck_kitlogonly.yml package loggercheck import ( diff --git a/test/testdata/loggercheck/configs/loggercheck_kitlogonly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml similarity index 100% rename from test/testdata/loggercheck/configs/loggercheck_kitlogonly.yml rename to pkg/golinters/loggercheck/testdata/loggercheck_kitlogonly.yml diff --git a/test/testdata/loggercheck/loggercheck_logronly.go b/pkg/golinters/loggercheck/testdata/loggercheck_logronly.go similarity index 90% rename from test/testdata/loggercheck/loggercheck_logronly.go rename to pkg/golinters/loggercheck/testdata/loggercheck_logronly.go index 56629705824d..3384b4955a09 100644 --- a/test/testdata/loggercheck/loggercheck_logronly.go +++ b/pkg/golinters/loggercheck/testdata/loggercheck_logronly.go @@ -1,5 +1,5 @@ //golangcitest:args -Eloggercheck -//golangcitest:config_path configs/loggercheck_logronly.yml +//golangcitest:config_path testdata/loggercheck_logronly.yml package loggercheck import ( diff --git a/test/testdata/loggercheck/configs/loggercheck_logronly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml similarity index 100% rename from test/testdata/loggercheck/configs/loggercheck_logronly.yml rename to pkg/golinters/loggercheck/testdata/loggercheck_logronly.yml diff --git a/test/testdata/loggercheck/loggercheck_noprintflike.go b/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.go similarity index 87% rename from test/testdata/loggercheck/loggercheck_noprintflike.go rename to pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.go index de93db4b43f6..7ef5f4a216b4 100644 --- a/test/testdata/loggercheck/loggercheck_noprintflike.go +++ b/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.go @@ -1,5 +1,5 @@ //golangcitest:args -Eloggercheck -//golangcitest:config_path configs/loggercheck_noprintflike.yml +//golangcitest:config_path testdata/loggercheck_noprintflike.yml package loggercheck import ( diff --git a/test/testdata/loggercheck/configs/loggercheck_noprintflike.yml b/pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml similarity index 100% rename from test/testdata/loggercheck/configs/loggercheck_noprintflike.yml rename to pkg/golinters/loggercheck/testdata/loggercheck_noprintflike.yml diff --git a/test/testdata/loggercheck/loggercheck_requirestringkey.go b/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.go similarity index 91% rename from test/testdata/loggercheck/loggercheck_requirestringkey.go rename to pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.go index 5efacca14c69..d86e62624698 100644 --- a/test/testdata/loggercheck/loggercheck_requirestringkey.go +++ b/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.go @@ -1,5 +1,5 @@ //golangcitest:args -Eloggercheck -//golangcitest:config_path configs/loggercheck_requirestringkey.yml +//golangcitest:config_path testdata/loggercheck_requirestringkey.yml package loggercheck import ( diff --git a/test/testdata/loggercheck/configs/loggercheck_requirestringkey.yml b/pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml similarity index 100% rename from test/testdata/loggercheck/configs/loggercheck_requirestringkey.yml rename to pkg/golinters/loggercheck/testdata/loggercheck_requirestringkey.yml diff --git a/test/testdata/loggercheck/loggercheck_zaponly.go b/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.go similarity index 86% rename from test/testdata/loggercheck/loggercheck_zaponly.go rename to pkg/golinters/loggercheck/testdata/loggercheck_zaponly.go index 626a3c27ee75..2d56101b287e 100644 --- a/test/testdata/loggercheck/loggercheck_zaponly.go +++ b/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.go @@ -1,5 +1,5 @@ //golangcitest:args -Eloggercheck -//golangcitest:config_path configs/loggercheck_zaponly.yml +//golangcitest:config_path testdata/loggercheck_zaponly.yml package loggercheck import "go.uber.org/zap" diff --git a/test/testdata/loggercheck/configs/loggercheck_zaponly.yml b/pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml similarity index 100% rename from test/testdata/loggercheck/configs/loggercheck_zaponly.yml rename to pkg/golinters/loggercheck/testdata/loggercheck_zaponly.yml diff --git a/test/testdata/loggercheck/logrlint_compatiblity.go b/pkg/golinters/loggercheck/testdata/logrlint_compatiblity.go similarity index 100% rename from test/testdata/loggercheck/logrlint_compatiblity.go rename to pkg/golinters/loggercheck/testdata/logrlint_compatiblity.go diff --git a/pkg/golinters/maintidx.go b/pkg/golinters/maintidx/maintidx.go similarity index 85% rename from pkg/golinters/maintidx.go rename to pkg/golinters/maintidx/maintidx.go index b5751227bcac..08f12369e641 100644 --- a/pkg/golinters/maintidx.go +++ b/pkg/golinters/maintidx/maintidx.go @@ -1,4 +1,4 @@ -package golinters +package maintidx import ( "github.com/yagipy/maintidx" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewMaintIdx(cfg *config.MaintIdxSettings) *goanalysis.Linter { +func New(cfg *config.MaintIdxSettings) *goanalysis.Linter { analyzer := maintidx.Analyzer cfgMap := map[string]map[string]any{ diff --git a/pkg/golinters/maintidx/maintidx_integration_test.go b/pkg/golinters/maintidx/maintidx_integration_test.go new file mode 100644 index 000000000000..cd8f25cfd20c --- /dev/null +++ b/pkg/golinters/maintidx/maintidx_integration_test.go @@ -0,0 +1,11 @@ +package maintidx + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/maintidx.go b/pkg/golinters/maintidx/testdata/maintidx.go similarity index 100% rename from test/testdata/maintidx.go rename to pkg/golinters/maintidx/testdata/maintidx.go diff --git a/test/testdata/maintidx_under_100.go b/pkg/golinters/maintidx/testdata/maintidx_under_100.go similarity index 97% rename from test/testdata/maintidx_under_100.go rename to pkg/golinters/maintidx/testdata/maintidx_under_100.go index 72af2e3959c4..b0d37b22ab53 100644 --- a/test/testdata/maintidx_under_100.go +++ b/pkg/golinters/maintidx/testdata/maintidx_under_100.go @@ -1,5 +1,5 @@ //golangcitest:args -Emaintidx -//golangcitest:config_path testdata/configs/maintidx_under_100.yml +//golangcitest:config_path testdata/maintidx_under_100.yml package testdata func over20() { // want "Function name: over20, Cyclomatic Complexity: 1, Halstead Volume: 8.00, Maintainability Index: 86" diff --git a/test/testdata/configs/maintidx_under_100.yml b/pkg/golinters/maintidx/testdata/maintidx_under_100.yml similarity index 100% rename from test/testdata/configs/maintidx_under_100.yml rename to pkg/golinters/maintidx/testdata/maintidx_under_100.yml diff --git a/pkg/golinters/makezero.go b/pkg/golinters/makezero/makezero.go similarity index 89% rename from pkg/golinters/makezero.go rename to pkg/golinters/makezero/makezero.go index 9aeb08a60b98..a77ed30a1320 100644 --- a/pkg/golinters/makezero.go +++ b/pkg/golinters/makezero/makezero.go @@ -1,4 +1,4 @@ -package golinters +package makezero import ( "fmt" @@ -13,14 +13,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const makezeroName = "makezero" +const name = "makezero" -func NewMakezero(settings *config.MakezeroSettings) *goanalysis.Linter { +func New(settings *config.MakezeroSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: makezeroName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues, err := runMakeZero(pass, settings) @@ -41,7 +41,7 @@ func NewMakezero(settings *config.MakezeroSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - makezeroName, + name, "Finds slice declarations with non-zero initial length", []*analysis.Analyzer{analyzer}, nil, @@ -65,7 +65,7 @@ func runMakeZero(pass *analysis.Pass, settings *config.MakezeroSettings) ([]goan issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: hint.Position(), Text: hint.Details(), - FromLinter: makezeroName, + FromLinter: name, }, pass)) } } diff --git a/pkg/golinters/makezero/makezero_integration_test.go b/pkg/golinters/makezero/makezero_integration_test.go new file mode 100644 index 000000000000..388077d8d24d --- /dev/null +++ b/pkg/golinters/makezero/makezero_integration_test.go @@ -0,0 +1,11 @@ +package makezero + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/makezero.go b/pkg/golinters/makezero/testdata/makezero.go similarity index 100% rename from test/testdata/makezero.go rename to pkg/golinters/makezero/testdata/makezero.go diff --git a/test/testdata/makezero_always.go b/pkg/golinters/makezero/testdata/makezero_always.go similarity index 83% rename from test/testdata/makezero_always.go rename to pkg/golinters/makezero/testdata/makezero_always.go index 80396b446074..9b96134402cd 100644 --- a/test/testdata/makezero_always.go +++ b/pkg/golinters/makezero/testdata/makezero_always.go @@ -1,5 +1,5 @@ //golangcitest:args -Emakezero -//golangcitest:config_path testdata/configs/makezero_always.yml +//golangcitest:config_path testdata/makezero_always.yml package testdata import "math" diff --git a/test/testdata/configs/makezero_always.yml b/pkg/golinters/makezero/testdata/makezero_always.yml similarity index 100% rename from test/testdata/configs/makezero_always.yml rename to pkg/golinters/makezero/testdata/makezero_always.yml diff --git a/pkg/golinters/mirror.go b/pkg/golinters/mirror/mirror.go similarity index 96% rename from pkg/golinters/mirror.go rename to pkg/golinters/mirror/mirror.go index 3d5766fe8eaa..34b880b5295f 100644 --- a/pkg/golinters/mirror.go +++ b/pkg/golinters/mirror/mirror.go @@ -1,4 +1,4 @@ -package golinters +package mirror import ( "sync" @@ -11,7 +11,7 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -func NewMirror() *goanalysis.Linter { +func New() *goanalysis.Linter { var ( mu sync.Mutex issues []goanalysis.Issue diff --git a/pkg/golinters/mirror/mirror_integration_test.go b/pkg/golinters/mirror/mirror_integration_test.go new file mode 100644 index 000000000000..926e3ea125db --- /dev/null +++ b/pkg/golinters/mirror/mirror_integration_test.go @@ -0,0 +1,19 @@ +package mirror + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/in/mirror.go b/pkg/golinters/mirror/testdata/fix/in/mirror.go similarity index 100% rename from test/testdata/fix/in/mirror.go rename to pkg/golinters/mirror/testdata/fix/in/mirror.go diff --git a/test/testdata/fix/out/mirror.go b/pkg/golinters/mirror/testdata/fix/out/mirror.go similarity index 100% rename from test/testdata/fix/out/mirror.go rename to pkg/golinters/mirror/testdata/fix/out/mirror.go diff --git a/test/testdata/mirror.go b/pkg/golinters/mirror/testdata/mirror.go similarity index 100% rename from test/testdata/mirror.go rename to pkg/golinters/mirror/testdata/mirror.go diff --git a/pkg/golinters/misspell.go b/pkg/golinters/misspell/misspell.go similarity index 96% rename from pkg/golinters/misspell.go rename to pkg/golinters/misspell/misspell.go index 70ee5602c0dc..5d07817cd203 100644 --- a/pkg/golinters/misspell.go +++ b/pkg/golinters/misspell/misspell.go @@ -1,4 +1,4 @@ -package golinters +package misspell import ( "fmt" @@ -17,20 +17,20 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const misspellName = "misspell" +const name = "misspell" -func NewMisspell(settings *config.MisspellSettings) *goanalysis.Linter { +func New(settings *config.MisspellSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: misspellName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: goanalysis.DummyRun, } return goanalysis.NewLinter( - misspellName, + name, "Finds commonly misspelled English words", []*analysis.Analyzer{analyzer}, nil, @@ -153,7 +153,7 @@ func runMisspellOnFile(lintCtx *linter.Context, filename string, replacer *missp res = append(res, result.Issue{ Pos: pos, Text: text, - FromLinter: misspellName, + FromLinter: name, Replacement: replacement, }) } diff --git a/pkg/golinters/misspell/misspell_integration_test.go b/pkg/golinters/misspell/misspell_integration_test.go new file mode 100644 index 000000000000..f211f9c04795 --- /dev/null +++ b/pkg/golinters/misspell/misspell_integration_test.go @@ -0,0 +1,19 @@ +package misspell + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/pkg/golinters/misspell_test.go b/pkg/golinters/misspell/misspell_test.go similarity index 99% rename from pkg/golinters/misspell_test.go rename to pkg/golinters/misspell/misspell_test.go index 5c590ef97e5c..3766d1799224 100644 --- a/pkg/golinters/misspell_test.go +++ b/pkg/golinters/misspell/misspell_test.go @@ -1,4 +1,4 @@ -package golinters +package misspell import ( "testing" diff --git a/test/testdata/fix/in/misspell.go b/pkg/golinters/misspell/testdata/fix/in/misspell.go similarity index 100% rename from test/testdata/fix/in/misspell.go rename to pkg/golinters/misspell/testdata/fix/in/misspell.go diff --git a/test/testdata/fix/out/misspell.go b/pkg/golinters/misspell/testdata/fix/out/misspell.go similarity index 100% rename from test/testdata/fix/out/misspell.go rename to pkg/golinters/misspell/testdata/fix/out/misspell.go diff --git a/test/testdata/misspell.go b/pkg/golinters/misspell/testdata/misspell.go similarity index 83% rename from test/testdata/misspell.go rename to pkg/golinters/misspell/testdata/misspell.go index 7646066e9b7e..829e8dcd10e8 100644 --- a/test/testdata/misspell.go +++ b/pkg/golinters/misspell/testdata/misspell.go @@ -1,5 +1,5 @@ //golangcitest:args -Emisspell -//golangcitest:config_path testdata/configs/misspell.yml +//golangcitest:config_path testdata/misspell.yml package testdata func Misspell() { diff --git a/test/testdata/configs/misspell.yml b/pkg/golinters/misspell/testdata/misspell.yml similarity index 100% rename from test/testdata/configs/misspell.yml rename to pkg/golinters/misspell/testdata/misspell.yml diff --git a/test/testdata/misspell_custom.go b/pkg/golinters/misspell/testdata/misspell_custom.go similarity index 85% rename from test/testdata/misspell_custom.go rename to pkg/golinters/misspell/testdata/misspell_custom.go index 32362fb636a1..d1b294dd2322 100644 --- a/test/testdata/misspell_custom.go +++ b/pkg/golinters/misspell/testdata/misspell_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Emisspell -//golangcitest:config_path testdata/configs/misspell_custom.yml +//golangcitest:config_path testdata/misspell_custom.yml package testdata func Misspell() { diff --git a/test/testdata/configs/misspell_custom.yml b/pkg/golinters/misspell/testdata/misspell_custom.yml similarity index 100% rename from test/testdata/configs/misspell_custom.yml rename to pkg/golinters/misspell/testdata/misspell_custom.yml diff --git a/pkg/golinters/mnd.go b/pkg/golinters/mnd/mnd.go similarity index 95% rename from pkg/golinters/mnd.go rename to pkg/golinters/mnd/mnd.go index aa2016061087..ee73c535b65e 100644 --- a/pkg/golinters/mnd.go +++ b/pkg/golinters/mnd/mnd.go @@ -1,4 +1,4 @@ -package golinters +package mnd import ( mnd "github.com/tommy-muehle/go-mnd/v2" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewMND(settings *config.MndSettings) *goanalysis.Linter { +func New(settings *config.MndSettings) *goanalysis.Linter { return newMND(mnd.Analyzer, settings, nil) } diff --git a/pkg/golinters/mnd/mnd_integration_test.go b/pkg/golinters/mnd/mnd_integration_test.go new file mode 100644 index 000000000000..b0c15f50fd30 --- /dev/null +++ b/pkg/golinters/mnd/mnd_integration_test.go @@ -0,0 +1,11 @@ +package mnd + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/mnd.go b/pkg/golinters/mnd/testdata/mnd.go similarity index 100% rename from test/testdata/mnd.go rename to pkg/golinters/mnd/testdata/mnd.go diff --git a/pkg/golinters/musttag.go b/pkg/golinters/musttag/musttag.go similarity index 85% rename from pkg/golinters/musttag.go rename to pkg/golinters/musttag/musttag.go index 9b97ed4f3ac6..30047abfc2a9 100644 --- a/pkg/golinters/musttag.go +++ b/pkg/golinters/musttag/musttag.go @@ -1,4 +1,4 @@ -package golinters +package musttag import ( "go-simpler.org/musttag" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewMustTag(setting *config.MustTagSettings) *goanalysis.Linter { +func New(setting *config.MustTagSettings) *goanalysis.Linter { var funcs []musttag.Func if setting != nil { diff --git a/pkg/golinters/musttag/musttag_integration_test.go b/pkg/golinters/musttag/musttag_integration_test.go new file mode 100644 index 000000000000..fcb4643fd4c9 --- /dev/null +++ b/pkg/golinters/musttag/musttag_integration_test.go @@ -0,0 +1,11 @@ +package musttag + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/musttag.go b/pkg/golinters/musttag/testdata/musttag.go similarity index 100% rename from test/testdata/musttag.go rename to pkg/golinters/musttag/testdata/musttag.go diff --git a/test/testdata/configs/musttag.yml b/pkg/golinters/musttag/testdata/musttag.yml similarity index 100% rename from test/testdata/configs/musttag.yml rename to pkg/golinters/musttag/testdata/musttag.yml diff --git a/test/testdata/musttag_custom.go b/pkg/golinters/musttag/testdata/musttag_custom.go similarity index 90% rename from test/testdata/musttag_custom.go rename to pkg/golinters/musttag/testdata/musttag_custom.go index 0e6f820252b9..07fa55cd0cbb 100644 --- a/test/testdata/musttag_custom.go +++ b/pkg/golinters/musttag/testdata/musttag_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Emusttag -//golangcitest:config_path testdata/configs/musttag.yml +//golangcitest:config_path testdata/musttag.yml package testdata import ( diff --git a/pkg/golinters/nakedret.go b/pkg/golinters/nakedret/nakedret.go similarity index 82% rename from pkg/golinters/nakedret.go rename to pkg/golinters/nakedret/nakedret.go index 0831458042b7..4dd3fd4c3fd7 100644 --- a/pkg/golinters/nakedret.go +++ b/pkg/golinters/nakedret/nakedret.go @@ -1,4 +1,4 @@ -package golinters +package nakedret import ( "github.com/alexkohler/nakedret/v2" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewNakedret(settings *config.NakedretSettings) *goanalysis.Linter { +func New(settings *config.NakedretSettings) *goanalysis.Linter { var maxLines int if settings != nil { maxLines = settings.MaxFuncLines diff --git a/pkg/golinters/nakedret/nakedret_integration_test.go b/pkg/golinters/nakedret/nakedret_integration_test.go new file mode 100644 index 000000000000..2c081425adce --- /dev/null +++ b/pkg/golinters/nakedret/nakedret_integration_test.go @@ -0,0 +1,11 @@ +package nakedret + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/nakedret.go b/pkg/golinters/nakedret/testdata/nakedret.go similarity index 100% rename from test/testdata/nakedret.go rename to pkg/golinters/nakedret/testdata/nakedret.go diff --git a/pkg/golinters/nestif.go b/pkg/golinters/nestif/nestif.go similarity index 91% rename from pkg/golinters/nestif.go rename to pkg/golinters/nestif/nestif.go index 4daad31cdeb6..2ee3d500e7e1 100644 --- a/pkg/golinters/nestif.go +++ b/pkg/golinters/nestif/nestif.go @@ -1,4 +1,4 @@ -package golinters +package nestif import ( "sort" @@ -13,9 +13,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const nestifName = "nestif" +const name = "nestif" -func NewNestif(settings *config.NestifSettings) *goanalysis.Linter { +func New(settings *config.NestifSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -38,7 +38,7 @@ func NewNestif(settings *config.NestifSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - nestifName, + name, "Reports deeply nested if statements", []*analysis.Analyzer{analyzer}, nil, @@ -70,7 +70,7 @@ func runNestIf(pass *analysis.Pass, settings *config.NestifSettings) []goanalysi issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: i.Pos, Text: i.Message, - FromLinter: nestifName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/nestif/nestif_integration_test.go b/pkg/golinters/nestif/nestif_integration_test.go new file mode 100644 index 000000000000..b9fde385df1e --- /dev/null +++ b/pkg/golinters/nestif/nestif_integration_test.go @@ -0,0 +1,11 @@ +package nestif + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/nestif.go b/pkg/golinters/nestif/testdata/nestif.go similarity index 93% rename from test/testdata/nestif.go rename to pkg/golinters/nestif/testdata/nestif.go index e930f13c4e51..cfd4f0408795 100644 --- a/test/testdata/nestif.go +++ b/pkg/golinters/nestif/testdata/nestif.go @@ -1,5 +1,5 @@ //golangcitest:args -Enestif -//golangcitest:config_path testdata/configs/nestif.yml +//golangcitest:config_path testdata/nestif.yml package testdata func _() { diff --git a/test/testdata/configs/nestif.yml b/pkg/golinters/nestif/testdata/nestif.yml similarity index 100% rename from test/testdata/configs/nestif.yml rename to pkg/golinters/nestif/testdata/nestif.yml diff --git a/pkg/golinters/nilerr.go b/pkg/golinters/nilerr/nilerr.go similarity index 86% rename from pkg/golinters/nilerr.go rename to pkg/golinters/nilerr/nilerr.go index 79d86b55a4fc..c9e466905e86 100644 --- a/pkg/golinters/nilerr.go +++ b/pkg/golinters/nilerr/nilerr.go @@ -1,4 +1,4 @@ -package golinters +package nilerr import ( "github.com/gostaticanalysis/nilerr" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewNilErr() *goanalysis.Linter { +func New() *goanalysis.Linter { a := nilerr.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/nilerr/nilerr_integration_test.go b/pkg/golinters/nilerr/nilerr_integration_test.go new file mode 100644 index 000000000000..500c472664f2 --- /dev/null +++ b/pkg/golinters/nilerr/nilerr_integration_test.go @@ -0,0 +1,11 @@ +package nilerr + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/nilerr.go b/pkg/golinters/nilerr/testdata/nilerr.go similarity index 100% rename from test/testdata/nilerr.go rename to pkg/golinters/nilerr/testdata/nilerr.go diff --git a/pkg/golinters/nilnil.go b/pkg/golinters/nilnil/nilnil.go similarity index 87% rename from pkg/golinters/nilnil.go rename to pkg/golinters/nilnil/nilnil.go index 539a65768168..c9237035d331 100644 --- a/pkg/golinters/nilnil.go +++ b/pkg/golinters/nilnil/nilnil.go @@ -1,4 +1,4 @@ -package golinters +package nilnil import ( "strings" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewNilNil(cfg *config.NilNilSettings) *goanalysis.Linter { +func New(cfg *config.NilNilSettings) *goanalysis.Linter { a := analyzer.New() cfgMap := make(map[string]map[string]any) diff --git a/pkg/golinters/nilnil/nilnil_integration_test.go b/pkg/golinters/nilnil/nilnil_integration_test.go new file mode 100644 index 000000000000..175ea4f6eec5 --- /dev/null +++ b/pkg/golinters/nilnil/nilnil_integration_test.go @@ -0,0 +1,11 @@ +package nilnil + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/nilnil.go b/pkg/golinters/nilnil/testdata/nilnil.go similarity index 100% rename from test/testdata/nilnil.go rename to pkg/golinters/nilnil/testdata/nilnil.go diff --git a/pkg/golinters/nlreturn.go b/pkg/golinters/nlreturn/nlreturn.go similarity index 86% rename from pkg/golinters/nlreturn.go rename to pkg/golinters/nlreturn/nlreturn.go index a7a65e2a37c0..509218808501 100644 --- a/pkg/golinters/nlreturn.go +++ b/pkg/golinters/nlreturn/nlreturn.go @@ -1,4 +1,4 @@ -package golinters +package nlreturn import ( "github.com/ssgreg/nlreturn/v2/pkg/nlreturn" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewNLReturn(settings *config.NlreturnSettings) *goanalysis.Linter { +func New(settings *config.NlreturnSettings) *goanalysis.Linter { a := nlreturn.NewAnalyzer() cfg := map[string]map[string]any{} diff --git a/pkg/golinters/nlreturn/nlreturn_integration_test.go b/pkg/golinters/nlreturn/nlreturn_integration_test.go new file mode 100644 index 000000000000..edb97def4db8 --- /dev/null +++ b/pkg/golinters/nlreturn/nlreturn_integration_test.go @@ -0,0 +1,11 @@ +package nlreturn + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/nlreturn-block-size.go b/pkg/golinters/nlreturn/testdata/nlreturn-block-size.go similarity index 82% rename from test/testdata/nlreturn-block-size.go rename to pkg/golinters/nlreturn/testdata/nlreturn-block-size.go index 85cac5398192..d58ad81c57cf 100644 --- a/test/testdata/nlreturn-block-size.go +++ b/pkg/golinters/nlreturn/testdata/nlreturn-block-size.go @@ -1,5 +1,5 @@ //golangcitest:args -Enlreturn -//golangcitest:config_path testdata/configs/nlreturn.yml +//golangcitest:config_path testdata/nlreturn.yml package testdata func foo0(n int) int { diff --git a/test/testdata/nlreturn.go b/pkg/golinters/nlreturn/testdata/nlreturn.go similarity index 100% rename from test/testdata/nlreturn.go rename to pkg/golinters/nlreturn/testdata/nlreturn.go diff --git a/test/testdata/configs/nlreturn.yml b/pkg/golinters/nlreturn/testdata/nlreturn.yml similarity index 100% rename from test/testdata/configs/nlreturn.yml rename to pkg/golinters/nlreturn/testdata/nlreturn.yml diff --git a/pkg/golinters/noctx.go b/pkg/golinters/noctx/noctx.go similarity index 85% rename from pkg/golinters/noctx.go rename to pkg/golinters/noctx/noctx.go index e62f6cbf373a..8a063c613c31 100644 --- a/pkg/golinters/noctx.go +++ b/pkg/golinters/noctx/noctx.go @@ -1,4 +1,4 @@ -package golinters +package noctx import ( "github.com/sonatard/noctx" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewNoctx() *goanalysis.Linter { +func New() *goanalysis.Linter { a := noctx.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/noctx/noctx_integration_test.go b/pkg/golinters/noctx/noctx_integration_test.go new file mode 100644 index 000000000000..e9116cc90f2e --- /dev/null +++ b/pkg/golinters/noctx/noctx_integration_test.go @@ -0,0 +1,11 @@ +package noctx + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/noctx.go b/pkg/golinters/noctx/testdata/noctx.go similarity index 100% rename from test/testdata/noctx.go rename to pkg/golinters/noctx/testdata/noctx.go diff --git a/pkg/golinters/nolintlint.go b/pkg/golinters/nolintlint.go deleted file mode 100644 index 8ed2dceb9342..000000000000 --- a/pkg/golinters/nolintlint.go +++ /dev/null @@ -1,104 +0,0 @@ -package golinters - -import ( - "fmt" - "go/ast" - "sync" - - "golang.org/x/tools/go/analysis" - - "github.com/golangci/golangci-lint/pkg/config" - "github.com/golangci/golangci-lint/pkg/goanalysis" - "github.com/golangci/golangci-lint/pkg/golinters/nolintlint" - "github.com/golangci/golangci-lint/pkg/lint/linter" - "github.com/golangci/golangci-lint/pkg/result" -) - -const NoLintLintName = "nolintlint" - -func NewNoLintLint(settings *config.NoLintLintSettings) *goanalysis.Linter { - var mu sync.Mutex - var resIssues []goanalysis.Issue - - analyzer := &analysis.Analyzer{ - Name: NoLintLintName, - Doc: goanalysis.TheOnlyanalyzerDoc, - Run: func(pass *analysis.Pass) (any, error) { - issues, err := runNoLintLint(pass, settings) - if err != nil { - return nil, err - } - - if len(issues) == 0 { - return nil, nil - } - - mu.Lock() - resIssues = append(resIssues, issues...) - mu.Unlock() - - return nil, nil - }, - } - - return goanalysis.NewLinter( - NoLintLintName, - "Reports ill-formed or insufficient nolint directives", - []*analysis.Analyzer{analyzer}, - nil, - ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { - return resIssues - }).WithLoadMode(goanalysis.LoadModeSyntax) -} - -func runNoLintLint(pass *analysis.Pass, settings *config.NoLintLintSettings) ([]goanalysis.Issue, error) { - var needs nolintlint.Needs - if settings.RequireExplanation { - needs |= nolintlint.NeedsExplanation - } - if settings.RequireSpecific { - needs |= nolintlint.NeedsSpecific - } - if !settings.AllowUnused { - needs |= nolintlint.NeedsUnused - } - - lnt, err := nolintlint.NewLinter(needs, settings.AllowNoExplanation) - if err != nil { - return nil, err - } - - nodes := make([]ast.Node, 0, len(pass.Files)) - for _, n := range pass.Files { - nodes = append(nodes, n) - } - - lintIssues, err := lnt.Run(pass.Fset, nodes...) - if err != nil { - return nil, fmt.Errorf("linter failed to run: %w", err) - } - - var issues []goanalysis.Issue - - for _, i := range lintIssues { - expectNoLint := false - var expectedNolintLinter string - if ii, ok := i.(nolintlint.UnusedCandidate); ok { - expectedNolintLinter = ii.ExpectedLinter - expectNoLint = true - } - - issue := &result.Issue{ - FromLinter: NoLintLintName, - Text: i.Details(), - Pos: i.Position(), - ExpectNoLint: expectNoLint, - ExpectedNoLintLinter: expectedNolintLinter, - Replacement: i.Replacement(), - } - - issues = append(issues, goanalysis.NewIssue(issue, pass)) - } - - return issues, nil -} diff --git a/pkg/golinters/nolintlint/README.md b/pkg/golinters/nolintlint/internal/README.md similarity index 100% rename from pkg/golinters/nolintlint/README.md rename to pkg/golinters/nolintlint/internal/README.md diff --git a/pkg/golinters/nolintlint/internal/nolintlint.go b/pkg/golinters/nolintlint/internal/nolintlint.go new file mode 100644 index 000000000000..5fed41cfdfbb --- /dev/null +++ b/pkg/golinters/nolintlint/internal/nolintlint.go @@ -0,0 +1,304 @@ +// Package internal provides a linter to ensure that all //nolint directives are followed by explanations +package internal + +import ( + "fmt" + "go/ast" + "go/token" + "regexp" + "strings" + "unicode" + + "github.com/golangci/golangci-lint/pkg/result" +) + +type BaseIssue struct { + fullDirective string + directiveWithOptionalLeadingSpace string + position token.Position + replacement *result.Replacement +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (b BaseIssue) Position() token.Position { + return b.position +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (b BaseIssue) Replacement() *result.Replacement { + return b.replacement +} + +type ExtraLeadingSpace struct { + BaseIssue +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (i ExtraLeadingSpace) Details() string { + return fmt.Sprintf("directive `%s` should not have more than one leading space", i.fullDirective) +} + +func (i ExtraLeadingSpace) String() string { return toString(i) } + +type NotMachine struct { + BaseIssue +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (i NotMachine) Details() string { + expected := i.fullDirective[:2] + strings.TrimLeftFunc(i.fullDirective[2:], unicode.IsSpace) + return fmt.Sprintf("directive `%s` should be written without leading space as `%s`", + i.fullDirective, expected) +} + +func (i NotMachine) String() string { return toString(i) } + +type NotSpecific struct { + BaseIssue +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (i NotSpecific) Details() string { + return fmt.Sprintf("directive `%s` should mention specific linter such as `%s:my-linter`", + i.fullDirective, i.directiveWithOptionalLeadingSpace) +} + +func (i NotSpecific) String() string { return toString(i) } + +type ParseError struct { + BaseIssue +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (i ParseError) Details() string { + return fmt.Sprintf("directive `%s` should match `%s[:] [// ]`", + i.fullDirective, + i.directiveWithOptionalLeadingSpace) +} + +func (i ParseError) String() string { return toString(i) } + +type NoExplanation struct { + BaseIssue + fullDirectiveWithoutExplanation string +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (i NoExplanation) Details() string { + return fmt.Sprintf("directive `%s` should provide explanation such as `%s // this is why`", + i.fullDirective, i.fullDirectiveWithoutExplanation) +} + +func (i NoExplanation) String() string { return toString(i) } + +type UnusedCandidate struct { + BaseIssue + ExpectedLinter string +} + +//nolint:gocritic // TODO(ldez) must be change in the future. +func (i UnusedCandidate) Details() string { + details := fmt.Sprintf("directive `%s` is unused", i.fullDirective) + if i.ExpectedLinter != "" { + details += fmt.Sprintf(" for linter %q", i.ExpectedLinter) + } + return details +} + +func (i UnusedCandidate) String() string { return toString(i) } + +func toString(issue Issue) string { + return fmt.Sprintf("%s at %s", issue.Details(), issue.Position()) +} + +type Issue interface { + Details() string + Position() token.Position + String() string + Replacement() *result.Replacement +} + +type Needs uint + +const ( + NeedsMachineOnly Needs = 1 << iota + NeedsSpecific + NeedsExplanation + NeedsUnused + NeedsAll = NeedsMachineOnly | NeedsSpecific | NeedsExplanation +) + +var commentPattern = regexp.MustCompile(`^//\s*(nolint)(:\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*)?\b`) + +// matches a complete nolint directive +var fullDirectivePattern = regexp.MustCompile(`^//\s*nolint(?::(\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*))?\s*(//.*)?\s*\n?$`) + +type Linter struct { + needs Needs // indicates which linter checks to perform + excludeByLinter map[string]bool +} + +// NewLinter creates a linter that enforces that the provided directives fulfill the provided requirements +func NewLinter(needs Needs, excludes []string) (*Linter, error) { + excludeByName := make(map[string]bool) + for _, e := range excludes { + excludeByName[e] = true + } + + return &Linter{ + needs: needs | NeedsMachineOnly, + excludeByLinter: excludeByName, + }, nil +} + +var ( + leadingSpacePattern = regexp.MustCompile(`^//(\s*)`) + trailingBlankExplanation = regexp.MustCompile(`\s*(//\s*)?$`) +) + +//nolint:funlen,gocyclo // the function is going to be refactored in the future +func (l Linter) Run(fset *token.FileSet, nodes ...ast.Node) ([]Issue, error) { + var issues []Issue + + for _, node := range nodes { + file, ok := node.(*ast.File) + if !ok { + continue + } + + for _, c := range file.Comments { + for _, comment := range c.List { + if !commentPattern.MatchString(comment.Text) { + continue + } + + // check for a space between the "//" and the directive + leadingSpaceMatches := leadingSpacePattern.FindStringSubmatch(comment.Text) + + var leadingSpace string + if len(leadingSpaceMatches) > 0 { + leadingSpace = leadingSpaceMatches[1] + } + + directiveWithOptionalLeadingSpace := "//" + if leadingSpace != "" { + directiveWithOptionalLeadingSpace += " " + } + + split := strings.Split(strings.SplitN(comment.Text, ":", 2)[0], "//") + directiveWithOptionalLeadingSpace += strings.TrimSpace(split[1]) + + pos := fset.Position(comment.Pos()) + end := fset.Position(comment.End()) + + base := BaseIssue{ + fullDirective: comment.Text, + directiveWithOptionalLeadingSpace: directiveWithOptionalLeadingSpace, + position: pos, + } + + // check for, report and eliminate leading spaces, so we can check for other issues + if leadingSpace != "" { + removeWhitespace := &result.Replacement{ + Inline: &result.InlineFix{ + StartCol: pos.Column + 1, + Length: len(leadingSpace), + NewString: "", + }, + } + if (l.needs & NeedsMachineOnly) != 0 { + issue := NotMachine{BaseIssue: base} + issue.BaseIssue.replacement = removeWhitespace + issues = append(issues, issue) + } else if len(leadingSpace) > 1 { + issue := ExtraLeadingSpace{BaseIssue: base} + issue.BaseIssue.replacement = removeWhitespace + issue.BaseIssue.replacement.Inline.NewString = " " // assume a single space was intended + issues = append(issues, issue) + } + } + + fullMatches := fullDirectivePattern.FindStringSubmatch(comment.Text) + if len(fullMatches) == 0 { + issues = append(issues, ParseError{BaseIssue: base}) + continue + } + + lintersText, explanation := fullMatches[1], fullMatches[2] + + var linters []string + if lintersText != "" && !strings.HasPrefix(lintersText, "all") { + lls := strings.Split(lintersText, ",") + linters = make([]string, 0, len(lls)) + rangeStart := (pos.Column - 1) + len("//") + len(leadingSpace) + len("nolint:") + for i, ll := range lls { + rangeEnd := rangeStart + len(ll) + if i < len(lls)-1 { + rangeEnd++ // include trailing comma + } + trimmedLinterName := strings.TrimSpace(ll) + if trimmedLinterName != "" { + linters = append(linters, trimmedLinterName) + } + rangeStart = rangeEnd + } + } + + if (l.needs & NeedsSpecific) != 0 { + if len(linters) == 0 { + issues = append(issues, NotSpecific{BaseIssue: base}) + } + } + + // when detecting unused directives, we send all the directives through and filter them out in the nolint processor + if (l.needs & NeedsUnused) != 0 { + removeNolintCompletely := &result.Replacement{ + Inline: &result.InlineFix{ + StartCol: pos.Column - 1, + Length: end.Column - pos.Column, + NewString: "", + }, + } + + if len(linters) == 0 { + issue := UnusedCandidate{BaseIssue: base} + issue.replacement = removeNolintCompletely + issues = append(issues, issue) + } else { + for _, linter := range linters { + issue := UnusedCandidate{BaseIssue: base, ExpectedLinter: linter} + // only offer replacement if there is a single linter + // because of issues around commas and the possibility of all + // linters being removed + if len(linters) == 1 { + issue.replacement = removeNolintCompletely + } + issues = append(issues, issue) + } + } + } + + if (l.needs&NeedsExplanation) != 0 && (explanation == "" || strings.TrimSpace(explanation) == "//") { + needsExplanation := len(linters) == 0 // if no linters are mentioned, we must have explanation + // otherwise, check if we are excluding all the mentioned linters + for _, ll := range linters { + if !l.excludeByLinter[ll] { // if a linter does require explanation + needsExplanation = true + break + } + } + + if needsExplanation { + fullDirectiveWithoutExplanation := trailingBlankExplanation.ReplaceAllString(comment.Text, "") + issues = append(issues, NoExplanation{ + BaseIssue: base, + fullDirectiveWithoutExplanation: fullDirectiveWithoutExplanation, + }) + } + } + } + } + } + + return issues, nil +} diff --git a/pkg/golinters/nolintlint/nolintlint_test.go b/pkg/golinters/nolintlint/internal/nolintlint_test.go similarity index 99% rename from pkg/golinters/nolintlint/nolintlint_test.go rename to pkg/golinters/nolintlint/internal/nolintlint_test.go index a483c7ea66b1..1c6d7d89b03f 100644 --- a/pkg/golinters/nolintlint/nolintlint_test.go +++ b/pkg/golinters/nolintlint/internal/nolintlint_test.go @@ -1,4 +1,4 @@ -package nolintlint +package internal import ( "go/parser" diff --git a/pkg/golinters/nolintlint/nolintlint.go b/pkg/golinters/nolintlint/nolintlint.go index 1bce5ef5d2d8..507d65ab8f9d 100644 --- a/pkg/golinters/nolintlint/nolintlint.go +++ b/pkg/golinters/nolintlint/nolintlint.go @@ -1,303 +1,103 @@ -// Package nolintlint provides a linter to ensure that all //nolint directives are followed by explanations package nolintlint import ( "fmt" "go/ast" - "go/token" - "regexp" - "strings" - "unicode" + "sync" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/pkg/config" + "github.com/golangci/golangci-lint/pkg/goanalysis" + "github.com/golangci/golangci-lint/pkg/golinters/nolintlint/internal" + "github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/result" ) -type BaseIssue struct { - fullDirective string - directiveWithOptionalLeadingSpace string - position token.Position - replacement *result.Replacement -} +const Name = "nolintlint" -//nolint:gocritic // TODO(ldez) must be change in the future. -func (b BaseIssue) Position() token.Position { - return b.position -} - -//nolint:gocritic // TODO(ldez) must be change in the future. -func (b BaseIssue) Replacement() *result.Replacement { - return b.replacement -} - -type ExtraLeadingSpace struct { - BaseIssue -} - -//nolint:gocritic // TODO(ldez) must be change in the future. -func (i ExtraLeadingSpace) Details() string { - return fmt.Sprintf("directive `%s` should not have more than one leading space", i.fullDirective) -} - -func (i ExtraLeadingSpace) String() string { return toString(i) } - -type NotMachine struct { - BaseIssue -} - -//nolint:gocritic // TODO(ldez) must be change in the future. -func (i NotMachine) Details() string { - expected := i.fullDirective[:2] + strings.TrimLeftFunc(i.fullDirective[2:], unicode.IsSpace) - return fmt.Sprintf("directive `%s` should be written without leading space as `%s`", - i.fullDirective, expected) -} - -func (i NotMachine) String() string { return toString(i) } - -type NotSpecific struct { - BaseIssue -} +func New(settings *config.NoLintLintSettings) *goanalysis.Linter { + var mu sync.Mutex + var resIssues []goanalysis.Issue -//nolint:gocritic // TODO(ldez) must be change in the future. -func (i NotSpecific) Details() string { - return fmt.Sprintf("directive `%s` should mention specific linter such as `%s:my-linter`", - i.fullDirective, i.directiveWithOptionalLeadingSpace) -} - -func (i NotSpecific) String() string { return toString(i) } - -type ParseError struct { - BaseIssue -} - -//nolint:gocritic // TODO(ldez) must be change in the future. -func (i ParseError) Details() string { - return fmt.Sprintf("directive `%s` should match `%s[:] [// ]`", - i.fullDirective, - i.directiveWithOptionalLeadingSpace) -} - -func (i ParseError) String() string { return toString(i) } - -type NoExplanation struct { - BaseIssue - fullDirectiveWithoutExplanation string -} - -//nolint:gocritic // TODO(ldez) must be change in the future. -func (i NoExplanation) Details() string { - return fmt.Sprintf("directive `%s` should provide explanation such as `%s // this is why`", - i.fullDirective, i.fullDirectiveWithoutExplanation) -} + analyzer := &analysis.Analyzer{ + Name: Name, + Doc: goanalysis.TheOnlyanalyzerDoc, + Run: func(pass *analysis.Pass) (any, error) { + issues, err := runNoLintLint(pass, settings) + if err != nil { + return nil, err + } -func (i NoExplanation) String() string { return toString(i) } + if len(issues) == 0 { + return nil, nil + } -type UnusedCandidate struct { - BaseIssue - ExpectedLinter string -} + mu.Lock() + resIssues = append(resIssues, issues...) + mu.Unlock() -//nolint:gocritic // TODO(ldez) must be change in the future. -func (i UnusedCandidate) Details() string { - details := fmt.Sprintf("directive `%s` is unused", i.fullDirective) - if i.ExpectedLinter != "" { - details += fmt.Sprintf(" for linter %q", i.ExpectedLinter) + return nil, nil + }, } - return details -} - -func (i UnusedCandidate) String() string { return toString(i) } -func toString(issue Issue) string { - return fmt.Sprintf("%s at %s", issue.Details(), issue.Position()) + return goanalysis.NewLinter( + Name, + "Reports ill-formed or insufficient nolint directives", + []*analysis.Analyzer{analyzer}, + nil, + ).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue { + return resIssues + }).WithLoadMode(goanalysis.LoadModeSyntax) } -type Issue interface { - Details() string - Position() token.Position - String() string - Replacement() *result.Replacement -} - -type Needs uint - -const ( - NeedsMachineOnly Needs = 1 << iota - NeedsSpecific - NeedsExplanation - NeedsUnused - NeedsAll = NeedsMachineOnly | NeedsSpecific | NeedsExplanation -) - -var commentPattern = regexp.MustCompile(`^//\s*(nolint)(:\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*)?\b`) - -// matches a complete nolint directive -var fullDirectivePattern = regexp.MustCompile(`^//\s*nolint(?::(\s*[\w-]+\s*(?:,\s*[\w-]+\s*)*))?\s*(//.*)?\s*\n?$`) - -type Linter struct { - needs Needs // indicates which linter checks to perform - excludeByLinter map[string]bool -} +func runNoLintLint(pass *analysis.Pass, settings *config.NoLintLintSettings) ([]goanalysis.Issue, error) { + var needs internal.Needs + if settings.RequireExplanation { + needs |= internal.NeedsExplanation + } + if settings.RequireSpecific { + needs |= internal.NeedsSpecific + } + if !settings.AllowUnused { + needs |= internal.NeedsUnused + } -// NewLinter creates a linter that enforces that the provided directives fulfill the provided requirements -func NewLinter(needs Needs, excludes []string) (*Linter, error) { - excludeByName := make(map[string]bool) - for _, e := range excludes { - excludeByName[e] = true + lnt, err := internal.NewLinter(needs, settings.AllowNoExplanation) + if err != nil { + return nil, err } - return &Linter{ - needs: needs | NeedsMachineOnly, - excludeByLinter: excludeByName, - }, nil -} + nodes := make([]ast.Node, 0, len(pass.Files)) + for _, n := range pass.Files { + nodes = append(nodes, n) + } -var ( - leadingSpacePattern = regexp.MustCompile(`^//(\s*)`) - trailingBlankExplanation = regexp.MustCompile(`\s*(//\s*)?$`) -) + lintIssues, err := lnt.Run(pass.Fset, nodes...) + if err != nil { + return nil, fmt.Errorf("linter failed to run: %w", err) + } -//nolint:funlen,gocyclo // the function is going to be refactored in the future -func (l Linter) Run(fset *token.FileSet, nodes ...ast.Node) ([]Issue, error) { - var issues []Issue + var issues []goanalysis.Issue - for _, node := range nodes { - file, ok := node.(*ast.File) - if !ok { - continue + for _, i := range lintIssues { + expectNoLint := false + var expectedNolintLinter string + if ii, ok := i.(internal.UnusedCandidate); ok { + expectedNolintLinter = ii.ExpectedLinter + expectNoLint = true } - for _, c := range file.Comments { - for _, comment := range c.List { - if !commentPattern.MatchString(comment.Text) { - continue - } - - // check for a space between the "//" and the directive - leadingSpaceMatches := leadingSpacePattern.FindStringSubmatch(comment.Text) - - var leadingSpace string - if len(leadingSpaceMatches) > 0 { - leadingSpace = leadingSpaceMatches[1] - } - - directiveWithOptionalLeadingSpace := "//" - if leadingSpace != "" { - directiveWithOptionalLeadingSpace += " " - } - - split := strings.Split(strings.SplitN(comment.Text, ":", 2)[0], "//") - directiveWithOptionalLeadingSpace += strings.TrimSpace(split[1]) - - pos := fset.Position(comment.Pos()) - end := fset.Position(comment.End()) - - base := BaseIssue{ - fullDirective: comment.Text, - directiveWithOptionalLeadingSpace: directiveWithOptionalLeadingSpace, - position: pos, - } - - // check for, report and eliminate leading spaces, so we can check for other issues - if leadingSpace != "" { - removeWhitespace := &result.Replacement{ - Inline: &result.InlineFix{ - StartCol: pos.Column + 1, - Length: len(leadingSpace), - NewString: "", - }, - } - if (l.needs & NeedsMachineOnly) != 0 { - issue := NotMachine{BaseIssue: base} - issue.BaseIssue.replacement = removeWhitespace - issues = append(issues, issue) - } else if len(leadingSpace) > 1 { - issue := ExtraLeadingSpace{BaseIssue: base} - issue.BaseIssue.replacement = removeWhitespace - issue.BaseIssue.replacement.Inline.NewString = " " // assume a single space was intended - issues = append(issues, issue) - } - } - - fullMatches := fullDirectivePattern.FindStringSubmatch(comment.Text) - if len(fullMatches) == 0 { - issues = append(issues, ParseError{BaseIssue: base}) - continue - } - - lintersText, explanation := fullMatches[1], fullMatches[2] - - var linters []string - if lintersText != "" && !strings.HasPrefix(lintersText, "all") { - lls := strings.Split(lintersText, ",") - linters = make([]string, 0, len(lls)) - rangeStart := (pos.Column - 1) + len("//") + len(leadingSpace) + len("nolint:") - for i, ll := range lls { - rangeEnd := rangeStart + len(ll) - if i < len(lls)-1 { - rangeEnd++ // include trailing comma - } - trimmedLinterName := strings.TrimSpace(ll) - if trimmedLinterName != "" { - linters = append(linters, trimmedLinterName) - } - rangeStart = rangeEnd - } - } - - if (l.needs & NeedsSpecific) != 0 { - if len(linters) == 0 { - issues = append(issues, NotSpecific{BaseIssue: base}) - } - } - - // when detecting unused directives, we send all the directives through and filter them out in the nolint processor - if (l.needs & NeedsUnused) != 0 { - removeNolintCompletely := &result.Replacement{ - Inline: &result.InlineFix{ - StartCol: pos.Column - 1, - Length: end.Column - pos.Column, - NewString: "", - }, - } - - if len(linters) == 0 { - issue := UnusedCandidate{BaseIssue: base} - issue.replacement = removeNolintCompletely - issues = append(issues, issue) - } else { - for _, linter := range linters { - issue := UnusedCandidate{BaseIssue: base, ExpectedLinter: linter} - // only offer replacement if there is a single linter - // because of issues around commas and the possibility of all - // linters being removed - if len(linters) == 1 { - issue.replacement = removeNolintCompletely - } - issues = append(issues, issue) - } - } - } - - if (l.needs&NeedsExplanation) != 0 && (explanation == "" || strings.TrimSpace(explanation) == "//") { - needsExplanation := len(linters) == 0 // if no linters are mentioned, we must have explanation - // otherwise, check if we are excluding all the mentioned linters - for _, ll := range linters { - if !l.excludeByLinter[ll] { // if a linter does require explanation - needsExplanation = true - break - } - } - - if needsExplanation { - fullDirectiveWithoutExplanation := trailingBlankExplanation.ReplaceAllString(comment.Text, "") - issues = append(issues, NoExplanation{ - BaseIssue: base, - fullDirectiveWithoutExplanation: fullDirectiveWithoutExplanation, - }) - } - } - } + issue := &result.Issue{ + FromLinter: Name, + Text: i.Details(), + Pos: i.Position(), + ExpectNoLint: expectNoLint, + ExpectedNoLintLinter: expectedNolintLinter, + Replacement: i.Replacement(), } + + issues = append(issues, goanalysis.NewIssue(issue, pass)) } return issues, nil diff --git a/pkg/golinters/nonamedreturns.go b/pkg/golinters/nonamedreturns/nonamedreturns.go similarity index 83% rename from pkg/golinters/nonamedreturns.go rename to pkg/golinters/nonamedreturns/nonamedreturns.go index ccfd5d6827f7..42a618e64154 100644 --- a/pkg/golinters/nonamedreturns.go +++ b/pkg/golinters/nonamedreturns/nonamedreturns.go @@ -1,4 +1,4 @@ -package golinters +package nonamedreturns import ( "github.com/firefart/nonamedreturns/analyzer" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewNoNamedReturns(settings *config.NoNamedReturnsSettings) *goanalysis.Linter { +func New(settings *config.NoNamedReturnsSettings) *goanalysis.Linter { a := analyzer.Analyzer var cfg map[string]map[string]any diff --git a/pkg/golinters/nonamedreturns/nonamedreturns_integration_test.go b/pkg/golinters/nonamedreturns/nonamedreturns_integration_test.go new file mode 100644 index 000000000000..c91a292b91a1 --- /dev/null +++ b/pkg/golinters/nonamedreturns/nonamedreturns_integration_test.go @@ -0,0 +1,11 @@ +package nonamedreturns + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/nonamedreturns.go b/pkg/golinters/nonamedreturns/testdata/nonamedreturns.go similarity index 100% rename from test/testdata/nonamedreturns.go rename to pkg/golinters/nonamedreturns/testdata/nonamedreturns.go diff --git a/test/testdata/nonamedreturns_custom.go b/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.go similarity index 97% rename from test/testdata/nonamedreturns_custom.go rename to pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.go index 3218f6ea8f9b..5a64f54a1d53 100644 --- a/test/testdata/nonamedreturns_custom.go +++ b/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Enonamedreturns -//golangcitest:config_path testdata/configs/nonamedreturns_custom.yml +//golangcitest:config_path testdata/nonamedreturns_custom.yml package testdata import "fmt" diff --git a/test/testdata/configs/nonamedreturns_custom.yml b/pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml similarity index 100% rename from test/testdata/configs/nonamedreturns_custom.yml rename to pkg/golinters/nonamedreturns/testdata/nonamedreturns_custom.yml diff --git a/pkg/golinters/nosprintfhostport.go b/pkg/golinters/nosprintfhostport/nosprintfhostport.go similarity index 82% rename from pkg/golinters/nosprintfhostport.go rename to pkg/golinters/nosprintfhostport/nosprintfhostport.go index a4fdcb859a69..8f06ae1f6d19 100644 --- a/pkg/golinters/nosprintfhostport.go +++ b/pkg/golinters/nosprintfhostport/nosprintfhostport.go @@ -1,4 +1,4 @@ -package golinters +package nosprintfhostport import ( "github.com/stbenjam/no-sprintf-host-port/pkg/analyzer" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewNoSprintfHostPort() *goanalysis.Linter { +func New() *goanalysis.Linter { a := analyzer.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/nosprintfhostport/nosprintfhostport_integration_test.go b/pkg/golinters/nosprintfhostport/nosprintfhostport_integration_test.go new file mode 100644 index 000000000000..d685d1524147 --- /dev/null +++ b/pkg/golinters/nosprintfhostport/nosprintfhostport_integration_test.go @@ -0,0 +1,11 @@ +package nosprintfhostport + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/nosprintfhostport.go b/pkg/golinters/nosprintfhostport/testdata/nosprintfhostport.go similarity index 100% rename from test/testdata/nosprintfhostport.go rename to pkg/golinters/nosprintfhostport/testdata/nosprintfhostport.go diff --git a/pkg/golinters/paralleltest.go b/pkg/golinters/paralleltest/paralleltest.go similarity index 88% rename from pkg/golinters/paralleltest.go rename to pkg/golinters/paralleltest/paralleltest.go index 55fc7548d809..0c908fa38ffb 100644 --- a/pkg/golinters/paralleltest.go +++ b/pkg/golinters/paralleltest/paralleltest.go @@ -1,4 +1,4 @@ -package golinters +package paralleltest import ( "github.com/kunwardeep/paralleltest/pkg/paralleltest" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewParallelTest(settings *config.ParallelTestSettings) *goanalysis.Linter { +func New(settings *config.ParallelTestSettings) *goanalysis.Linter { a := paralleltest.NewAnalyzer() var cfg map[string]map[string]any diff --git a/pkg/golinters/paralleltest/paralleltest_integration_test.go b/pkg/golinters/paralleltest/paralleltest_integration_test.go new file mode 100644 index 000000000000..9cf0ea6f2624 --- /dev/null +++ b/pkg/golinters/paralleltest/paralleltest_integration_test.go @@ -0,0 +1,11 @@ +package paralleltest + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/paralleltest.go b/pkg/golinters/paralleltest/testdata/paralleltest.go similarity index 100% rename from test/testdata/paralleltest.go rename to pkg/golinters/paralleltest/testdata/paralleltest.go diff --git a/test/testdata/paralleltest_custom.go b/pkg/golinters/paralleltest/testdata/paralleltest_custom.go similarity index 85% rename from test/testdata/paralleltest_custom.go rename to pkg/golinters/paralleltest/testdata/paralleltest_custom.go index f896edf279ba..c03b0996e70f 100644 --- a/test/testdata/paralleltest_custom.go +++ b/pkg/golinters/paralleltest/testdata/paralleltest_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Eparalleltest -//golangcitest:config_path testdata/configs/paralleltest_custom.yml +//golangcitest:config_path testdata/paralleltest_custom.yml //golangcitest:expected_exitcode 0 package testdata diff --git a/test/testdata/configs/paralleltest_custom.yml b/pkg/golinters/paralleltest/testdata/paralleltest_custom.yml similarity index 100% rename from test/testdata/configs/paralleltest_custom.yml rename to pkg/golinters/paralleltest/testdata/paralleltest_custom.yml diff --git a/pkg/golinters/perfsprint.go b/pkg/golinters/perfsprint/perfsprint.go similarity index 87% rename from pkg/golinters/perfsprint.go rename to pkg/golinters/perfsprint/perfsprint.go index 8dc3e56aacc5..a4ead1914d2c 100644 --- a/pkg/golinters/perfsprint.go +++ b/pkg/golinters/perfsprint/perfsprint.go @@ -1,4 +1,4 @@ -package golinters +package perfsprint import ( "github.com/catenacyber/perfsprint/analyzer" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewPerfSprint(settings *config.PerfSprintSettings) *goanalysis.Linter { +func New(settings *config.PerfSprintSettings) *goanalysis.Linter { a := analyzer.New() cfg := map[string]map[string]any{ diff --git a/pkg/golinters/perfsprint/perfsprint_integration_test.go b/pkg/golinters/perfsprint/perfsprint_integration_test.go new file mode 100644 index 000000000000..a94b87573b14 --- /dev/null +++ b/pkg/golinters/perfsprint/perfsprint_integration_test.go @@ -0,0 +1,11 @@ +package perfsprint + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/perfsprint.go b/pkg/golinters/perfsprint/testdata/perfsprint.go similarity index 100% rename from test/testdata/perfsprint.go rename to pkg/golinters/perfsprint/testdata/perfsprint.go diff --git a/test/testdata/perfsprint_custom.go b/pkg/golinters/perfsprint/testdata/perfsprint_custom.go similarity index 96% rename from test/testdata/perfsprint_custom.go rename to pkg/golinters/perfsprint/testdata/perfsprint_custom.go index 04de585b7eff..cbfe8541220a 100644 --- a/test/testdata/perfsprint_custom.go +++ b/pkg/golinters/perfsprint/testdata/perfsprint_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Eperfsprint -//golangcitest:config_path testdata/configs/perfsprint_custom.yml +//golangcitest:config_path testdata/perfsprint_custom.yml package testdata import ( diff --git a/test/testdata/configs/perfsprint_custom.yml b/pkg/golinters/perfsprint/testdata/perfsprint_custom.yml similarity index 100% rename from test/testdata/configs/perfsprint_custom.yml rename to pkg/golinters/perfsprint/testdata/perfsprint_custom.yml diff --git a/pkg/golinters/prealloc.go b/pkg/golinters/prealloc/prealloc.go similarity index 88% rename from pkg/golinters/prealloc.go rename to pkg/golinters/prealloc/prealloc.go index 944286ee09a8..28116aa2a57f 100644 --- a/pkg/golinters/prealloc.go +++ b/pkg/golinters/prealloc/prealloc.go @@ -1,4 +1,4 @@ -package golinters +package prealloc import ( "fmt" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const preallocName = "prealloc" +const name = "prealloc" -func NewPreAlloc(settings *config.PreallocSettings) *goanalysis.Linter { +func New(settings *config.PreallocSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: preallocName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues := runPreAlloc(pass, settings) @@ -39,7 +39,7 @@ func NewPreAlloc(settings *config.PreallocSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - preallocName, + name, "Finds slice declarations that could potentially be pre-allocated", []*analysis.Analyzer{analyzer}, nil, @@ -57,7 +57,7 @@ func runPreAlloc(pass *analysis.Pass, settings *config.PreallocSettings) []goana issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: pass.Fset.Position(hint.Pos), Text: fmt.Sprintf("Consider pre-allocating %s", internal.FormatCode(hint.DeclaredSliceName, nil)), - FromLinter: preallocName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/prealloc/prealloc_integration_test.go b/pkg/golinters/prealloc/prealloc_integration_test.go new file mode 100644 index 000000000000..bb5207c3f780 --- /dev/null +++ b/pkg/golinters/prealloc/prealloc_integration_test.go @@ -0,0 +1,11 @@ +package prealloc + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/prealloc.go b/pkg/golinters/prealloc/testdata/prealloc.go similarity index 100% rename from test/testdata/prealloc.go rename to pkg/golinters/prealloc/testdata/prealloc.go diff --git a/pkg/golinters/predeclared.go b/pkg/golinters/predeclared/predeclared.go similarity index 85% rename from pkg/golinters/predeclared.go rename to pkg/golinters/predeclared/predeclared.go index e9afa792afe5..b8d189fd557e 100644 --- a/pkg/golinters/predeclared.go +++ b/pkg/golinters/predeclared/predeclared.go @@ -1,4 +1,4 @@ -package golinters +package predeclared import ( "github.com/nishanths/predeclared/passes/predeclared" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewPredeclared(settings *config.PredeclaredSettings) *goanalysis.Linter { +func New(settings *config.PredeclaredSettings) *goanalysis.Linter { a := predeclared.Analyzer var cfg map[string]map[string]any diff --git a/pkg/golinters/predeclared/predeclared_integration_test.go b/pkg/golinters/predeclared/predeclared_integration_test.go new file mode 100644 index 000000000000..dfd42eb7d147 --- /dev/null +++ b/pkg/golinters/predeclared/predeclared_integration_test.go @@ -0,0 +1,11 @@ +package predeclared + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/predeclared.go b/pkg/golinters/predeclared/testdata/predeclared.go similarity index 100% rename from test/testdata/predeclared.go rename to pkg/golinters/predeclared/testdata/predeclared.go diff --git a/test/testdata/predeclared_custom.go b/pkg/golinters/predeclared/testdata/predeclared_custom.go similarity index 86% rename from test/testdata/predeclared_custom.go rename to pkg/golinters/predeclared/testdata/predeclared_custom.go index 560f63da0633..4b6163e33269 100644 --- a/test/testdata/predeclared_custom.go +++ b/pkg/golinters/predeclared/testdata/predeclared_custom.go @@ -1,5 +1,5 @@ //golangcitest:args -Epredeclared -//golangcitest:config_path testdata/configs/predeclared_custom.yml +//golangcitest:config_path testdata/predeclared_custom.yml package testdata func hello() { diff --git a/test/testdata/configs/predeclared_custom.yml b/pkg/golinters/predeclared/testdata/predeclared_custom.yml similarity index 100% rename from test/testdata/configs/predeclared_custom.yml rename to pkg/golinters/predeclared/testdata/predeclared_custom.yml diff --git a/pkg/golinters/promlinter.go b/pkg/golinters/promlinter/promlinter.go similarity index 88% rename from pkg/golinters/promlinter.go rename to pkg/golinters/promlinter/promlinter.go index 59eac10141ba..f863be8ee9f5 100644 --- a/pkg/golinters/promlinter.go +++ b/pkg/golinters/promlinter/promlinter.go @@ -1,4 +1,4 @@ -package golinters +package promlinter import ( "fmt" @@ -13,9 +13,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const promlinterName = "promlinter" +const name = "promlinter" -func NewPromlinter(settings *config.PromlinterSettings) *goanalysis.Linter { +func New(settings *config.PromlinterSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -28,7 +28,7 @@ func NewPromlinter(settings *config.PromlinterSettings) *goanalysis.Linter { } analyzer := &analysis.Analyzer{ - Name: promlinterName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues := runPromLinter(pass, promSettings) @@ -46,7 +46,7 @@ func NewPromlinter(settings *config.PromlinterSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - promlinterName, + name, "Check Prometheus metrics naming via promlint", []*analysis.Analyzer{analyzer}, nil, @@ -67,7 +67,7 @@ func runPromLinter(pass *analysis.Pass, promSettings promlinter.Setting) []goana issue := result.Issue{ Pos: i.Pos, Text: fmt.Sprintf("Metric: %s Error: %s", i.Metric, i.Text), - FromLinter: promlinterName, + FromLinter: name, } issues[k] = goanalysis.NewIssue(&issue, pass) diff --git a/pkg/golinters/promlinter/promlinter_integration_test.go b/pkg/golinters/promlinter/promlinter_integration_test.go new file mode 100644 index 000000000000..3aa64fe5b68d --- /dev/null +++ b/pkg/golinters/promlinter/promlinter_integration_test.go @@ -0,0 +1,11 @@ +package promlinter + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/promlinter.go b/pkg/golinters/promlinter/testdata/promlinter.go similarity index 100% rename from test/testdata/promlinter.go rename to pkg/golinters/promlinter/testdata/promlinter.go diff --git a/pkg/golinters/protogetter.go b/pkg/golinters/protogetter/protogetter.go similarity index 94% rename from pkg/golinters/protogetter.go rename to pkg/golinters/protogetter/protogetter.go index fdc5b6641e3c..302ce67b88f4 100644 --- a/pkg/golinters/protogetter.go +++ b/pkg/golinters/protogetter/protogetter.go @@ -1,4 +1,4 @@ -package golinters +package protogetter import ( "sync" @@ -12,7 +12,7 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -func NewProtoGetter(settings *config.ProtoGetterSettings) *goanalysis.Linter { +func New(settings *config.ProtoGetterSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue diff --git a/pkg/golinters/protogetter/protogetter_integration_test.go b/pkg/golinters/protogetter/protogetter_integration_test.go new file mode 100644 index 000000000000..b139aa244b66 --- /dev/null +++ b/pkg/golinters/protogetter/protogetter_integration_test.go @@ -0,0 +1,11 @@ +package protogetter + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/protogetter/go.mod b/pkg/golinters/protogetter/testdata/go.mod similarity index 100% rename from test/testdata/protogetter/go.mod rename to pkg/golinters/protogetter/testdata/go.mod diff --git a/test/testdata/protogetter/go.sum b/pkg/golinters/protogetter/testdata/go.sum similarity index 100% rename from test/testdata/protogetter/go.sum rename to pkg/golinters/protogetter/testdata/go.sum diff --git a/test/testdata/protogetter/proto/test.go b/pkg/golinters/protogetter/testdata/proto/test.go similarity index 100% rename from test/testdata/protogetter/proto/test.go rename to pkg/golinters/protogetter/testdata/proto/test.go diff --git a/test/testdata/protogetter/proto/test.pb.go b/pkg/golinters/protogetter/testdata/proto/test.pb.go similarity index 100% rename from test/testdata/protogetter/proto/test.pb.go rename to pkg/golinters/protogetter/testdata/proto/test.pb.go diff --git a/test/testdata/protogetter/proto/test.proto b/pkg/golinters/protogetter/testdata/proto/test.proto similarity index 100% rename from test/testdata/protogetter/proto/test.proto rename to pkg/golinters/protogetter/testdata/proto/test.proto diff --git a/test/testdata/protogetter/proto/test_grpc.pb.go b/pkg/golinters/protogetter/testdata/proto/test_grpc.pb.go similarity index 100% rename from test/testdata/protogetter/proto/test_grpc.pb.go rename to pkg/golinters/protogetter/testdata/proto/test_grpc.pb.go diff --git a/test/testdata/protogetter/protogetter.go b/pkg/golinters/protogetter/testdata/protogetter.go similarity index 100% rename from test/testdata/protogetter/protogetter.go rename to pkg/golinters/protogetter/testdata/protogetter.go diff --git a/pkg/golinters/reassign.go b/pkg/golinters/reassign/reassign.go similarity index 86% rename from pkg/golinters/reassign.go rename to pkg/golinters/reassign/reassign.go index 43a6ce43afb4..cfc85635e2be 100644 --- a/pkg/golinters/reassign.go +++ b/pkg/golinters/reassign/reassign.go @@ -1,4 +1,4 @@ -package golinters +package reassign import ( "fmt" @@ -11,7 +11,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewReassign(settings *config.ReassignSettings) *goanalysis.Linter { +func New(settings *config.ReassignSettings) *goanalysis.Linter { a := reassign.NewAnalyzer() var cfg map[string]map[string]any diff --git a/pkg/golinters/reassign/reassign_integration_test.go b/pkg/golinters/reassign/reassign_integration_test.go new file mode 100644 index 000000000000..5b1337a9a587 --- /dev/null +++ b/pkg/golinters/reassign/reassign_integration_test.go @@ -0,0 +1,11 @@ +package reassign + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/reassign.go b/pkg/golinters/reassign/testdata/reassign.go similarity index 100% rename from test/testdata/reassign.go rename to pkg/golinters/reassign/testdata/reassign.go diff --git a/test/testdata/reassign_patterns.go b/pkg/golinters/reassign/testdata/reassign_patterns.go similarity index 82% rename from test/testdata/reassign_patterns.go rename to pkg/golinters/reassign/testdata/reassign_patterns.go index dc83cd71c0ef..b6e0ae6a6885 100644 --- a/test/testdata/reassign_patterns.go +++ b/pkg/golinters/reassign/testdata/reassign_patterns.go @@ -1,5 +1,5 @@ //golangcitest:args -Ereassign -//golangcitest:config_path testdata/configs/reassign_patterns.yml +//golangcitest:config_path testdata/reassign_patterns.yml package testdata import ( diff --git a/test/testdata/configs/reassign_patterns.yml b/pkg/golinters/reassign/testdata/reassign_patterns.yml similarity index 100% rename from test/testdata/configs/reassign_patterns.yml rename to pkg/golinters/reassign/testdata/reassign_patterns.yml diff --git a/pkg/golinters/revive.go b/pkg/golinters/revive/revive.go similarity index 96% rename from pkg/golinters/revive.go rename to pkg/golinters/revive/revive.go index 0715d93700cd..5287cbc383a4 100644 --- a/pkg/golinters/revive.go +++ b/pkg/golinters/revive/revive.go @@ -1,4 +1,4 @@ -package golinters +package revive import ( "bytes" @@ -23,9 +23,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const reviveName = "revive" +const name = "revive" -var reviveDebugf = logutils.Debug(logutils.DebugKeyRevive) +var debugf = logutils.Debug(logutils.DebugKeyRevive) // jsonObject defines a JSON object of a failure type jsonObject struct { @@ -33,10 +33,7 @@ type jsonObject struct { lint.Failure `json:",inline"` } -// NewRevive returns a new Revive linter. -// - -func NewRevive(settings *config.ReviveSettings) *goanalysis.Linter { +func New(settings *config.ReviveSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -47,7 +44,7 @@ func NewRevive(settings *config.ReviveSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - reviveName, + name, "Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.", []*analysis.Analyzer{analyzer}, nil, @@ -154,7 +151,7 @@ func reviveToIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue { From: object.Position.Start.Line, To: lineRangeTo, }, - FromLinter: reviveName, + FromLinter: name, }, pass) } @@ -192,7 +189,7 @@ func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) { conf.Rules[k] = r } - reviveDebugf("revive configuration: %#v", conf) + debugf("revive configuration: %#v", conf) return conf, nil } diff --git a/pkg/golinters/revive/revive_integration_test.go b/pkg/golinters/revive/revive_integration_test.go new file mode 100644 index 000000000000..c28e2815e7ac --- /dev/null +++ b/pkg/golinters/revive/revive_integration_test.go @@ -0,0 +1,11 @@ +package revive + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/revive.go b/pkg/golinters/revive/testdata/revive.go similarity index 91% rename from test/testdata/revive.go rename to pkg/golinters/revive/testdata/revive.go index 8f497a89d7c3..735f1b757bf6 100644 --- a/test/testdata/revive.go +++ b/pkg/golinters/revive/testdata/revive.go @@ -1,5 +1,5 @@ //golangcitest:args -Erevive -//golangcitest:config_path testdata/configs/revive.yml +//golangcitest:config_path testdata/revive.yml package testdata import ( diff --git a/test/testdata/configs/revive.yml b/pkg/golinters/revive/testdata/revive.yml similarity index 100% rename from test/testdata/configs/revive.yml rename to pkg/golinters/revive/testdata/revive.yml diff --git a/test/testdata/revive_default.go b/pkg/golinters/revive/testdata/revive_default.go similarity index 100% rename from test/testdata/revive_default.go rename to pkg/golinters/revive/testdata/revive_default.go diff --git a/pkg/golinters/rowserrcheck.go b/pkg/golinters/rowserrcheck/rowserrcheck.go similarity index 83% rename from pkg/golinters/rowserrcheck.go rename to pkg/golinters/rowserrcheck/rowserrcheck.go index 17814c7c0e64..3fe824467341 100644 --- a/pkg/golinters/rowserrcheck.go +++ b/pkg/golinters/rowserrcheck/rowserrcheck.go @@ -1,4 +1,4 @@ -package golinters +package rowserrcheck import ( "github.com/jingyugao/rowserrcheck/passes/rowserr" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewRowsErrCheck(settings *config.RowsErrCheckSettings) *goanalysis.Linter { +func New(settings *config.RowsErrCheckSettings) *goanalysis.Linter { var pkgs []string if settings != nil { pkgs = settings.Packages diff --git a/pkg/golinters/rowserrcheck/rowserrcheck_integration_test.go b/pkg/golinters/rowserrcheck/rowserrcheck_integration_test.go new file mode 100644 index 000000000000..d7b6bc1038f9 --- /dev/null +++ b/pkg/golinters/rowserrcheck/rowserrcheck_integration_test.go @@ -0,0 +1,11 @@ +package rowserrcheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/rowserrcheck.go b/pkg/golinters/rowserrcheck/testdata/rowserrcheck.go similarity index 100% rename from test/testdata/rowserrcheck.go rename to pkg/golinters/rowserrcheck/testdata/rowserrcheck.go diff --git a/pkg/golinters/sloglint.go b/pkg/golinters/sloglint/sloglint.go similarity index 89% rename from pkg/golinters/sloglint.go rename to pkg/golinters/sloglint/sloglint.go index 788d0c523731..be7d45180611 100644 --- a/pkg/golinters/sloglint.go +++ b/pkg/golinters/sloglint/sloglint.go @@ -1,4 +1,4 @@ -package golinters +package sloglint import ( "go-simpler.org/sloglint" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewSlogLint(settings *config.SlogLintSettings) *goanalysis.Linter { +func New(settings *config.SlogLintSettings) *goanalysis.Linter { var opts *sloglint.Options if settings != nil { opts = &sloglint.Options{ diff --git a/pkg/golinters/sloglint/sloglint_integration_test.go b/pkg/golinters/sloglint/sloglint_integration_test.go new file mode 100644 index 000000000000..818dd22c4f1f --- /dev/null +++ b/pkg/golinters/sloglint/sloglint_integration_test.go @@ -0,0 +1,11 @@ +package sloglint + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/sloglint.go b/pkg/golinters/sloglint/testdata/sloglint.go similarity index 100% rename from test/testdata/sloglint.go rename to pkg/golinters/sloglint/testdata/sloglint.go diff --git a/test/testdata/sloglint_args_on_sep_lines.go b/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.go similarity index 78% rename from test/testdata/sloglint_args_on_sep_lines.go rename to pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.go index 9bdd89764cbe..1b93cd5bdab7 100644 --- a/test/testdata/sloglint_args_on_sep_lines.go +++ b/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.go @@ -1,7 +1,7 @@ //go:build go1.21 //golangcitest:args -Esloglint -//golangcitest:config_path testdata/configs/sloglint_args_on_sep_lines.yml +//golangcitest:config_path testdata/sloglint_args_on_sep_lines.yml package testdata import "log/slog" diff --git a/test/testdata/configs/sloglint_args_on_sep_lines.yml b/pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml similarity index 100% rename from test/testdata/configs/sloglint_args_on_sep_lines.yml rename to pkg/golinters/sloglint/testdata/sloglint_args_on_sep_lines.yml diff --git a/test/testdata/sloglint_attr_only.go b/pkg/golinters/sloglint/testdata/sloglint_attr_only.go similarity index 78% rename from test/testdata/sloglint_attr_only.go rename to pkg/golinters/sloglint/testdata/sloglint_attr_only.go index 3153026e4557..67fb9b59e064 100644 --- a/test/testdata/sloglint_attr_only.go +++ b/pkg/golinters/sloglint/testdata/sloglint_attr_only.go @@ -1,7 +1,7 @@ //go:build go1.21 //golangcitest:args -Esloglint -//golangcitest:config_path testdata/configs/sloglint_attr_only.yml +//golangcitest:config_path testdata/sloglint_attr_only.yml package testdata import "log/slog" diff --git a/test/testdata/configs/sloglint_attr_only.yml b/pkg/golinters/sloglint/testdata/sloglint_attr_only.yml similarity index 100% rename from test/testdata/configs/sloglint_attr_only.yml rename to pkg/golinters/sloglint/testdata/sloglint_attr_only.yml diff --git a/test/testdata/sloglint_context_only.go b/pkg/golinters/sloglint/testdata/sloglint_context_only.go similarity index 77% rename from test/testdata/sloglint_context_only.go rename to pkg/golinters/sloglint/testdata/sloglint_context_only.go index 78f39e373432..a257a5168c1f 100644 --- a/test/testdata/sloglint_context_only.go +++ b/pkg/golinters/sloglint/testdata/sloglint_context_only.go @@ -1,7 +1,7 @@ //go:build go1.21 //golangcitest:args -Esloglint -//golangcitest:config_path testdata/configs/sloglint_context_only.yml +//golangcitest:config_path testdata/sloglint_context_only.yml package testdata import ( diff --git a/test/testdata/configs/sloglint_context_only.yml b/pkg/golinters/sloglint/testdata/sloglint_context_only.yml similarity index 100% rename from test/testdata/configs/sloglint_context_only.yml rename to pkg/golinters/sloglint/testdata/sloglint_context_only.yml diff --git a/test/testdata/sloglint_key_naming_case.go b/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.go similarity index 90% rename from test/testdata/sloglint_key_naming_case.go rename to pkg/golinters/sloglint/testdata/sloglint_key_naming_case.go index d278cd974c80..c5be41f6560d 100644 --- a/test/testdata/sloglint_key_naming_case.go +++ b/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.go @@ -1,7 +1,7 @@ //go:build go1.21 //golangcitest:args -Esloglint -//golangcitest:config_path testdata/configs/sloglint_key_naming_case.yml +//golangcitest:config_path testdata/sloglint_key_naming_case.yml package testdata import "log/slog" diff --git a/test/testdata/configs/sloglint_key_naming_case.yml b/pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml similarity index 100% rename from test/testdata/configs/sloglint_key_naming_case.yml rename to pkg/golinters/sloglint/testdata/sloglint_key_naming_case.yml diff --git a/test/testdata/sloglint_kv_only.go b/pkg/golinters/sloglint/testdata/sloglint_kv_only.go similarity index 78% rename from test/testdata/sloglint_kv_only.go rename to pkg/golinters/sloglint/testdata/sloglint_kv_only.go index efbcefcc8591..cf05d6b23bda 100644 --- a/test/testdata/sloglint_kv_only.go +++ b/pkg/golinters/sloglint/testdata/sloglint_kv_only.go @@ -1,7 +1,7 @@ //go:build go1.21 //golangcitest:args -Esloglint -//golangcitest:config_path testdata/configs/sloglint_kv_only.yml +//golangcitest:config_path testdata/sloglint_kv_only.yml package testdata import "log/slog" diff --git a/test/testdata/configs/sloglint_kv_only.yml b/pkg/golinters/sloglint/testdata/sloglint_kv_only.yml similarity index 100% rename from test/testdata/configs/sloglint_kv_only.yml rename to pkg/golinters/sloglint/testdata/sloglint_kv_only.yml diff --git a/test/testdata/sloglint_no_raw_keys.go b/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.go similarity index 85% rename from test/testdata/sloglint_no_raw_keys.go rename to pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.go index ff248993142f..2c1dc2e1a907 100644 --- a/test/testdata/sloglint_no_raw_keys.go +++ b/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.go @@ -1,7 +1,7 @@ //go:build go1.21 //golangcitest:args -Esloglint -//golangcitest:config_path testdata/configs/sloglint_no_raw_keys.yml +//golangcitest:config_path testdata/sloglint_no_raw_keys.yml package testdata import "log/slog" diff --git a/test/testdata/configs/sloglint_no_raw_keys.yml b/pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml similarity index 100% rename from test/testdata/configs/sloglint_no_raw_keys.yml rename to pkg/golinters/sloglint/testdata/sloglint_no_raw_keys.yml diff --git a/test/testdata/sloglint_static_msg.go b/pkg/golinters/sloglint/testdata/sloglint_static_msg.go similarity index 79% rename from test/testdata/sloglint_static_msg.go rename to pkg/golinters/sloglint/testdata/sloglint_static_msg.go index 261a40b6601f..258ff871f3e2 100644 --- a/test/testdata/sloglint_static_msg.go +++ b/pkg/golinters/sloglint/testdata/sloglint_static_msg.go @@ -1,7 +1,7 @@ //go:build go1.21 //golangcitest:args -Esloglint -//golangcitest:config_path testdata/configs/sloglint_static_msg.yml +//golangcitest:config_path testdata/sloglint_static_msg.yml package testdata import ( diff --git a/test/testdata/configs/sloglint_static_msg.yml b/pkg/golinters/sloglint/testdata/sloglint_static_msg.yml similarity index 100% rename from test/testdata/configs/sloglint_static_msg.yml rename to pkg/golinters/sloglint/testdata/sloglint_static_msg.yml diff --git a/pkg/golinters/spancheck.go b/pkg/golinters/spancheck/spancheck.go similarity index 86% rename from pkg/golinters/spancheck.go rename to pkg/golinters/spancheck/spancheck.go index 426c318a491a..9bee6cb45a66 100644 --- a/pkg/golinters/spancheck.go +++ b/pkg/golinters/spancheck/spancheck.go @@ -1,4 +1,4 @@ -package golinters +package spancheck import ( "github.com/jjti/go-spancheck" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewSpancheck(settings *config.SpancheckSettings) *goanalysis.Linter { +func New(settings *config.SpancheckSettings) *goanalysis.Linter { cfg := spancheck.NewDefaultConfig() if settings != nil { diff --git a/pkg/golinters/spancheck/spancheck_integration_test.go b/pkg/golinters/spancheck/spancheck_integration_test.go new file mode 100644 index 000000000000..c05bc9af6486 --- /dev/null +++ b/pkg/golinters/spancheck/spancheck_integration_test.go @@ -0,0 +1,11 @@ +package spancheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/spancheck/go.mod b/pkg/golinters/spancheck/testdata/go.mod similarity index 100% rename from test/testdata/spancheck/go.mod rename to pkg/golinters/spancheck/testdata/go.mod diff --git a/test/testdata/spancheck/go.sum b/pkg/golinters/spancheck/testdata/go.sum similarity index 100% rename from test/testdata/spancheck/go.sum rename to pkg/golinters/spancheck/testdata/go.sum diff --git a/test/testdata/spancheck/spancheck_default.go b/pkg/golinters/spancheck/testdata/spancheck_default.go similarity index 100% rename from test/testdata/spancheck/spancheck_default.go rename to pkg/golinters/spancheck/testdata/spancheck_default.go diff --git a/test/testdata/spancheck/spancheck_enable_all.go b/pkg/golinters/spancheck/testdata/spancheck_enable_all.go similarity index 98% rename from test/testdata/spancheck/spancheck_enable_all.go rename to pkg/golinters/spancheck/testdata/spancheck_enable_all.go index 38cce01900d2..e91aa9afd4cf 100644 --- a/test/testdata/spancheck/spancheck_enable_all.go +++ b/pkg/golinters/spancheck/testdata/spancheck_enable_all.go @@ -1,4 +1,4 @@ -//golangcitest:config_path configs/spancheck_enable_all.yml +//golangcitest:config_path testdata/spancheck_enable_all.yml //golangcitest:args -Espancheck package spancheck diff --git a/test/testdata/spancheck/configs/spancheck_enable_all.yml b/pkg/golinters/spancheck/testdata/spancheck_enable_all.yml similarity index 100% rename from test/testdata/spancheck/configs/spancheck_enable_all.yml rename to pkg/golinters/spancheck/testdata/spancheck_enable_all.yml diff --git a/pkg/golinters/sqlclosecheck.go b/pkg/golinters/sqlclosecheck/sqlclosecheck.go similarity index 83% rename from pkg/golinters/sqlclosecheck.go rename to pkg/golinters/sqlclosecheck/sqlclosecheck.go index 94fd8b2c09f9..5eb32ff9dbe3 100644 --- a/pkg/golinters/sqlclosecheck.go +++ b/pkg/golinters/sqlclosecheck/sqlclosecheck.go @@ -1,4 +1,4 @@ -package golinters +package sqlclosecheck import ( "github.com/ryanrolds/sqlclosecheck/pkg/analyzer" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewSQLCloseCheck() *goanalysis.Linter { +func New() *goanalysis.Linter { a := analyzer.NewAnalyzer() return goanalysis.NewLinter( diff --git a/pkg/golinters/sqlclosecheck/sqlclosecheck_integration_test.go b/pkg/golinters/sqlclosecheck/sqlclosecheck_integration_test.go new file mode 100644 index 000000000000..09a6c99eef12 --- /dev/null +++ b/pkg/golinters/sqlclosecheck/sqlclosecheck_integration_test.go @@ -0,0 +1,11 @@ +package sqlclosecheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/sqlclosecheck.go b/pkg/golinters/sqlclosecheck/testdata/sqlclosecheck.go similarity index 100% rename from test/testdata/sqlclosecheck.go rename to pkg/golinters/sqlclosecheck/testdata/sqlclosecheck.go diff --git a/pkg/golinters/staticcheck.go b/pkg/golinters/staticcheck/staticcheck.go similarity index 87% rename from pkg/golinters/staticcheck.go rename to pkg/golinters/staticcheck/staticcheck.go index f0a2e6c03c25..0c0534539ea5 100644 --- a/pkg/golinters/staticcheck.go +++ b/pkg/golinters/staticcheck/staticcheck.go @@ -1,4 +1,4 @@ -package golinters +package staticcheck import ( "honnef.co/go/tools/staticcheck" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/internal" ) -func NewStaticcheck(settings *config.StaticCheckSettings) *goanalysis.Linter { +func New(settings *config.StaticCheckSettings) *goanalysis.Linter { cfg := internal.StaticCheckConfig(settings) analyzers := internal.SetupStaticCheckAnalyzers(staticcheck.Analyzers, internal.GetGoVersion(settings), cfg.Checks) diff --git a/pkg/golinters/staticcheck/staticcheck_integration_test.go b/pkg/golinters/staticcheck/staticcheck_integration_test.go new file mode 100644 index 000000000000..ed09970659f9 --- /dev/null +++ b/pkg/golinters/staticcheck/staticcheck_integration_test.go @@ -0,0 +1,11 @@ +package staticcheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/staticcheck.go b/pkg/golinters/staticcheck/testdata/staticcheck.go similarity index 100% rename from test/testdata/staticcheck.go rename to pkg/golinters/staticcheck/testdata/staticcheck.go diff --git a/test/testdata/staticcheck_in_megacheck.go b/pkg/golinters/staticcheck/testdata/staticcheck_in_megacheck.go similarity index 100% rename from test/testdata/staticcheck_in_megacheck.go rename to pkg/golinters/staticcheck/testdata/staticcheck_in_megacheck.go diff --git a/pkg/golinters/stylecheck.go b/pkg/golinters/stylecheck/stylecheck.go similarity index 91% rename from pkg/golinters/stylecheck.go rename to pkg/golinters/stylecheck/stylecheck.go index 338326b90576..b8fc8fe547d1 100644 --- a/pkg/golinters/stylecheck.go +++ b/pkg/golinters/stylecheck/stylecheck.go @@ -1,4 +1,4 @@ -package golinters +package stylecheck import ( "golang.org/x/tools/go/analysis" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/internal" ) -func NewStylecheck(settings *config.StaticCheckSettings) *goanalysis.Linter { +func New(settings *config.StaticCheckSettings) *goanalysis.Linter { cfg := internal.StaticCheckConfig(settings) // `scconfig.Analyzer` is a singleton, then it's not possible to have more than one instance for all staticcheck "sub-linters". diff --git a/pkg/golinters/stylecheck/stylecheck_integration_test.go b/pkg/golinters/stylecheck/stylecheck_integration_test.go new file mode 100644 index 000000000000..b82e5d3b13c9 --- /dev/null +++ b/pkg/golinters/stylecheck/stylecheck_integration_test.go @@ -0,0 +1,11 @@ +package stylecheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/stylecheck.go b/pkg/golinters/stylecheck/testdata/stylecheck.go similarity index 100% rename from test/testdata/stylecheck.go rename to pkg/golinters/stylecheck/testdata/stylecheck.go diff --git a/test/testdata/stylecheck_not_in_megacheck.go b/pkg/golinters/stylecheck/testdata/stylecheck_not_in_megacheck.go similarity index 100% rename from test/testdata/stylecheck_not_in_megacheck.go rename to pkg/golinters/stylecheck/testdata/stylecheck_not_in_megacheck.go diff --git a/pkg/golinters/tagalign.go b/pkg/golinters/tagalign/tagalign.go similarity index 95% rename from pkg/golinters/tagalign.go rename to pkg/golinters/tagalign/tagalign.go index 4a2e000fee7b..f438c51b5c7e 100644 --- a/pkg/golinters/tagalign.go +++ b/pkg/golinters/tagalign/tagalign.go @@ -1,4 +1,4 @@ -package golinters +package tagalign import ( "sync" @@ -12,7 +12,7 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -func NewTagAlign(settings *config.TagAlignSettings) *goanalysis.Linter { +func New(settings *config.TagAlignSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue diff --git a/pkg/golinters/tagalign/tagalign_integration_test.go b/pkg/golinters/tagalign/tagalign_integration_test.go new file mode 100644 index 000000000000..2dc10120ece9 --- /dev/null +++ b/pkg/golinters/tagalign/tagalign_integration_test.go @@ -0,0 +1,19 @@ +package tagalign + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/fix/in/tagalign.go b/pkg/golinters/tagalign/testdata/fix/in/tagalign.go similarity index 83% rename from test/testdata/fix/in/tagalign.go rename to pkg/golinters/tagalign/testdata/fix/in/tagalign.go index ecf1a54e2e76..50253a3ae460 100644 --- a/test/testdata/fix/in/tagalign.go +++ b/pkg/golinters/tagalign/testdata/fix/in/tagalign.go @@ -1,5 +1,5 @@ //golangcitest:args -Etagalign -//golangcitest:config_path testdata/configs/tagalign_strict.yml +//golangcitest:config_path testdata/tagalign_strict.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/fix/out/tagalign.go b/pkg/golinters/tagalign/testdata/fix/out/tagalign.go similarity index 85% rename from test/testdata/fix/out/tagalign.go rename to pkg/golinters/tagalign/testdata/fix/out/tagalign.go index 4bada9c75c1c..650cf67076ef 100644 --- a/test/testdata/fix/out/tagalign.go +++ b/pkg/golinters/tagalign/testdata/fix/out/tagalign.go @@ -1,5 +1,5 @@ //golangcitest:args -Etagalign -//golangcitest:config_path testdata/configs/tagalign_strict.yml +//golangcitest:config_path testdata/tagalign_strict.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/tagalign.go b/pkg/golinters/tagalign/testdata/tagalign.go similarity index 100% rename from test/testdata/tagalign.go rename to pkg/golinters/tagalign/testdata/tagalign.go diff --git a/test/testdata/tagalign_align_only.go b/pkg/golinters/tagalign/testdata/tagalign_align_only.go similarity index 96% rename from test/testdata/tagalign_align_only.go rename to pkg/golinters/tagalign/testdata/tagalign_align_only.go index a71f958e74d4..4fb5fbfb15b8 100644 --- a/test/testdata/tagalign_align_only.go +++ b/pkg/golinters/tagalign/testdata/tagalign_align_only.go @@ -1,5 +1,5 @@ //golangcitest:args -Etagalign -//golangcitest:config_path testdata/configs/tagalign_align_only.yml +//golangcitest:config_path testdata/tagalign_align_only.yml package testdata import "time" diff --git a/test/testdata/configs/tagalign_align_only.yml b/pkg/golinters/tagalign/testdata/tagalign_align_only.yml similarity index 100% rename from test/testdata/configs/tagalign_align_only.yml rename to pkg/golinters/tagalign/testdata/tagalign_align_only.yml diff --git a/test/testdata/tagalign_order_only.go b/pkg/golinters/tagalign/testdata/tagalign_order_only.go similarity index 92% rename from test/testdata/tagalign_order_only.go rename to pkg/golinters/tagalign/testdata/tagalign_order_only.go index 5837fc6d838a..c0ef82b2df16 100644 --- a/test/testdata/tagalign_order_only.go +++ b/pkg/golinters/tagalign/testdata/tagalign_order_only.go @@ -1,5 +1,5 @@ //golangcitest:args -Etagalign -//golangcitest:config_path testdata/configs/tagalign_order_only.yml +//golangcitest:config_path testdata/tagalign_order_only.yml package testdata import "time" diff --git a/test/testdata/configs/tagalign_order_only.yml b/pkg/golinters/tagalign/testdata/tagalign_order_only.yml similarity index 100% rename from test/testdata/configs/tagalign_order_only.yml rename to pkg/golinters/tagalign/testdata/tagalign_order_only.yml diff --git a/test/testdata/tagalign_sort_only.go b/pkg/golinters/tagalign/testdata/tagalign_sort_only.go similarity index 92% rename from test/testdata/tagalign_sort_only.go rename to pkg/golinters/tagalign/testdata/tagalign_sort_only.go index 600f4bbb2e8e..67118a25f732 100644 --- a/test/testdata/tagalign_sort_only.go +++ b/pkg/golinters/tagalign/testdata/tagalign_sort_only.go @@ -1,5 +1,5 @@ //golangcitest:args -Etagalign -//golangcitest:config_path testdata/configs/tagalign_sort_only.yml +//golangcitest:config_path testdata/tagalign_sort_only.yml package testdata import "time" diff --git a/test/testdata/configs/tagalign_sort_only.yml b/pkg/golinters/tagalign/testdata/tagalign_sort_only.yml similarity index 100% rename from test/testdata/configs/tagalign_sort_only.yml rename to pkg/golinters/tagalign/testdata/tagalign_sort_only.yml diff --git a/test/testdata/tagalign_strict.go b/pkg/golinters/tagalign/testdata/tagalign_strict.go similarity index 90% rename from test/testdata/tagalign_strict.go rename to pkg/golinters/tagalign/testdata/tagalign_strict.go index 6689d486fc52..f21f715a946a 100644 --- a/test/testdata/tagalign_strict.go +++ b/pkg/golinters/tagalign/testdata/tagalign_strict.go @@ -1,5 +1,5 @@ //golangcitest:args -Etagalign -//golangcitest:config_path testdata/configs/tagalign_strict.yml +//golangcitest:config_path testdata/tagalign_strict.yml package testdata import "time" diff --git a/test/testdata/configs/tagalign_strict.yml b/pkg/golinters/tagalign/testdata/tagalign_strict.yml similarity index 100% rename from test/testdata/configs/tagalign_strict.yml rename to pkg/golinters/tagalign/testdata/tagalign_strict.yml diff --git a/pkg/golinters/tagliatelle.go b/pkg/golinters/tagliatelle/tagliatelle.go similarity index 86% rename from pkg/golinters/tagliatelle.go rename to pkg/golinters/tagliatelle/tagliatelle.go index 73186035365b..d1674c3e9e28 100644 --- a/pkg/golinters/tagliatelle.go +++ b/pkg/golinters/tagliatelle/tagliatelle.go @@ -1,4 +1,4 @@ -package golinters +package tagliatelle import ( "github.com/ldez/tagliatelle" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewTagliatelle(settings *config.TagliatelleSettings) *goanalysis.Linter { +func New(settings *config.TagliatelleSettings) *goanalysis.Linter { cfg := tagliatelle.Config{ Rules: map[string]string{ "json": "camel", diff --git a/pkg/golinters/tagliatelle/tagliatelle_integration_test.go b/pkg/golinters/tagliatelle/tagliatelle_integration_test.go new file mode 100644 index 000000000000..ee5eb0e15fac --- /dev/null +++ b/pkg/golinters/tagliatelle/tagliatelle_integration_test.go @@ -0,0 +1,11 @@ +package tagliatelle + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/tagliatelle.go b/pkg/golinters/tagliatelle/testdata/tagliatelle.go similarity index 100% rename from test/testdata/tagliatelle.go rename to pkg/golinters/tagliatelle/testdata/tagliatelle.go diff --git a/pkg/golinters/tenv.go b/pkg/golinters/tenv/tenv.go similarity index 84% rename from pkg/golinters/tenv.go rename to pkg/golinters/tenv/tenv.go index 6c102711dae8..b80a783b6567 100644 --- a/pkg/golinters/tenv.go +++ b/pkg/golinters/tenv/tenv.go @@ -1,4 +1,4 @@ -package golinters +package tenv import ( "github.com/sivchari/tenv" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewTenv(settings *config.TenvSettings) *goanalysis.Linter { +func New(settings *config.TenvSettings) *goanalysis.Linter { a := tenv.Analyzer var cfg map[string]map[string]any diff --git a/pkg/golinters/tenv/tenv_integration_test.go b/pkg/golinters/tenv/tenv_integration_test.go new file mode 100644 index 000000000000..d7fdff3c0080 --- /dev/null +++ b/pkg/golinters/tenv/tenv_integration_test.go @@ -0,0 +1,11 @@ +package tenv + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/tenv.go b/pkg/golinters/tenv/testdata/tenv.go similarity index 96% rename from test/testdata/tenv.go rename to pkg/golinters/tenv/testdata/tenv.go index 7023ead8c710..986b2f5daee4 100644 --- a/test/testdata/tenv.go +++ b/pkg/golinters/tenv/testdata/tenv.go @@ -1,5 +1,5 @@ //golangcitest:args -Etenv -//golangcitest:config_path testdata/configs/tenv_all.yml +//golangcitest:config_path testdata/tenv_all.yml package testdata import ( diff --git a/test/testdata/tenv_all.go b/pkg/golinters/tenv/testdata/tenv_all.go similarity index 96% rename from test/testdata/tenv_all.go rename to pkg/golinters/tenv/testdata/tenv_all.go index 7023ead8c710..986b2f5daee4 100644 --- a/test/testdata/tenv_all.go +++ b/pkg/golinters/tenv/testdata/tenv_all.go @@ -1,5 +1,5 @@ //golangcitest:args -Etenv -//golangcitest:config_path testdata/configs/tenv_all.yml +//golangcitest:config_path testdata/tenv_all.yml package testdata import ( diff --git a/test/testdata/configs/tenv_all.yml b/pkg/golinters/tenv/testdata/tenv_all.yml similarity index 100% rename from test/testdata/configs/tenv_all.yml rename to pkg/golinters/tenv/testdata/tenv_all.yml diff --git a/test/testdata/tenv_all_test.go b/pkg/golinters/tenv/testdata/tenv_all_test.go similarity index 96% rename from test/testdata/tenv_all_test.go rename to pkg/golinters/tenv/testdata/tenv_all_test.go index b370915f6f8a..bd5fc97974b9 100644 --- a/test/testdata/tenv_all_test.go +++ b/pkg/golinters/tenv/testdata/tenv_all_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Etenv -//golangcitest:config_path testdata/configs/tenv_all.yml +//golangcitest:config_path testdata/tenv_all.yml package testdata import ( diff --git a/test/testdata/tenv_fuzz.go b/pkg/golinters/tenv/testdata/tenv_fuzz.go similarity index 100% rename from test/testdata/tenv_fuzz.go rename to pkg/golinters/tenv/testdata/tenv_fuzz.go diff --git a/test/testdata/tenv_test.go b/pkg/golinters/tenv/testdata/tenv_test.go similarity index 100% rename from test/testdata/tenv_test.go rename to pkg/golinters/tenv/testdata/tenv_test.go diff --git a/pkg/golinters/testableexamples.go b/pkg/golinters/testableexamples/testableexamples.go similarity index 83% rename from pkg/golinters/testableexamples.go rename to pkg/golinters/testableexamples/testableexamples.go index 2cb8127d6e67..6b76271dbab5 100644 --- a/pkg/golinters/testableexamples.go +++ b/pkg/golinters/testableexamples/testableexamples.go @@ -1,4 +1,4 @@ -package golinters +package testableexamples import ( "github.com/maratori/testableexamples/pkg/testableexamples" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewTestableexamples() *goanalysis.Linter { +func New() *goanalysis.Linter { a := testableexamples.NewAnalyzer() return goanalysis.NewLinter( diff --git a/pkg/golinters/testableexamples/testableexamples_integration_test.go b/pkg/golinters/testableexamples/testableexamples_integration_test.go new file mode 100644 index 000000000000..e614803aa6bf --- /dev/null +++ b/pkg/golinters/testableexamples/testableexamples_integration_test.go @@ -0,0 +1,11 @@ +package testableexamples + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/testableexamples_test.go b/pkg/golinters/testableexamples/testdata/testableexamples_test.go similarity index 100% rename from test/testdata/testableexamples_test.go rename to pkg/golinters/testableexamples/testdata/testableexamples_test.go diff --git a/test/testdata/testifylint.go b/pkg/golinters/testifylint/testdata/testifylint.go similarity index 100% rename from test/testdata/testifylint.go rename to pkg/golinters/testifylint/testdata/testifylint.go diff --git a/test/testdata/testifylint_bool_compare_only.go b/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.go similarity index 79% rename from test/testdata/testifylint_bool_compare_only.go rename to pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.go index 977e823ca5e8..77605ec8d28c 100644 --- a/test/testdata/testifylint_bool_compare_only.go +++ b/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.go @@ -1,5 +1,5 @@ //golangcitest:args -Etestifylint -//golangcitest:config_path testdata/configs/testifylint_bool_compare_only.yml +//golangcitest:config_path testdata/testifylint_bool_compare_only.yml package testdata import ( diff --git a/test/testdata/configs/testifylint_bool_compare_only.yml b/pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml similarity index 100% rename from test/testdata/configs/testifylint_bool_compare_only.yml rename to pkg/golinters/testifylint/testdata/testifylint_bool_compare_only.yml diff --git a/test/testdata/testifylint_require_error_only.go b/pkg/golinters/testifylint/testdata/testifylint_require_error_only.go similarity index 95% rename from test/testdata/testifylint_require_error_only.go rename to pkg/golinters/testifylint/testdata/testifylint_require_error_only.go index 0ba35e8403e9..c85d01e73d43 100644 --- a/test/testdata/testifylint_require_error_only.go +++ b/pkg/golinters/testifylint/testdata/testifylint_require_error_only.go @@ -1,5 +1,5 @@ //golangcitest:args -Etestifylint -//golangcitest:config_path testdata/configs/testifylint_require_error_only.yml +//golangcitest:config_path testdata/testifylint_require_error_only.yml package testdata import ( diff --git a/test/testdata/configs/testifylint_require_error_only.yml b/pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml similarity index 100% rename from test/testdata/configs/testifylint_require_error_only.yml rename to pkg/golinters/testifylint/testdata/testifylint_require_error_only.yml diff --git a/pkg/golinters/testifylint.go b/pkg/golinters/testifylint/testifylint.go similarity index 92% rename from pkg/golinters/testifylint.go rename to pkg/golinters/testifylint/testifylint.go index dd5763a3d9d2..55c96881d83b 100644 --- a/pkg/golinters/testifylint.go +++ b/pkg/golinters/testifylint/testifylint.go @@ -1,4 +1,4 @@ -package golinters +package testifylint import ( "github.com/Antonboom/testifylint/analyzer" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewTestifylint(settings *config.TestifylintSettings) *goanalysis.Linter { +func New(settings *config.TestifylintSettings) *goanalysis.Linter { a := analyzer.New() cfg := make(map[string]map[string]any) diff --git a/pkg/golinters/testifylint/testifylint_integration_test.go b/pkg/golinters/testifylint/testifylint_integration_test.go new file mode 100644 index 000000000000..0e6966f45187 --- /dev/null +++ b/pkg/golinters/testifylint/testifylint_integration_test.go @@ -0,0 +1,11 @@ +package testifylint + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/testpackage_test.go b/pkg/golinters/testpackage/testdata/testpackage_test.go similarity index 100% rename from test/testdata/testpackage_test.go rename to pkg/golinters/testpackage/testdata/testpackage_test.go diff --git a/pkg/golinters/testpackage.go b/pkg/golinters/testpackage/testpackage.go similarity index 87% rename from pkg/golinters/testpackage.go rename to pkg/golinters/testpackage/testpackage.go index d572ea0fe083..632152712bcc 100644 --- a/pkg/golinters/testpackage.go +++ b/pkg/golinters/testpackage/testpackage.go @@ -1,4 +1,4 @@ -package golinters +package testpackage import ( "strings" @@ -10,7 +10,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewTestpackage(cfg *config.TestpackageSettings) *goanalysis.Linter { +func New(cfg *config.TestpackageSettings) *goanalysis.Linter { a := testpackage.NewAnalyzer() var settings map[string]map[string]any diff --git a/pkg/golinters/testpackage/testpackage_integration_test.go b/pkg/golinters/testpackage/testpackage_integration_test.go new file mode 100644 index 000000000000..871b10afaf24 --- /dev/null +++ b/pkg/golinters/testpackage/testpackage_integration_test.go @@ -0,0 +1,11 @@ +package testpackage + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/thelper.go b/pkg/golinters/thelper/testdata/thelper.go similarity index 100% rename from test/testdata/thelper.go rename to pkg/golinters/thelper/testdata/thelper.go diff --git a/test/testdata/configs/thelper.yml b/pkg/golinters/thelper/testdata/thelper.yml similarity index 100% rename from test/testdata/configs/thelper.yml rename to pkg/golinters/thelper/testdata/thelper.yml diff --git a/test/testdata/thelper_fuzz.go b/pkg/golinters/thelper/testdata/thelper_fuzz.go similarity index 100% rename from test/testdata/thelper_fuzz.go rename to pkg/golinters/thelper/testdata/thelper_fuzz.go diff --git a/test/testdata/thelper_with_options.go b/pkg/golinters/thelper/testdata/thelper_with_options.go similarity index 87% rename from test/testdata/thelper_with_options.go rename to pkg/golinters/thelper/testdata/thelper_with_options.go index cf39e8a985d6..754294bcbf47 100644 --- a/test/testdata/thelper_with_options.go +++ b/pkg/golinters/thelper/testdata/thelper_with_options.go @@ -1,5 +1,5 @@ //golangcitest:args -Ethelper -//golangcitest:config_path testdata/configs/thelper.yml +//golangcitest:config_path testdata/thelper.yml package testdata import "testing" diff --git a/pkg/golinters/thelper.go b/pkg/golinters/thelper/thelper.go similarity index 94% rename from pkg/golinters/thelper.go rename to pkg/golinters/thelper/thelper.go index b1f96d3d6241..cc6ea755c9ed 100644 --- a/pkg/golinters/thelper.go +++ b/pkg/golinters/thelper/thelper.go @@ -1,4 +1,4 @@ -package golinters +package thelper import ( "strings" @@ -12,7 +12,7 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/internal" ) -func NewThelper(cfg *config.ThelperSettings) *goanalysis.Linter { +func New(cfg *config.ThelperSettings) *goanalysis.Linter { a := analyzer.NewAnalyzer() opts := map[string]struct{}{ diff --git a/pkg/golinters/thelper/thelper_integration_test.go b/pkg/golinters/thelper/thelper_integration_test.go new file mode 100644 index 000000000000..5ff8792da8c8 --- /dev/null +++ b/pkg/golinters/thelper/thelper_integration_test.go @@ -0,0 +1,11 @@ +package thelper + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/tparallel_happy_path_test.go b/pkg/golinters/tparallel/testdata/tparallel_happy_path_test.go similarity index 100% rename from test/testdata/tparallel_happy_path_test.go rename to pkg/golinters/tparallel/testdata/tparallel_happy_path_test.go diff --git a/test/testdata/tparallel_missing_subtest_test.go b/pkg/golinters/tparallel/testdata/tparallel_missing_subtest_test.go similarity index 100% rename from test/testdata/tparallel_missing_subtest_test.go rename to pkg/golinters/tparallel/testdata/tparallel_missing_subtest_test.go diff --git a/test/testdata/tparallel_missing_toplevel_test.go b/pkg/golinters/tparallel/testdata/tparallel_missing_toplevel_test.go similarity index 100% rename from test/testdata/tparallel_missing_toplevel_test.go rename to pkg/golinters/tparallel/testdata/tparallel_missing_toplevel_test.go diff --git a/pkg/golinters/tparallel.go b/pkg/golinters/tparallel/tparallel.go similarity index 82% rename from pkg/golinters/tparallel.go rename to pkg/golinters/tparallel/tparallel.go index 80569ced7413..4f7c43a99d1b 100644 --- a/pkg/golinters/tparallel.go +++ b/pkg/golinters/tparallel/tparallel.go @@ -1,4 +1,4 @@ -package golinters +package tparallel import ( "github.com/moricho/tparallel" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewTparallel() *goanalysis.Linter { +func New() *goanalysis.Linter { a := tparallel.Analyzer return goanalysis.NewLinter( a.Name, diff --git a/pkg/golinters/tparallel/tparallel_integration_test.go b/pkg/golinters/tparallel/tparallel_integration_test.go new file mode 100644 index 000000000000..7b57d308da09 --- /dev/null +++ b/pkg/golinters/tparallel/tparallel_integration_test.go @@ -0,0 +1,11 @@ +package tparallel + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/unconvert.go b/pkg/golinters/unconvert/testdata/unconvert.go similarity index 100% rename from test/testdata/unconvert.go rename to pkg/golinters/unconvert/testdata/unconvert.go diff --git a/pkg/golinters/unconvert.go b/pkg/golinters/unconvert/unconvert.go similarity index 86% rename from pkg/golinters/unconvert.go rename to pkg/golinters/unconvert/unconvert.go index c6e6bda931ba..fe3247e43d2a 100644 --- a/pkg/golinters/unconvert.go +++ b/pkg/golinters/unconvert/unconvert.go @@ -1,4 +1,4 @@ -package golinters +package unconvert import ( "sync" @@ -12,14 +12,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const unconvertName = "unconvert" +const name = "unconvert" -func NewUnconvert(settings *config.UnconvertSettings) *goanalysis.Linter { +func New(settings *config.UnconvertSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: unconvertName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Run: func(pass *analysis.Pass) (any, error) { issues := runUnconvert(pass, settings) @@ -37,7 +37,7 @@ func NewUnconvert(settings *config.UnconvertSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - unconvertName, + name, "Remove unnecessary type conversions", []*analysis.Analyzer{analyzer}, nil, @@ -54,7 +54,7 @@ func runUnconvert(pass *analysis.Pass, settings *config.UnconvertSettings) []goa issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: position, Text: "unnecessary conversion", - FromLinter: unconvertName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/unconvert/unconvert_integration_test.go b/pkg/golinters/unconvert/unconvert_integration_test.go new file mode 100644 index 000000000000..3404eb073b00 --- /dev/null +++ b/pkg/golinters/unconvert/unconvert_integration_test.go @@ -0,0 +1,11 @@ +package unconvert + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/unparam.go b/pkg/golinters/unparam/testdata/unparam.go similarity index 100% rename from test/testdata/unparam.go rename to pkg/golinters/unparam/testdata/unparam.go diff --git a/pkg/golinters/unparam.go b/pkg/golinters/unparam/unparam.go similarity index 91% rename from pkg/golinters/unparam.go rename to pkg/golinters/unparam/unparam.go index 6ec35a00f83f..06e302b6b9ca 100644 --- a/pkg/golinters/unparam.go +++ b/pkg/golinters/unparam/unparam.go @@ -1,4 +1,4 @@ -package golinters +package unparam import ( "sync" @@ -14,14 +14,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const unparamName = "unparam" +const name = "unparam" -func NewUnparam(settings *config.UnparamSettings) *goanalysis.Linter { +func New(settings *config.UnparamSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: unparamName, + Name: name, Doc: goanalysis.TheOnlyanalyzerDoc, Requires: []*analysis.Analyzer{buildssa.Analyzer}, Run: func(pass *analysis.Pass) (any, error) { @@ -43,7 +43,7 @@ func NewUnparam(settings *config.UnparamSettings) *goanalysis.Linter { } return goanalysis.NewLinter( - unparamName, + name, "Reports unused function parameters", []*analysis.Analyzer{analyzer}, nil, @@ -82,7 +82,7 @@ func runUnparam(pass *analysis.Pass, settings *config.UnparamSettings) ([]goanal issues = append(issues, goanalysis.NewIssue(&result.Issue{ Pos: pass.Fset.Position(i.Pos()), Text: i.Message(), - FromLinter: unparamName, + FromLinter: name, }, pass)) } diff --git a/pkg/golinters/unparam/unparam_integration_test.go b/pkg/golinters/unparam/unparam_integration_test.go new file mode 100644 index 000000000000..279663fd261e --- /dev/null +++ b/pkg/golinters/unparam/unparam_integration_test.go @@ -0,0 +1,11 @@ +package unparam + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/unused.go b/pkg/golinters/unused/testdata/unused.go similarity index 100% rename from test/testdata/unused.go rename to pkg/golinters/unused/testdata/unused.go diff --git a/pkg/golinters/unused.go b/pkg/golinters/unused/unused.go similarity index 93% rename from pkg/golinters/unused.go rename to pkg/golinters/unused/unused.go index 5e3a8dbd7cfa..1cadb71a38b8 100644 --- a/pkg/golinters/unused.go +++ b/pkg/golinters/unused/unused.go @@ -1,4 +1,4 @@ -package golinters +package unused import ( "fmt" @@ -17,14 +17,14 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const unusedName = "unused" +const name = "unused" -func NewUnused(settings *config.UnusedSettings, scSettings *config.StaticCheckSettings) *goanalysis.Linter { +func New(settings *config.UnusedSettings, scSettings *config.StaticCheckSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue analyzer := &analysis.Analyzer{ - Name: unusedName, + Name: name, Doc: unused.Analyzer.Analyzer.Doc, Requires: unused.Analyzer.Analyzer.Requires, Run: func(pass *analysis.Pass) (any, error) { @@ -44,7 +44,7 @@ func NewUnused(settings *config.UnusedSettings, scSettings *config.StaticCheckSe internal.SetAnalyzerGoVersion(analyzer, internal.GetGoVersion(scSettings)) return goanalysis.NewLinter( - unusedName, + name, "Checks Go code for unused constants, variables, functions and types", []*analysis.Analyzer{analyzer}, nil, @@ -75,7 +75,7 @@ func runUnused(pass *analysis.Pass, cfg *config.UnusedSettings) []goanalysis.Iss } issue := goanalysis.NewIssue(&result.Issue{ - FromLinter: unusedName, + FromLinter: name, Text: fmt.Sprintf("%s %s is unused", object.Kind, object.Name), Pos: object.Position, }, pass) diff --git a/pkg/golinters/unused/unused_integration_test.go b/pkg/golinters/unused/unused_integration_test.go new file mode 100644 index 000000000000..d8610ebc4f26 --- /dev/null +++ b/pkg/golinters/unused/unused_integration_test.go @@ -0,0 +1,11 @@ +package unused + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/usestdlibvars.go b/pkg/golinters/usestdlibvars/testdata/usestdlibvars.go similarity index 100% rename from test/testdata/usestdlibvars.go rename to pkg/golinters/usestdlibvars/testdata/usestdlibvars.go diff --git a/test/testdata/usestdlibvars_non_default.go b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.go similarity index 95% rename from test/testdata/usestdlibvars_non_default.go rename to pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.go index c9915fad7a01..14f4a93a6b3c 100644 --- a/test/testdata/usestdlibvars_non_default.go +++ b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.go @@ -1,5 +1,5 @@ //golangcitest:args -Eusestdlibvars -//golangcitest:config_path testdata/configs/usestdlibvars_non_default.yml +//golangcitest:config_path testdata/usestdlibvars_non_default.yml package testdata import "net/http" diff --git a/test/testdata/configs/usestdlibvars_non_default.yml b/pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml similarity index 100% rename from test/testdata/configs/usestdlibvars_non_default.yml rename to pkg/golinters/usestdlibvars/testdata/usestdlibvars_non_default.yml diff --git a/pkg/golinters/usestdlibvars.go b/pkg/golinters/usestdlibvars/usestdlibvars.go similarity index 92% rename from pkg/golinters/usestdlibvars.go rename to pkg/golinters/usestdlibvars/usestdlibvars.go index 1b2e5e5c7944..050e47f24cce 100644 --- a/pkg/golinters/usestdlibvars.go +++ b/pkg/golinters/usestdlibvars/usestdlibvars.go @@ -1,4 +1,4 @@ -package golinters +package usestdlibvars import ( "github.com/sashamelentyev/usestdlibvars/pkg/analyzer" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewUseStdlibVars(cfg *config.UseStdlibVarsSettings) *goanalysis.Linter { +func New(cfg *config.UseStdlibVarsSettings) *goanalysis.Linter { a := analyzer.New() cfgMap := make(map[string]map[string]any) diff --git a/pkg/golinters/usestdlibvars/usestdlibvars_integration_test.go b/pkg/golinters/usestdlibvars/usestdlibvars_integration_test.go new file mode 100644 index 000000000000..81d589047a1d --- /dev/null +++ b/pkg/golinters/usestdlibvars/usestdlibvars_integration_test.go @@ -0,0 +1,11 @@ +package usestdlibvars + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/varnamelen.go b/pkg/golinters/varnamelen/testdata/varnamelen.go similarity index 100% rename from test/testdata/varnamelen.go rename to pkg/golinters/varnamelen/testdata/varnamelen.go diff --git a/pkg/golinters/varnamelen.go b/pkg/golinters/varnamelen/varnamelen.go similarity index 93% rename from pkg/golinters/varnamelen.go rename to pkg/golinters/varnamelen/varnamelen.go index bf2e8bff6b40..6cb57ffa57c4 100644 --- a/pkg/golinters/varnamelen.go +++ b/pkg/golinters/varnamelen/varnamelen.go @@ -1,4 +1,4 @@ -package golinters +package varnamelen import ( "strconv" @@ -11,7 +11,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewVarnamelen(settings *config.VarnamelenSettings) *goanalysis.Linter { +func New(settings *config.VarnamelenSettings) *goanalysis.Linter { analyzer := varnamelen.NewAnalyzer() cfg := map[string]map[string]any{} diff --git a/pkg/golinters/varnamelen/varnamelen_integration_test.go b/pkg/golinters/varnamelen/varnamelen_integration_test.go new file mode 100644 index 000000000000..4c3367590cb6 --- /dev/null +++ b/pkg/golinters/varnamelen/varnamelen_integration_test.go @@ -0,0 +1,11 @@ +package varnamelen + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/wastedassign.go b/pkg/golinters/wastedassign/testdata/wastedassign.go similarity index 100% rename from test/testdata/wastedassign.go rename to pkg/golinters/wastedassign/testdata/wastedassign.go diff --git a/pkg/golinters/wastedassign.go b/pkg/golinters/wastedassign/wastedassign.go similarity index 84% rename from pkg/golinters/wastedassign.go rename to pkg/golinters/wastedassign/wastedassign.go index 8b48a21cc80a..094fa95c2943 100644 --- a/pkg/golinters/wastedassign.go +++ b/pkg/golinters/wastedassign/wastedassign.go @@ -1,4 +1,4 @@ -package golinters +package wastedassign import ( "github.com/sanposhiho/wastedassign/v2" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewWastedAssign() *goanalysis.Linter { +func New() *goanalysis.Linter { a := wastedassign.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/wastedassign/wastedassign_integration_test.go b/pkg/golinters/wastedassign/wastedassign_integration_test.go new file mode 100644 index 000000000000..581e237beeab --- /dev/null +++ b/pkg/golinters/wastedassign/wastedassign_integration_test.go @@ -0,0 +1,11 @@ +package wastedassign + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/fix/in/whitespace.go b/pkg/golinters/whitespace/testdata/fix/in/whitespace.go similarity index 93% rename from test/testdata/fix/in/whitespace.go rename to pkg/golinters/whitespace/testdata/fix/in/whitespace.go index 028d9d25693c..b10ca1718833 100644 --- a/test/testdata/fix/in/whitespace.go +++ b/pkg/golinters/whitespace/testdata/fix/in/whitespace.go @@ -1,5 +1,5 @@ //golangcitest:args -Ewhitespace -//golangcitest:config_path testdata/configs/whitespace-fix.yml +//golangcitest:config_path testdata/whitespace-fix.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/fix/out/whitespace.go b/pkg/golinters/whitespace/testdata/fix/out/whitespace.go similarity index 93% rename from test/testdata/fix/out/whitespace.go rename to pkg/golinters/whitespace/testdata/fix/out/whitespace.go index ec8d4065375b..a29fc4125fc7 100644 --- a/test/testdata/fix/out/whitespace.go +++ b/pkg/golinters/whitespace/testdata/fix/out/whitespace.go @@ -1,5 +1,5 @@ //golangcitest:args -Ewhitespace -//golangcitest:config_path testdata/configs/whitespace-fix.yml +//golangcitest:config_path testdata/whitespace-fix.yml //golangcitest:expected_exitcode 0 package p diff --git a/test/testdata/configs/whitespace-fix.yml b/pkg/golinters/whitespace/testdata/whitespace-fix.yml similarity index 100% rename from test/testdata/configs/whitespace-fix.yml rename to pkg/golinters/whitespace/testdata/whitespace-fix.yml diff --git a/pkg/golinters/whitespace.go b/pkg/golinters/whitespace/whitespace.go similarity index 93% rename from pkg/golinters/whitespace.go rename to pkg/golinters/whitespace/whitespace.go index 7a09e8d90426..1b445751521e 100644 --- a/pkg/golinters/whitespace.go +++ b/pkg/golinters/whitespace/whitespace.go @@ -1,4 +1,4 @@ -package golinters +package whitespace import ( "fmt" @@ -13,9 +13,9 @@ import ( "github.com/golangci/golangci-lint/pkg/result" ) -const whitespaceName = "whitespace" +const name = "whitespace" -func NewWhitespace(settings *config.WhitespaceSettings) *goanalysis.Linter { +func New(settings *config.WhitespaceSettings) *goanalysis.Linter { var mu sync.Mutex var resIssues []goanalysis.Issue @@ -63,7 +63,7 @@ func runWhitespace(pass *analysis.Pass, wsSettings whitespace.Settings) ([]goana issues := make([]goanalysis.Issue, len(lintIssues)) for i, issue := range lintIssues { report := &result.Issue{ - FromLinter: whitespaceName, + FromLinter: name, Pos: pass.Fset.PositionFor(issue.Diagnostic, false), Text: issue.Message, } diff --git a/pkg/golinters/whitespace/whitespace_integration_test.go b/pkg/golinters/whitespace/whitespace_integration_test.go new file mode 100644 index 000000000000..fd80dafbb651 --- /dev/null +++ b/pkg/golinters/whitespace/whitespace_integration_test.go @@ -0,0 +1,15 @@ +package whitespace + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/test/testdata/wrapcheck.go b/pkg/golinters/wrapcheck/testdata/wrapcheck.go similarity index 100% rename from test/testdata/wrapcheck.go rename to pkg/golinters/wrapcheck/testdata/wrapcheck.go diff --git a/pkg/golinters/wrapcheck.go b/pkg/golinters/wrapcheck/wrapcheck.go similarity index 89% rename from pkg/golinters/wrapcheck.go rename to pkg/golinters/wrapcheck/wrapcheck.go index 5a40e943c062..96ec2eeae047 100644 --- a/pkg/golinters/wrapcheck.go +++ b/pkg/golinters/wrapcheck/wrapcheck.go @@ -1,4 +1,4 @@ -package golinters +package wrapcheck import ( "github.com/tomarrell/wrapcheck/v2/wrapcheck" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewWrapcheck(settings *config.WrapcheckSettings) *goanalysis.Linter { +func New(settings *config.WrapcheckSettings) *goanalysis.Linter { cfg := wrapcheck.NewDefaultConfig() if settings != nil { if len(settings.IgnoreSigs) != 0 { diff --git a/pkg/golinters/wrapcheck/wrapcheck_integration_test.go b/pkg/golinters/wrapcheck/wrapcheck_integration_test.go new file mode 100644 index 000000000000..c9adfc841ad2 --- /dev/null +++ b/pkg/golinters/wrapcheck/wrapcheck_integration_test.go @@ -0,0 +1,11 @@ +package wrapcheck + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/wsl.go b/pkg/golinters/wsl/testdata/wsl.go similarity index 98% rename from test/testdata/wsl.go rename to pkg/golinters/wsl/testdata/wsl.go index af8d92b7c0dc..e3b2a6066b3b 100644 --- a/test/testdata/wsl.go +++ b/pkg/golinters/wsl/testdata/wsl.go @@ -1,5 +1,5 @@ //golangcitest:args -Ewsl -//golangcitest:config_path testdata/configs/wsl.yml +//golangcitest:config_path testdata/wsl.yml package testdata import ( diff --git a/test/testdata/configs/wsl.yml b/pkg/golinters/wsl/testdata/wsl.yml similarity index 100% rename from test/testdata/configs/wsl.yml rename to pkg/golinters/wsl/testdata/wsl.yml diff --git a/pkg/golinters/wsl.go b/pkg/golinters/wsl/wsl.go similarity index 94% rename from pkg/golinters/wsl.go rename to pkg/golinters/wsl/wsl.go index cbef76e18b29..5a72035b506c 100644 --- a/pkg/golinters/wsl.go +++ b/pkg/golinters/wsl/wsl.go @@ -1,4 +1,4 @@ -package golinters +package wsl import ( "github.com/bombsimon/wsl/v4" @@ -8,7 +8,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewWSL(settings *config.WSLSettings) *goanalysis.Linter { +func New(settings *config.WSLSettings) *goanalysis.Linter { var conf *wsl.Configuration if settings != nil { conf = &wsl.Configuration{ diff --git a/pkg/golinters/wsl/wsl_integration_test.go b/pkg/golinters/wsl/wsl_integration_test.go new file mode 100644 index 000000000000..e9de29926090 --- /dev/null +++ b/pkg/golinters/wsl/wsl_integration_test.go @@ -0,0 +1,11 @@ +package wsl + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/test/testdata/zerologlint/go.mod b/pkg/golinters/zerologlint/testdata/go.mod similarity index 100% rename from test/testdata/zerologlint/go.mod rename to pkg/golinters/zerologlint/testdata/go.mod diff --git a/test/testdata/zerologlint/go.sum b/pkg/golinters/zerologlint/testdata/go.sum similarity index 100% rename from test/testdata/zerologlint/go.sum rename to pkg/golinters/zerologlint/testdata/go.sum diff --git a/test/testdata/zerologlint/zerologlint.go b/pkg/golinters/zerologlint/testdata/zerologlint.go similarity index 100% rename from test/testdata/zerologlint/zerologlint.go rename to pkg/golinters/zerologlint/testdata/zerologlint.go diff --git a/pkg/golinters/zerologlint.go b/pkg/golinters/zerologlint/zerologlint.go similarity index 82% rename from pkg/golinters/zerologlint.go rename to pkg/golinters/zerologlint/zerologlint.go index a1346172af46..6ca74020c82d 100644 --- a/pkg/golinters/zerologlint.go +++ b/pkg/golinters/zerologlint/zerologlint.go @@ -1,4 +1,4 @@ -package golinters +package zerologlint import ( "github.com/ykadowak/zerologlint" @@ -7,7 +7,7 @@ import ( "github.com/golangci/golangci-lint/pkg/goanalysis" ) -func NewZerologLint() *goanalysis.Linter { +func New() *goanalysis.Linter { a := zerologlint.Analyzer return goanalysis.NewLinter( diff --git a/pkg/golinters/zerologlint/zerologlint_integration_test.go b/pkg/golinters/zerologlint/zerologlint_integration_test.go new file mode 100644 index 000000000000..09030a8837fd --- /dev/null +++ b/pkg/golinters/zerologlint/zerologlint_integration_test.go @@ -0,0 +1,11 @@ +package zerologlint + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index a881eb591595..2c7c449c6d2d 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -3,6 +3,112 @@ package lintersdb import ( "github.com/golangci/golangci-lint/pkg/config" "github.com/golangci/golangci-lint/pkg/golinters" + "github.com/golangci/golangci-lint/pkg/golinters/asasalint" + "github.com/golangci/golangci-lint/pkg/golinters/asciicheck" + "github.com/golangci/golangci-lint/pkg/golinters/bidichk" + "github.com/golangci/golangci-lint/pkg/golinters/bodyclose" + "github.com/golangci/golangci-lint/pkg/golinters/containedctx" + "github.com/golangci/golangci-lint/pkg/golinters/contextcheck" + "github.com/golangci/golangci-lint/pkg/golinters/copyloopvar" + "github.com/golangci/golangci-lint/pkg/golinters/cyclop" + "github.com/golangci/golangci-lint/pkg/golinters/decorder" + "github.com/golangci/golangci-lint/pkg/golinters/depguard" + "github.com/golangci/golangci-lint/pkg/golinters/dogsled" + "github.com/golangci/golangci-lint/pkg/golinters/dupl" + "github.com/golangci/golangci-lint/pkg/golinters/dupword" + "github.com/golangci/golangci-lint/pkg/golinters/durationcheck" + "github.com/golangci/golangci-lint/pkg/golinters/err113" + "github.com/golangci/golangci-lint/pkg/golinters/errcheck" + "github.com/golangci/golangci-lint/pkg/golinters/errchkjson" + "github.com/golangci/golangci-lint/pkg/golinters/errname" + "github.com/golangci/golangci-lint/pkg/golinters/errorlint" + "github.com/golangci/golangci-lint/pkg/golinters/execinquery" + "github.com/golangci/golangci-lint/pkg/golinters/exhaustive" + "github.com/golangci/golangci-lint/pkg/golinters/exhaustruct" + "github.com/golangci/golangci-lint/pkg/golinters/exportloopref" + "github.com/golangci/golangci-lint/pkg/golinters/fatcontext" + "github.com/golangci/golangci-lint/pkg/golinters/forbidigo" + "github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert" + "github.com/golangci/golangci-lint/pkg/golinters/funlen" + "github.com/golangci/golangci-lint/pkg/golinters/gci" + "github.com/golangci/golangci-lint/pkg/golinters/ginkgolinter" + "github.com/golangci/golangci-lint/pkg/golinters/gocheckcompilerdirectives" + "github.com/golangci/golangci-lint/pkg/golinters/gochecknoglobals" + "github.com/golangci/golangci-lint/pkg/golinters/gochecknoinits" + "github.com/golangci/golangci-lint/pkg/golinters/gochecksumtype" + "github.com/golangci/golangci-lint/pkg/golinters/gocognit" + "github.com/golangci/golangci-lint/pkg/golinters/goconst" + "github.com/golangci/golangci-lint/pkg/golinters/gocritic" + "github.com/golangci/golangci-lint/pkg/golinters/gocyclo" + "github.com/golangci/golangci-lint/pkg/golinters/godot" + "github.com/golangci/golangci-lint/pkg/golinters/godox" + "github.com/golangci/golangci-lint/pkg/golinters/gofmt" + "github.com/golangci/golangci-lint/pkg/golinters/gofumpt" + "github.com/golangci/golangci-lint/pkg/golinters/goheader" + "github.com/golangci/golangci-lint/pkg/golinters/goimports" + "github.com/golangci/golangci-lint/pkg/golinters/gomoddirectives" + "github.com/golangci/golangci-lint/pkg/golinters/gomodguard" + "github.com/golangci/golangci-lint/pkg/golinters/goprintffuncname" + "github.com/golangci/golangci-lint/pkg/golinters/gosec" + "github.com/golangci/golangci-lint/pkg/golinters/gosimple" + "github.com/golangci/golangci-lint/pkg/golinters/gosmopolitan" + "github.com/golangci/golangci-lint/pkg/golinters/govet" + "github.com/golangci/golangci-lint/pkg/golinters/grouper" + "github.com/golangci/golangci-lint/pkg/golinters/importas" + "github.com/golangci/golangci-lint/pkg/golinters/inamedparam" + "github.com/golangci/golangci-lint/pkg/golinters/ineffassign" + "github.com/golangci/golangci-lint/pkg/golinters/interfacebloat" + "github.com/golangci/golangci-lint/pkg/golinters/intrange" + "github.com/golangci/golangci-lint/pkg/golinters/ireturn" + "github.com/golangci/golangci-lint/pkg/golinters/lll" + "github.com/golangci/golangci-lint/pkg/golinters/loggercheck" + "github.com/golangci/golangci-lint/pkg/golinters/maintidx" + "github.com/golangci/golangci-lint/pkg/golinters/makezero" + "github.com/golangci/golangci-lint/pkg/golinters/mirror" + "github.com/golangci/golangci-lint/pkg/golinters/misspell" + "github.com/golangci/golangci-lint/pkg/golinters/mnd" + "github.com/golangci/golangci-lint/pkg/golinters/musttag" + "github.com/golangci/golangci-lint/pkg/golinters/nakedret" + "github.com/golangci/golangci-lint/pkg/golinters/nestif" + "github.com/golangci/golangci-lint/pkg/golinters/nilerr" + "github.com/golangci/golangci-lint/pkg/golinters/nilnil" + "github.com/golangci/golangci-lint/pkg/golinters/nlreturn" + "github.com/golangci/golangci-lint/pkg/golinters/noctx" + "github.com/golangci/golangci-lint/pkg/golinters/nolintlint" + "github.com/golangci/golangci-lint/pkg/golinters/nonamedreturns" + "github.com/golangci/golangci-lint/pkg/golinters/nosprintfhostport" + "github.com/golangci/golangci-lint/pkg/golinters/paralleltest" + "github.com/golangci/golangci-lint/pkg/golinters/perfsprint" + "github.com/golangci/golangci-lint/pkg/golinters/prealloc" + "github.com/golangci/golangci-lint/pkg/golinters/predeclared" + "github.com/golangci/golangci-lint/pkg/golinters/promlinter" + "github.com/golangci/golangci-lint/pkg/golinters/protogetter" + "github.com/golangci/golangci-lint/pkg/golinters/reassign" + "github.com/golangci/golangci-lint/pkg/golinters/revive" + "github.com/golangci/golangci-lint/pkg/golinters/rowserrcheck" + "github.com/golangci/golangci-lint/pkg/golinters/sloglint" + "github.com/golangci/golangci-lint/pkg/golinters/spancheck" + "github.com/golangci/golangci-lint/pkg/golinters/sqlclosecheck" + "github.com/golangci/golangci-lint/pkg/golinters/staticcheck" + "github.com/golangci/golangci-lint/pkg/golinters/stylecheck" + "github.com/golangci/golangci-lint/pkg/golinters/tagalign" + "github.com/golangci/golangci-lint/pkg/golinters/tagliatelle" + "github.com/golangci/golangci-lint/pkg/golinters/tenv" + "github.com/golangci/golangci-lint/pkg/golinters/testableexamples" + "github.com/golangci/golangci-lint/pkg/golinters/testifylint" + "github.com/golangci/golangci-lint/pkg/golinters/testpackage" + "github.com/golangci/golangci-lint/pkg/golinters/thelper" + "github.com/golangci/golangci-lint/pkg/golinters/tparallel" + "github.com/golangci/golangci-lint/pkg/golinters/unconvert" + "github.com/golangci/golangci-lint/pkg/golinters/unparam" + "github.com/golangci/golangci-lint/pkg/golinters/unused" + "github.com/golangci/golangci-lint/pkg/golinters/usestdlibvars" + "github.com/golangci/golangci-lint/pkg/golinters/varnamelen" + "github.com/golangci/golangci-lint/pkg/golinters/wastedassign" + "github.com/golangci/golangci-lint/pkg/golinters/whitespace" + "github.com/golangci/golangci-lint/pkg/golinters/wrapcheck" + "github.com/golangci/golangci-lint/pkg/golinters/wsl" + "github.com/golangci/golangci-lint/pkg/golinters/zerologlint" "github.com/golangci/golangci-lint/pkg/lint/linter" ) @@ -26,53 +132,53 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { // The linters are sorted in the alphabetical order (case-insensitive). // When a new linter is added the version in `WithSince(...)` must be the next minor version of golangci-lint. return []*linter.Config{ - linter.NewConfig(golinters.NewAsasalint(&cfg.LintersSettings.Asasalint)). + linter.NewConfig(asasalint.New(&cfg.LintersSettings.Asasalint)). WithSince("1.47.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/alingse/asasalint"), - linter.NewConfig(golinters.NewAsciicheck()). + linter.NewConfig(asciicheck.New()). WithSince("v1.26.0"). WithPresets(linter.PresetBugs, linter.PresetStyle). WithURL("https://github.com/tdakkota/asciicheck"), - linter.NewConfig(golinters.NewBiDiChk(&cfg.LintersSettings.BiDiChk)). + linter.NewConfig(bidichk.New(&cfg.LintersSettings.BiDiChk)). WithSince("1.43.0"). WithPresets(linter.PresetBugs). WithURL("https://github.com/breml/bidichk"), - linter.NewConfig(golinters.NewBodyclose()). + linter.NewConfig(bodyclose.New()). WithSince("v1.18.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetPerformance, linter.PresetBugs). WithURL("https://github.com/timakin/bodyclose"), - linter.NewConfig(golinters.NewContainedCtx()). + linter.NewConfig(containedctx.New()). WithSince("1.44.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle). WithURL("https://github.com/sivchari/containedctx"), - linter.NewConfig(golinters.NewContextCheck()). + linter.NewConfig(contextcheck.New()). WithSince("v1.43.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/kkHAIKE/contextcheck"), - linter.NewConfig(golinters.NewCopyLoopVar(&cfg.LintersSettings.CopyLoopVar)). + linter.NewConfig(copyloopvar.New(&cfg.LintersSettings.CopyLoopVar)). WithSince("v1.57.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/karamaru-alpha/copyloopvar"). WithNoopFallback(cfg, linter.IsGoLowerThanGo122()), - linter.NewConfig(golinters.NewCyclop(&cfg.LintersSettings.Cyclop)). + linter.NewConfig(cyclop.New(&cfg.LintersSettings.Cyclop)). WithSince("v1.37.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetComplexity). WithURL("https://github.com/bkielbasa/cyclop"), - linter.NewConfig(golinters.NewDecorder(&cfg.LintersSettings.Decorder)). + linter.NewConfig(decorder.New(&cfg.LintersSettings.Decorder)). WithSince("v1.44.0"). WithPresets(linter.PresetFormatting, linter.PresetStyle). WithURL("https://gitlab.com/bosi/decorder"), @@ -84,64 +190,64 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/remyoudompheng/go-misc/tree/master/deadcode"). Deprecated("The owner seems to have abandoned the linter.", "v1.49.0", "unused"), - linter.NewConfig(golinters.NewDepguard(&cfg.LintersSettings.Depguard)). + linter.NewConfig(depguard.New(&cfg.LintersSettings.Depguard)). WithSince("v1.4.0"). WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule). WithURL("https://github.com/OpenPeeDeeP/depguard"), - linter.NewConfig(golinters.NewDogsled(&cfg.LintersSettings.Dogsled)). + linter.NewConfig(dogsled.New(&cfg.LintersSettings.Dogsled)). WithSince("v1.19.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/alexkohler/dogsled"), - linter.NewConfig(golinters.NewDupl(&cfg.LintersSettings.Dupl)). + linter.NewConfig(dupl.New(&cfg.LintersSettings.Dupl)). WithSince("v1.0.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/mibk/dupl"), - linter.NewConfig(golinters.NewDupWord(&cfg.LintersSettings.DupWord)). + linter.NewConfig(dupword.New(&cfg.LintersSettings.DupWord)). WithSince("1.50.0"). WithPresets(linter.PresetComment). WithURL("https://github.com/Abirdcfly/dupword"), - linter.NewConfig(golinters.NewDurationCheck()). + linter.NewConfig(durationcheck.New()). WithSince("v1.37.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/charithe/durationcheck"), - linter.NewConfig(golinters.NewErrcheck(&cfg.LintersSettings.Errcheck)). + linter.NewConfig(errcheck.New(&cfg.LintersSettings.Errcheck)). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs, linter.PresetError). WithURL("https://github.com/kisielk/errcheck"), - linter.NewConfig(golinters.NewErrChkJSON(&cfg.LintersSettings.ErrChkJSON)). + linter.NewConfig(errchkjson.New(&cfg.LintersSettings.ErrChkJSON)). WithSince("1.44.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/breml/errchkjson"), - linter.NewConfig(golinters.NewErrName()). + linter.NewConfig(errname.New()). WithSince("v1.42.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/Antonboom/errname"), - linter.NewConfig(golinters.NewErrorLint(&cfg.LintersSettings.ErrorLint)). + linter.NewConfig(errorlint.New(&cfg.LintersSettings.ErrorLint)). WithSince("v1.32.0"). WithPresets(linter.PresetBugs, linter.PresetError). WithLoadForGoAnalysis(). WithURL("https://github.com/polyfloyd/go-errorlint"), - linter.NewConfig(golinters.NewExecInQuery()). + linter.NewConfig(execinquery.New()). WithSince("v1.46.0"). WithPresets(linter.PresetSQL). WithLoadForGoAnalysis(). WithURL("https://github.com/lufeee/execinquery"), - linter.NewConfig(golinters.NewExhaustive(&cfg.LintersSettings.Exhaustive)). + linter.NewConfig(exhaustive.New(&cfg.LintersSettings.Exhaustive)). WithSince(" v1.28.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). @@ -154,19 +260,19 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/mbilski/exhaustivestruct"). Deprecated("The repository of the linter has been deprecated by the owner.", "v1.46.0", "exhaustruct"), - linter.NewConfig(golinters.NewExhaustruct(&cfg.LintersSettings.Exhaustruct)). + linter.NewConfig(exhaustruct.New(&cfg.LintersSettings.Exhaustruct)). WithSince("v1.46.0"). WithPresets(linter.PresetStyle, linter.PresetTest). WithLoadForGoAnalysis(). WithURL("https://github.com/GaijinEntertainment/go-exhaustruct"), - linter.NewConfig(golinters.NewExportLoopRef()). + linter.NewConfig(exportloopref.New()). WithSince("v1.28.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/kyoh86/exportloopref"), - linter.NewConfig(golinters.NewForbidigo(&cfg.LintersSettings.Forbidigo)). + linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)). WithSince("v1.34.0"). WithPresets(linter.PresetStyle). // Strictly speaking, @@ -176,114 +282,114 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/ashanbrown/forbidigo"), - linter.NewConfig(golinters.NewForceTypeAssert()). + linter.NewConfig(forcetypeassert.New()). WithSince("v1.38.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/gostaticanalysis/forcetypeassert"), - linter.NewConfig(golinters.NewFatContext()). + linter.NewConfig(fatcontext.New()). WithSince("1.58.0"). WithPresets(linter.PresetPerformance). WithLoadForGoAnalysis(). WithURL("https://github.com/Crocmagnon/fatcontext"), - linter.NewConfig(golinters.NewFunlen(&cfg.LintersSettings.Funlen)). + linter.NewConfig(funlen.New(&cfg.LintersSettings.Funlen)). WithSince("v1.18.0"). WithPresets(linter.PresetComplexity). WithURL("https://github.com/ultraware/funlen"), - linter.NewConfig(golinters.NewGci(&cfg.LintersSettings.Gci)). + linter.NewConfig(gci.New(&cfg.LintersSettings.Gci)). WithSince("v1.30.0"). WithPresets(linter.PresetFormatting, linter.PresetImport). WithAutoFix(). WithURL("https://github.com/daixiang0/gci"), - linter.NewConfig(golinters.NewGinkgoLinter(&cfg.LintersSettings.GinkgoLinter)). + linter.NewConfig(ginkgolinter.New(&cfg.LintersSettings.GinkgoLinter)). WithSince("v1.51.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle). WithURL("https://github.com/nunnatsa/ginkgolinter"), - linter.NewConfig(golinters.NewGoCheckCompilerDirectives()). + linter.NewConfig(gocheckcompilerdirectives.New()). WithSince("v1.51.0"). WithPresets(linter.PresetBugs). WithURL("https://github.com/leighmcculloch/gocheckcompilerdirectives"), - linter.NewConfig(golinters.NewGochecknoglobals()). + linter.NewConfig(gochecknoglobals.New()). WithSince("v1.12.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/leighmcculloch/gochecknoglobals"), - linter.NewConfig(golinters.NewGochecknoinits()). + linter.NewConfig(gochecknoinits.New()). WithSince("v1.12.0"). WithPresets(linter.PresetStyle), - linter.NewConfig(golinters.NewGoCheckSumType()). + linter.NewConfig(gochecksumtype.New()). WithSince("v1.55.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/alecthomas/go-check-sumtype"), - linter.NewConfig(golinters.NewGocognit(&cfg.LintersSettings.Gocognit)). + linter.NewConfig(gocognit.New(&cfg.LintersSettings.Gocognit)). WithSince("v1.20.0"). WithPresets(linter.PresetComplexity). WithURL("https://github.com/uudashr/gocognit"), - linter.NewConfig(golinters.NewGoconst(&cfg.LintersSettings.Goconst)). + linter.NewConfig(goconst.New(&cfg.LintersSettings.Goconst)). WithSince("v1.0.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/jgautheron/goconst"), - linter.NewConfig(golinters.NewGoCritic(&cfg.LintersSettings.Gocritic)). + linter.NewConfig(gocritic.New(&cfg.LintersSettings.Gocritic)). WithSince("v1.12.0"). WithPresets(linter.PresetStyle, linter.PresetMetaLinter). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/go-critic/go-critic"), - linter.NewConfig(golinters.NewGocyclo(&cfg.LintersSettings.Gocyclo)). + linter.NewConfig(gocyclo.New(&cfg.LintersSettings.Gocyclo)). WithSince("v1.0.0"). WithPresets(linter.PresetComplexity). WithURL("https://github.com/fzipp/gocyclo"), - linter.NewConfig(golinters.NewGodot(&cfg.LintersSettings.Godot)). + linter.NewConfig(godot.New(&cfg.LintersSettings.Godot)). WithSince("v1.25.0"). WithPresets(linter.PresetStyle, linter.PresetComment). WithAutoFix(). WithURL("https://github.com/tetafro/godot"), - linter.NewConfig(golinters.NewGodox(&cfg.LintersSettings.Godox)). + linter.NewConfig(godox.New(&cfg.LintersSettings.Godox)). WithSince("v1.19.0"). WithPresets(linter.PresetStyle, linter.PresetComment). WithURL("https://github.com/matoous/godox"), - linter.NewConfig(golinters.NewErr113()). + linter.NewConfig(err113.New()). WithSince("v1.26.0"). WithPresets(linter.PresetStyle, linter.PresetError). WithLoadForGoAnalysis(). WithAlternativeNames("goerr113"). WithURL("https://github.com/Djarvur/go-err113"), - linter.NewConfig(golinters.NewGofmt(&cfg.LintersSettings.Gofmt)). + linter.NewConfig(gofmt.New(&cfg.LintersSettings.Gofmt)). WithSince("v1.0.0"). WithPresets(linter.PresetFormatting). WithAutoFix(). WithURL("https://pkg.go.dev/cmd/gofmt"), - linter.NewConfig(golinters.NewGofumpt(&cfg.LintersSettings.Gofumpt)). + linter.NewConfig(gofumpt.New(&cfg.LintersSettings.Gofumpt)). WithSince("v1.28.0"). WithPresets(linter.PresetFormatting). WithAutoFix(). WithURL("https://github.com/mvdan/gofumpt"), - linter.NewConfig(golinters.NewGoHeader(&cfg.LintersSettings.Goheader)). + linter.NewConfig(goheader.New(&cfg.LintersSettings.Goheader)). WithSince("v1.28.0"). WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/denis-tingaikin/go-header"), - linter.NewConfig(golinters.NewGoimports(&cfg.LintersSettings.Goimports)). + linter.NewConfig(goimports.New(&cfg.LintersSettings.Goimports)). WithSince("v1.20.0"). WithPresets(linter.PresetFormatting, linter.PresetImport). WithAutoFix(). @@ -296,40 +402,40 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/golang/lint"). Deprecated("The repository of the linter has been archived by the owner.", "v1.41.0", "revive"), - linter.NewConfig(golinters.NewMND(&cfg.LintersSettings.Mnd)). + linter.NewConfig(mnd.New(&cfg.LintersSettings.Mnd)). WithSince("v1.22.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/tommy-muehle/go-mnd"), - linter.NewConfig(golinters.NewGoMND(&cfg.LintersSettings.Gomnd)). + linter.NewConfig(mnd.NewGoMND(&cfg.LintersSettings.Gomnd)). WithSince("v1.22.0"). WithPresets(linter.PresetStyle). Deprecated("The linter has been renamed.", "v1.58.0", "mnd"). WithURL("https://github.com/tommy-muehle/go-mnd"), - linter.NewConfig(golinters.NewGoModDirectives(&cfg.LintersSettings.GoModDirectives)). + linter.NewConfig(gomoddirectives.New(&cfg.LintersSettings.GoModDirectives)). WithSince("v1.39.0"). WithPresets(linter.PresetStyle, linter.PresetModule). WithURL("https://github.com/ldez/gomoddirectives"), - linter.NewConfig(golinters.NewGomodguard(&cfg.LintersSettings.Gomodguard)). + linter.NewConfig(gomodguard.New(&cfg.LintersSettings.Gomodguard)). WithSince("v1.25.0"). WithPresets(linter.PresetStyle, linter.PresetImport, linter.PresetModule). WithURL("https://github.com/ryancurrah/gomodguard"), - linter.NewConfig(golinters.NewGoPrintfFuncName()). + linter.NewConfig(goprintffuncname.New()). WithSince("v1.23.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/jirfag/go-printf-func-name"), - linter.NewConfig(golinters.NewGosec(&cfg.LintersSettings.Gosec)). + linter.NewConfig(gosec.New(&cfg.LintersSettings.Gosec)). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs). WithURL("https://github.com/securego/gosec"). WithAlternativeNames("gas"), - linter.NewConfig(golinters.NewGosimple(&cfg.LintersSettings.Gosimple)). + linter.NewConfig(gosimple.New(&cfg.LintersSettings.Gosimple)). WithEnabledByDefault(). WithSince("v1.20.0"). WithLoadForGoAnalysis(). @@ -337,13 +443,13 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAlternativeNames(megacheckName). WithURL("https://github.com/dominikh/go-tools/tree/master/simple"), - linter.NewConfig(golinters.NewGosmopolitan(&cfg.LintersSettings.Gosmopolitan)). + linter.NewConfig(gosmopolitan.New(&cfg.LintersSettings.Gosmopolitan)). WithSince("v1.53.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs). WithURL("https://github.com/xen0n/gosmopolitan"), - linter.NewConfig(golinters.NewGovet(&cfg.LintersSettings.Govet)). + linter.NewConfig(govet.New(&cfg.LintersSettings.Govet)). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). @@ -351,7 +457,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithAlternativeNames("vet", "vetshadow"). WithURL("https://pkg.go.dev/cmd/vet"), - linter.NewConfig(golinters.NewGrouper(&cfg.LintersSettings.Grouper)). + linter.NewConfig(grouper.New(&cfg.LintersSettings.Grouper)). WithSince("v1.44.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/leonklingele/grouper"), @@ -362,24 +468,24 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/esimonov/ifshort"). Deprecated("The repository of the linter has been deprecated by the owner.", "v1.48.0", ""), - linter.NewConfig(golinters.NewImportAs(&cfg.LintersSettings.ImportAs)). + linter.NewConfig(importas.New(&cfg.LintersSettings.ImportAs)). WithSince("v1.38.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/julz/importas"), - linter.NewConfig(golinters.NewINamedParam(&cfg.LintersSettings.Inamedparam)). + linter.NewConfig(inamedparam.New(&cfg.LintersSettings.Inamedparam)). WithSince("v1.55.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/macabu/inamedparam"), - linter.NewConfig(golinters.NewIneffassign()). + linter.NewConfig(ineffassign.New()). WithEnabledByDefault(). WithSince("v1.0.0"). WithPresets(linter.PresetUnused). WithURL("https://github.com/gordonklaus/ineffassign"), - linter.NewConfig(golinters.NewInterfaceBloat(&cfg.LintersSettings.InterfaceBloat)). + linter.NewConfig(interfacebloat.New(&cfg.LintersSettings.InterfaceBloat)). WithSince("v1.49.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/sashamelentyev/interfacebloat"), @@ -391,34 +497,34 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/mvdan/interfacer"). Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", ""), - linter.NewConfig(golinters.NewIntrange()). + linter.NewConfig(intrange.New()). WithSince("v1.57.0"). WithURL("https://github.com/ckaznocha/intrange"). WithNoopFallback(cfg, linter.IsGoLowerThanGo122()), - linter.NewConfig(golinters.NewIreturn(&cfg.LintersSettings.Ireturn)). + linter.NewConfig(ireturn.New(&cfg.LintersSettings.Ireturn)). WithSince("v1.43.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/butuzov/ireturn"), - linter.NewConfig(golinters.NewLLL(&cfg.LintersSettings.Lll)). + linter.NewConfig(lll.New(&cfg.LintersSettings.Lll)). WithSince("v1.8.0"). WithPresets(linter.PresetStyle), - linter.NewConfig(golinters.NewLoggerCheck(&cfg.LintersSettings.LoggerCheck)). + linter.NewConfig(loggercheck.New(&cfg.LintersSettings.LoggerCheck)). WithSince("v1.49.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle, linter.PresetBugs). WithAlternativeNames("logrlint"). WithURL("https://github.com/timonwong/loggercheck"), - linter.NewConfig(golinters.NewMaintIdx(&cfg.LintersSettings.MaintIdx)). + linter.NewConfig(maintidx.New(&cfg.LintersSettings.MaintIdx)). WithSince("v1.44.0"). WithPresets(linter.PresetComplexity). WithURL("https://github.com/yagipy/maintidx"), - linter.NewConfig(golinters.NewMakezero(&cfg.LintersSettings.Makezero)). + linter.NewConfig(makezero.New(&cfg.LintersSettings.Makezero)). WithSince("v1.34.0"). WithPresets(linter.PresetStyle, linter.PresetBugs). WithLoadForGoAnalysis(). @@ -431,59 +537,59 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/mdempsky/maligned"). Deprecated("The repository of the linter has been archived by the owner.", "v1.38.0", "govet 'fieldalignment'"), - linter.NewConfig(golinters.NewMirror()). + linter.NewConfig(mirror.New()). WithSince("v1.53.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/butuzov/mirror"), - linter.NewConfig(golinters.NewMisspell(&cfg.LintersSettings.Misspell)). + linter.NewConfig(misspell.New(&cfg.LintersSettings.Misspell)). WithSince("v1.8.0"). WithPresets(linter.PresetStyle, linter.PresetComment). WithAutoFix(). WithURL("https://github.com/client9/misspell"), - linter.NewConfig(golinters.NewMustTag(&cfg.LintersSettings.MustTag)). + linter.NewConfig(musttag.New(&cfg.LintersSettings.MustTag)). WithSince("v1.51.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle, linter.PresetBugs). WithURL("https://github.com/go-simpler/musttag"), - linter.NewConfig(golinters.NewNakedret(&cfg.LintersSettings.Nakedret)). + linter.NewConfig(nakedret.New(&cfg.LintersSettings.Nakedret)). WithSince("v1.19.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/alexkohler/nakedret"), - linter.NewConfig(golinters.NewNestif(&cfg.LintersSettings.Nestif)). + linter.NewConfig(nestif.New(&cfg.LintersSettings.Nestif)). WithSince("v1.25.0"). WithPresets(linter.PresetComplexity). WithURL("https://github.com/nakabonne/nestif"), - linter.NewConfig(golinters.NewNilErr()). + linter.NewConfig(nilerr.New()). WithSince("v1.38.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs). WithURL("https://github.com/gostaticanalysis/nilerr"), - linter.NewConfig(golinters.NewNilNil(&cfg.LintersSettings.NilNil)). + linter.NewConfig(nilnil.New(&cfg.LintersSettings.NilNil)). WithSince("v1.43.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/Antonboom/nilnil"), - linter.NewConfig(golinters.NewNLReturn(&cfg.LintersSettings.Nlreturn)). + linter.NewConfig(nlreturn.New(&cfg.LintersSettings.Nlreturn)). WithSince("v1.30.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/ssgreg/nlreturn"), - linter.NewConfig(golinters.NewNoctx()). + linter.NewConfig(noctx.New()). WithSince("v1.28.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetPerformance, linter.PresetBugs). WithURL("https://github.com/sonatard/noctx"), - linter.NewConfig(golinters.NewNoNamedReturns(&cfg.LintersSettings.NoNamedReturns)). + linter.NewConfig(nonamedreturns.New(&cfg.LintersSettings.NoNamedReturns)). WithSince("v1.46.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle). @@ -495,64 +601,64 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/sivchari/nosnakecase"). Deprecated("The repository of the linter has been deprecated by the owner.", "v1.48.1", "revive 'var-naming'"), - linter.NewConfig(golinters.NewNoSprintfHostPort()). + linter.NewConfig(nosprintfhostport.New()). WithSince("v1.46.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/stbenjam/no-sprintf-host-port"), - linter.NewConfig(golinters.NewParallelTest(&cfg.LintersSettings.ParallelTest)). + linter.NewConfig(paralleltest.New(&cfg.LintersSettings.ParallelTest)). WithSince("v1.33.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle, linter.PresetTest). WithURL("https://github.com/kunwardeep/paralleltest"), - linter.NewConfig(golinters.NewPerfSprint(&cfg.LintersSettings.PerfSprint)). + linter.NewConfig(perfsprint.New(&cfg.LintersSettings.PerfSprint)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetPerformance). WithURL("https://github.com/catenacyber/perfsprint"), - linter.NewConfig(golinters.NewPreAlloc(&cfg.LintersSettings.Prealloc)). + linter.NewConfig(prealloc.New(&cfg.LintersSettings.Prealloc)). WithSince("v1.19.0"). WithPresets(linter.PresetPerformance). WithURL("https://github.com/alexkohler/prealloc"), - linter.NewConfig(golinters.NewPredeclared(&cfg.LintersSettings.Predeclared)). + linter.NewConfig(predeclared.New(&cfg.LintersSettings.Predeclared)). WithSince("v1.35.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/nishanths/predeclared"), - linter.NewConfig(golinters.NewPromlinter(&cfg.LintersSettings.Promlinter)). + linter.NewConfig(promlinter.New(&cfg.LintersSettings.Promlinter)). WithSince("v1.40.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/yeya24/promlinter"), - linter.NewConfig(golinters.NewProtoGetter(&cfg.LintersSettings.ProtoGetter)). + linter.NewConfig(protogetter.New(&cfg.LintersSettings.ProtoGetter)). WithSince("v1.55.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithAutoFix(). WithURL("https://github.com/ghostiam/protogetter"), - linter.NewConfig(golinters.NewReassign(&cfg.LintersSettings.Reassign)). + linter.NewConfig(reassign.New(&cfg.LintersSettings.Reassign)). WithSince("1.49.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/curioswitch/go-reassign"), - linter.NewConfig(golinters.NewRevive(&cfg.LintersSettings.Revive)). + linter.NewConfig(revive.New(&cfg.LintersSettings.Revive)). WithSince("v1.37.0"). WithPresets(linter.PresetStyle, linter.PresetMetaLinter). ConsiderSlow(). WithURL("https://github.com/mgechev/revive"), - linter.NewConfig(golinters.NewRowsErrCheck(&cfg.LintersSettings.RowsErrCheck)). + linter.NewConfig(rowserrcheck.New(&cfg.LintersSettings.RowsErrCheck)). WithSince("v1.23.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs, linter.PresetSQL). WithURL("https://github.com/jingyugao/rowserrcheck"), - linter.NewConfig(golinters.NewSlogLint(&cfg.LintersSettings.SlogLint)). + linter.NewConfig(sloglint.New(&cfg.LintersSettings.SlogLint)). WithSince("v1.55.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle, linter.PresetFormatting). @@ -564,19 +670,19 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/kyoh86/scopelint"). Deprecated("The repository of the linter has been deprecated by the owner.", "v1.39.0", "exportloopref"), - linter.NewConfig(golinters.NewSQLCloseCheck()). + linter.NewConfig(sqlclosecheck.New()). WithSince("v1.28.0"). WithPresets(linter.PresetBugs, linter.PresetSQL). WithLoadForGoAnalysis(). WithURL("https://github.com/ryanrolds/sqlclosecheck"), - linter.NewConfig(golinters.NewSpancheck(&cfg.LintersSettings.Spancheck)). + linter.NewConfig(spancheck.New(&cfg.LintersSettings.Spancheck)). WithSince("v1.56.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetBugs). WithURL("https://github.com/jjti/go-spancheck"), - linter.NewConfig(golinters.NewStaticcheck(&cfg.LintersSettings.Staticcheck)). + linter.NewConfig(staticcheck.New(&cfg.LintersSettings.Staticcheck)). WithEnabledByDefault(). WithSince("v1.0.0"). WithLoadForGoAnalysis(). @@ -591,52 +697,52 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/opennota/check"). Deprecated("The owner seems to have abandoned the linter.", "v1.49.0", "unused"), - linter.NewConfig(golinters.NewStylecheck(&cfg.LintersSettings.Stylecheck)). + linter.NewConfig(stylecheck.New(&cfg.LintersSettings.Stylecheck)). WithSince("v1.20.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle). WithURL("https://github.com/dominikh/go-tools/tree/master/stylecheck"), - linter.NewConfig(golinters.NewTagAlign(&cfg.LintersSettings.TagAlign)). + linter.NewConfig(tagalign.New(&cfg.LintersSettings.TagAlign)). WithSince("v1.53.0"). WithPresets(linter.PresetStyle, linter.PresetFormatting). WithAutoFix(). WithURL("https://github.com/4meepo/tagalign"), - linter.NewConfig(golinters.NewTagliatelle(&cfg.LintersSettings.Tagliatelle)). + linter.NewConfig(tagliatelle.New(&cfg.LintersSettings.Tagliatelle)). WithSince("v1.40.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/ldez/tagliatelle"), - linter.NewConfig(golinters.NewTenv(&cfg.LintersSettings.Tenv)). + linter.NewConfig(tenv.New(&cfg.LintersSettings.Tenv)). WithSince("v1.43.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/sivchari/tenv"), - linter.NewConfig(golinters.NewTestableexamples()). + linter.NewConfig(testableexamples.New()). WithSince("v1.50.0"). WithPresets(linter.PresetTest). WithURL("https://github.com/maratori/testableexamples"), - linter.NewConfig(golinters.NewTestifylint(&cfg.LintersSettings.Testifylint)). + linter.NewConfig(testifylint.New(&cfg.LintersSettings.Testifylint)). WithSince("v1.55.0"). WithPresets(linter.PresetTest, linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/Antonboom/testifylint"), - linter.NewConfig(golinters.NewTestpackage(&cfg.LintersSettings.Testpackage)). + linter.NewConfig(testpackage.New(&cfg.LintersSettings.Testpackage)). WithSince("v1.25.0"). WithPresets(linter.PresetStyle, linter.PresetTest). WithURL("https://github.com/maratori/testpackage"), - linter.NewConfig(golinters.NewThelper(&cfg.LintersSettings.Thelper)). + linter.NewConfig(thelper.New(&cfg.LintersSettings.Thelper)). WithSince("v1.34.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/kulti/thelper"), - linter.NewConfig(golinters.NewTparallel()). + linter.NewConfig(tparallel.New()). WithSince("v1.32.0"). WithPresets(linter.PresetStyle, linter.PresetTest). WithLoadForGoAnalysis(). @@ -650,19 +756,19 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithPresets(linter.PresetBugs). WithURL(""), - linter.NewConfig(golinters.NewUnconvert(&cfg.LintersSettings.Unconvert)). + linter.NewConfig(unconvert.New(&cfg.LintersSettings.Unconvert)). WithSince("v1.0.0"). WithLoadForGoAnalysis(). WithPresets(linter.PresetStyle). WithURL("https://github.com/mdempsky/unconvert"), - linter.NewConfig(golinters.NewUnparam(&cfg.LintersSettings.Unparam)). + linter.NewConfig(unparam.New(&cfg.LintersSettings.Unparam)). WithSince("v1.9.0"). WithPresets(linter.PresetUnused). WithLoadForGoAnalysis(). WithURL("https://github.com/mvdan/unparam"), - linter.NewConfig(golinters.NewUnused(&cfg.LintersSettings.Unused, &cfg.LintersSettings.Staticcheck)). + linter.NewConfig(unused.New(&cfg.LintersSettings.Unused, &cfg.LintersSettings.Staticcheck)). WithEnabledByDefault(). WithSince("v1.20.0"). WithLoadForGoAnalysis(). @@ -672,7 +778,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithChangeTypes(). WithURL("https://github.com/dominikh/go-tools/tree/master/unused"), - linter.NewConfig(golinters.NewUseStdlibVars(&cfg.LintersSettings.UseStdlibVars)). + linter.NewConfig(usestdlibvars.New(&cfg.LintersSettings.UseStdlibVars)). WithSince("v1.48.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/sashamelentyev/usestdlibvars"), @@ -684,43 +790,43 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/opennota/check"). Deprecated("The owner seems to have abandoned the linter.", "v1.49.0", "unused"), - linter.NewConfig(golinters.NewVarnamelen(&cfg.LintersSettings.Varnamelen)). + linter.NewConfig(varnamelen.New(&cfg.LintersSettings.Varnamelen)). WithSince("v1.43.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/blizzy78/varnamelen"), - linter.NewConfig(golinters.NewWastedAssign()). + linter.NewConfig(wastedassign.New()). WithSince("v1.38.0"). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). WithURL("https://github.com/sanposhiho/wastedassign"), - linter.NewConfig(golinters.NewWhitespace(&cfg.LintersSettings.Whitespace)). + linter.NewConfig(whitespace.New(&cfg.LintersSettings.Whitespace)). WithSince("v1.19.0"). WithPresets(linter.PresetStyle). WithAutoFix(). WithURL("https://github.com/ultraware/whitespace"), - linter.NewConfig(golinters.NewWrapcheck(&cfg.LintersSettings.Wrapcheck)). + linter.NewConfig(wrapcheck.New(&cfg.LintersSettings.Wrapcheck)). WithSince("v1.32.0"). WithPresets(linter.PresetStyle, linter.PresetError). WithLoadForGoAnalysis(). WithURL("https://github.com/tomarrell/wrapcheck"), - linter.NewConfig(golinters.NewWSL(&cfg.LintersSettings.WSL)). + linter.NewConfig(wsl.New(&cfg.LintersSettings.WSL)). WithSince("v1.20.0"). WithPresets(linter.PresetStyle). WithURL("https://github.com/bombsimon/wsl"), - linter.NewConfig(golinters.NewZerologLint()). + linter.NewConfig(zerologlint.New()). WithSince("v1.53.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). WithURL("https://github.com/ykadowak/zerologlint"), // nolintlint must be last because it looks at the results of all the previous linters for unused nolint directives - linter.NewConfig(golinters.NewNoLintLint(&cfg.LintersSettings.NoLintLint)). + linter.NewConfig(nolintlint.New(&cfg.LintersSettings.NoLintLint)). WithSince("v1.26.0"). WithPresets(linter.PresetStyle). WithAutoFix(). diff --git a/pkg/result/processors/nolint.go b/pkg/result/processors/nolint.go index 1981fc95104c..62ca2d8ab0e1 100644 --- a/pkg/result/processors/nolint.go +++ b/pkg/result/processors/nolint.go @@ -10,7 +10,7 @@ import ( "golang.org/x/exp/maps" - "github.com/golangci/golangci-lint/pkg/golinters" + "github.com/golangci/golangci-lint/pkg/golinters/nolintlint" "github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/lint/lintersdb" "github.com/golangci/golangci-lint/pkg/logutils" @@ -35,7 +35,7 @@ func (i *ignoredRange) doesMatch(issue *result.Issue) bool { } // only allow selective nolinting of nolintlint - nolintFoundForLinter := len(i.linters) == 0 && issue.FromLinter != golinters.NoLintLintName + nolintFoundForLinter := len(i.linters) == 0 && issue.FromLinter != nolintlint.Name for _, linterName := range i.linters { if linterName == issue.FromLinter { @@ -50,7 +50,7 @@ func (i *ignoredRange) doesMatch(issue *result.Issue) bool { // handle possible unused nolint directives // nolintlint generates potential issues for every nolint directive, and they are filtered out here - if issue.FromLinter == golinters.NoLintLintName && issue.ExpectNoLint { + if issue.FromLinter == nolintlint.Name && issue.ExpectNoLint { if issue.ExpectedNoLintLinter != "" { return i.matchedIssueFromLinter[issue.ExpectedNoLintLinter] } @@ -111,7 +111,7 @@ func (p *Nolint) shouldPassIssue(issue *result.Issue) (bool, error) { nolintDebugf("got issue: %v", *issue) // don't expect disabled linters to cover their nolint statements - if issue.FromLinter == golinters.NoLintLintName && issue.ExpectNoLint && issue.ExpectedNoLintLinter != "" { + if issue.FromLinter == nolintlint.Name && issue.ExpectNoLint && issue.ExpectedNoLintLinter != "" { nolintDebugf("enabled linters: %v", p.enabledLinters) if p.enabledLinters[issue.ExpectedNoLintLinter] == nil { @@ -307,7 +307,7 @@ func (issues sortWithNolintlintLast) Len() int { } func (issues sortWithNolintlintLast) Less(i, j int) bool { - return issues[i].FromLinter != golinters.NoLintLintName && issues[j].FromLinter == golinters.NoLintLintName + return issues[i].FromLinter != nolintlint.Name && issues[j].FromLinter == nolintlint.Name } func (issues sortWithNolintlintLast) Swap(i, j int) { diff --git a/pkg/result/processors/nolint_test.go b/pkg/result/processors/nolint_test.go index bca041da979f..ea5a4c42fc37 100644 --- a/pkg/result/processors/nolint_test.go +++ b/pkg/result/processors/nolint_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/golangci/golangci-lint/pkg/config" - "github.com/golangci/golangci-lint/pkg/golinters" + "github.com/golangci/golangci-lint/pkg/golinters/nolintlint" "github.com/golangci/golangci-lint/pkg/lint/lintersdb" "github.com/golangci/golangci-lint/pkg/logutils" "github.com/golangci/golangci-lint/pkg/result" @@ -301,7 +301,7 @@ func TestNolintUnused(t *testing.T) { Filename: fileName, Line: 3, }, - FromLinter: golinters.NoLintLintName, + FromLinter: nolintlint.Name, ExpectNoLint: true, ExpectedNoLintLinter: "varcheck", } @@ -312,7 +312,7 @@ func TestNolintUnused(t *testing.T) { Filename: fileName, Line: 5, }, - FromLinter: golinters.NoLintLintName, + FromLinter: nolintlint.Name, ExpectNoLint: true, ExpectedNoLintLinter: "varcheck", } diff --git a/test/configuration_file_test.go b/test/configuration_file_test.go index 5d6169382614..8b736b0ad520 100644 --- a/test/configuration_file_test.go +++ b/test/configuration_file_test.go @@ -19,6 +19,11 @@ func Test_validateTestConfigurationFiles(t *testing.T) { require.NoError(t, err) } +func Test_validateTestConfigurationFilesLinters(t *testing.T) { + err := validateTestConfigurationFiles("../jsonschema/golangci.next.jsonschema.json", "../pkg/golinters") + require.NoError(t, err) +} + func validateTestConfigurationFiles(schemaPath, targetDir string) error { schema, err := loadSchema(filepath.FromSlash(schemaPath)) if err != nil { diff --git a/test/enabled_linters_test.go b/test/enabled_linters_test.go index 916647ad0bfb..1c61b996e12a 100644 --- a/test/enabled_linters_test.go +++ b/test/enabled_linters_test.go @@ -110,7 +110,7 @@ func TestEnabledLinters(t *testing.T) { }, } - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) for _, c := range cases { c := c @@ -127,6 +127,7 @@ func TestEnabledLinters(t *testing.T) { WithArgs(args...). WithArgs(c.args...). WithConfig(c.cfg). + WithBinPath(binPath). Runner(). Run() diff --git a/test/fix_test.go b/test/fix_test.go index 87dff82dbe3d..b65d6bf8e998 100644 --- a/test/fix_test.go +++ b/test/fix_test.go @@ -1,116 +1,15 @@ package test import ( - "os" - "os/exec" - "path/filepath" "testing" - "github.com/stretchr/testify/require" - - "github.com/golangci/golangci-lint/test/testshared" + "github.com/golangci/golangci-lint/test/testshared/integration" ) -// value: "1" -const envKeepTempFiles = "GL_KEEP_TEMP_FILES" - -func setupTestFix(t *testing.T) []string { - t.Helper() - - testshared.SkipOnWindows(t) - - tmpDir := filepath.Join(testdataDir, "fix.tmp") - _ = os.RemoveAll(tmpDir) // cleanup previous runs - - if os.Getenv(envKeepTempFiles) == "1" { - t.Logf("Temp dir for fix test: %s", tmpDir) - } else { - t.Cleanup(func() { _ = os.RemoveAll(tmpDir) }) - } - - sourcesDir := filepath.Join(testdataDir, "fix") - - err := exec.Command("cp", "-R", sourcesDir, tmpDir).Run() - require.NoError(t, err) - - testshared.InstallGolangciLint(t) - - return findSources(t, tmpDir, "in", "*.go") -} - func TestFix(t *testing.T) { - sources := setupTestFix(t) - - for _, input := range sources { - input := input - - t.Run(filepath.Base(input), func(t *testing.T) { - t.Parallel() - - rc := testshared.ParseTestDirectives(t, input) - if rc == nil { - t.Logf("Skipped: %s", input) - return - } - - testshared.NewRunnerBuilder(t). - WithArgs("--disable-all", - "--print-issued-lines=false", - "--print-linter-name=false", - "--out-format=line-number", - "--fix"). - WithRunContext(rc). - WithTargetPath(input). - Runner(). - Run(). - ExpectExitCode(rc.ExitCode) - - output, err := os.ReadFile(input) - require.NoError(t, err) - - expectedOutput, err := os.ReadFile(filepath.Join(testdataDir, "fix", "out", filepath.Base(input))) - require.NoError(t, err) - - require.Equal(t, string(expectedOutput), string(output)) - }) - } + integration.RunFix(t) } func TestFix_pathPrefix(t *testing.T) { - sources := setupTestFix(t) - - for _, input := range sources { - input := input - - t.Run(filepath.Base(input), func(t *testing.T) { - t.Parallel() - - rc := testshared.ParseTestDirectives(t, input) - if rc == nil { - t.Logf("Skipped: %s", input) - return - } - - testshared.NewRunnerBuilder(t). - WithArgs("--disable-all", - "--print-issued-lines=false", - "--print-linter-name=false", - "--out-format=line-number", - "--fix", - "--path-prefix=foobar/"). - WithRunContext(rc). - WithTargetPath(input). - Runner(). - Run(). - ExpectExitCode(rc.ExitCode) - - output, err := os.ReadFile(input) - require.NoError(t, err) - - expectedOutput, err := os.ReadFile(filepath.Join(testdataDir, "fix", "out", filepath.Base(input))) - require.NoError(t, err) - - require.Equal(t, string(expectedOutput), string(output)) - }) - } + integration.RunFixPathPrefix(t) } diff --git a/test/linters_test.go b/test/linters_test.go index 4ae7a67b8f8e..2735322eeedc 100644 --- a/test/linters_test.go +++ b/test/linters_test.go @@ -1,137 +1,21 @@ package test import ( - "os" - "os/exec" "path/filepath" - "strings" "testing" - "time" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/golangci/golangci-lint/pkg/logutils" "github.com/golangci/golangci-lint/test/testshared" + "github.com/golangci/golangci-lint/test/testshared/integration" ) const testdataDir = "testdata" func TestSourcesFromTestdata(t *testing.T) { - testSourcesFromDir(t, testdataDir) + integration.RunTestdata(t) } func TestTypecheck(t *testing.T) { testshared.SkipOnWindows(t) - testSourcesFromDir(t, filepath.Join(testdataDir, "notcompiles")) -} - -func TestSourcesFromTestdataSubDir(t *testing.T) { - subDirs := []string{ - "loggercheck", - "ginkgolinter", - "zerologlint", - "protogetter", - "spancheck", - } - - for _, dir := range subDirs { - t.Run(dir, func(t *testing.T) { - testSourcesFromDir(t, filepath.Join(testdataDir, dir)) - }) - } -} - -func testSourcesFromDir(t *testing.T, dir string) { - t.Helper() - - t.Log(filepath.Join(dir, "*.go")) - - sources := findSources(t, dir, "*.go") - - binPath := testshared.InstallGolangciLint(t) - - cwd, err := os.Getwd() - require.NoError(t, err) - t.Cleanup(func() { _ = os.Chdir(cwd) }) - - err = os.Chdir(dir) - require.NoError(t, err) - - log := logutils.NewStderrLog(logutils.DebugKeyTest) - log.SetLevel(logutils.LogLevelInfo) - - for _, source := range sources { - source := source - t.Run(filepath.Base(source), func(subTest *testing.T) { - subTest.Parallel() - - rel, err := filepath.Rel(dir, source) - require.NoError(t, err) - - testOneSource(subTest, log, binPath, rel) - }) - } -} - -func testOneSource(t *testing.T, log *logutils.StderrLog, binPath, sourcePath string) { - t.Helper() - - rc := testshared.ParseTestDirectives(t, sourcePath) - if rc == nil { - t.Skipf("Skipped: %s", sourcePath) - } - - args := []string{ - "--go=1.22", // TODO(ldez) remove this line when we will run go1.23 on the CI. (related to intrange, copyloopvar) - "--disable-all", - "--out-format=json", - "--max-same-issues=100", - "--max-issues-per-linter=100", - } - - for _, addArg := range []string{"", "-Etypecheck"} { - caseArgs := append([]string{}, args...) - - if addArg != "" { - caseArgs = append(caseArgs, addArg) - } - - cmd := testshared.NewRunnerBuilder(t). - WithBinPath(binPath). - WithArgs(caseArgs...). - WithRunContext(rc). - WithTargetPath(sourcePath). - Runner(). - Command() - - startedAt := time.Now() - - output, err := cmd.CombinedOutput() - - log.Infof("ran [%s] in %s", strings.Join(cmd.Args, " "), time.Since(startedAt)) - - // The returned error will be nil if the test file does not have any issues - // and thus the linter exits with exit code 0. - // So perform the additional assertions only if the error is non-nil. - if err != nil { - var exitErr *exec.ExitError - require.ErrorAs(t, err, &exitErr) - } - - assert.Equal(t, rc.ExitCode, cmd.ProcessState.ExitCode(), "Unexpected exit code: %s", string(output)) - - testshared.Analyze(t, sourcePath, output) - } -} - -func findSources(t *testing.T, pathPatterns ...string) []string { - t.Helper() - - sources, err := filepath.Glob(filepath.Join(pathPatterns...)) - require.NoError(t, err) - require.NotEmpty(t, sources) - - return sources + integration.RunTestSourcesFromDir(t, filepath.Join(testdataDir, "notcompiles")) } diff --git a/test/output_test.go b/test/output_test.go index e3c3b71e975b..52352ca693ce 100644 --- a/test/output_test.go +++ b/test/output_test.go @@ -13,10 +13,10 @@ import ( ) //nolint:misspell // misspelling is intentional -const expectedJSONOutput = `{"Issues":[{"FromLinter":"misspell","Text":"` + "`" + `occured` + "`" + ` is a misspelling of ` + "`" + `occurred` + "`" + `","Severity":"","SourceLines":["\t// comment with incorrect spelling: occured // want \"` + "`" + `occured` + "`" + ` is a misspelling of ` + "`" + `occurred` + "`" + `\""],"Replacement":{"NeedOnlyDelete":false,"NewLines":null,"Inline":{"StartCol":37,"Length":7,"NewString":"occurred"}},"Pos":{"Filename":"testdata/misspell.go","Offset":0,"Line":6,"Column":38},"ExpectNoLint":false,"ExpectedNoLintLinter":""}]` +const expectedJSONOutput = `{"Issues":[{"FromLinter":"misspell","Text":"` + "`" + `occured` + "`" + ` is a misspelling of ` + "`" + `occurred` + "`" + `","Severity":"","SourceLines":["\t// comment with incorrect spelling: occured // want \"` + "`" + `occured` + "`" + ` is a misspelling of ` + "`" + `occurred` + "`" + `\""],"Replacement":{"NeedOnlyDelete":false,"NewLines":null,"Inline":{"StartCol":37,"Length":7,"NewString":"occurred"}},"Pos":{"Filename":"testdata/output.go","Offset":0,"Line":6,"Column":38},"ExpectNoLint":false,"ExpectedNoLintLinter":""}]` func TestOutput_lineNumber(t *testing.T) { - sourcePath := filepath.Join(testdataDir, "misspell.go") + sourcePath := filepath.Join(testdataDir, "output.go") testshared.NewRunnerBuilder(t). WithArgs( @@ -31,11 +31,11 @@ func TestOutput_lineNumber(t *testing.T) { Install(). Run(). //nolint:misspell // misspelling is intentional - ExpectHasIssue("testdata/misspell.go:6:38: `occured` is a misspelling of `occurred`") + ExpectHasIssue("testdata/output.go:6:38: `occured` is a misspelling of `occurred`") } func TestOutput_Stderr(t *testing.T) { - sourcePath := filepath.Join(testdataDir, "misspell.go") + sourcePath := filepath.Join(testdataDir, "output.go") testshared.NewRunnerBuilder(t). WithArgs( @@ -55,7 +55,7 @@ func TestOutput_Stderr(t *testing.T) { func TestOutput_File(t *testing.T) { resultPath := filepath.Join(t.TempDir(), "golangci_lint_test_result") - sourcePath := filepath.Join(testdataDir, "misspell.go") + sourcePath := filepath.Join(testdataDir, "output.go") testshared.NewRunnerBuilder(t). WithArgs( @@ -77,7 +77,7 @@ func TestOutput_File(t *testing.T) { } func TestOutput_Multiple(t *testing.T) { - sourcePath := filepath.Join(testdataDir, "misspell.go") + sourcePath := filepath.Join(testdataDir, "output.go") testshared.NewRunnerBuilder(t). WithArgs( @@ -92,6 +92,6 @@ func TestOutput_Multiple(t *testing.T) { Install(). Run(). //nolint:misspell // misspelling is intentional - ExpectHasIssue("testdata/misspell.go:6:38: `occured` is a misspelling of `occurred`"). + ExpectHasIssue("testdata/output.go:6:38: `occured` is a misspelling of `occurred`"). ExpectOutputContains(testshared.NormalizeFilePathInJSON(expectedJSONOutput)) } diff --git a/test/run_test.go b/test/run_test.go index 17c6fa3c47ef..4c6b870ac07b 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -68,7 +68,7 @@ func TestTimeout(t *testing.T) { } func TestTimeoutInConfig(t *testing.T) { - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) cfg := ` run: @@ -79,6 +79,7 @@ func TestTimeoutInConfig(t *testing.T) { testshared.NewRunnerBuilder(t). WithConfig(cfg). WithTargetPath(testdataDir, minimalPkg). + WithBinPath(binPath). Runner(). Run(). ExpectExitCode(exitcodes.Timeout). @@ -111,7 +112,7 @@ func TestCgoOk(t *testing.T) { } func TestCgoWithIssues(t *testing.T) { - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) testCases := []struct { desc string @@ -153,6 +154,7 @@ func TestCgoWithIssues(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs(test.args...). WithTargetPath(testdataDir, test.dir). + WithBinPath(binPath). Runner(). Run(). ExpectHasIssue(test.expected) @@ -162,7 +164,7 @@ func TestCgoWithIssues(t *testing.T) { // https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives func TestLineDirective(t *testing.T) { - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) testCases := []struct { desc string @@ -251,6 +253,7 @@ func TestLineDirective(t *testing.T) { WithArgs(test.args...). WithTargetPath(testdataDir, test.targetPath). WithConfigFile(test.configPath). + WithBinPath(binPath). Runner(). Run(). ExpectHasIssue(test.expected) @@ -260,6 +263,8 @@ func TestLineDirective(t *testing.T) { // https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives func TestLineDirectiveProcessedFiles(t *testing.T) { + binPath := testshared.InstallGolangciLint(t) + testCases := []struct { desc string args []string @@ -307,8 +312,8 @@ func TestLineDirectiveProcessedFiles(t *testing.T) { WithNoConfig(). WithArgs(test.args...). WithTargetPath(testdataDir, test.target). + WithBinPath(binPath). Runner(). - Install(). Run(). ExpectExitCode(exitcodes.IssuesFound). ExpectOutputContains(test.expected...) @@ -345,7 +350,7 @@ func TestSortedResults(t *testing.T) { }, } - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) for _, test := range testCases { test := test @@ -356,6 +361,7 @@ func TestSortedResults(t *testing.T) { WithNoConfig(). WithArgs("--print-issued-lines=false", test.opt). WithTargetPath(testdataDir, "sort_results"). + WithBinPath(binPath). Runner(). Run(). ExpectExitCode(exitcodes.IssuesFound).ExpectOutputEq(test.want + "\n") @@ -418,7 +424,7 @@ func TestUnusedCheckExported(t *testing.T) { } func TestConfigFileIsDetected(t *testing.T) { - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) testCases := []struct { desc string @@ -442,6 +448,7 @@ func TestConfigFileIsDetected(t *testing.T) { testshared.NewRunnerBuilder(t). // WithNoConfig(). WithTargetPath(test.targetPath). + WithBinPath(binPath). Runner(). Run(). ExpectExitCode(exitcodes.Success). @@ -452,7 +459,7 @@ func TestConfigFileIsDetected(t *testing.T) { } func TestEnableAllFastAndEnableCanCoexist(t *testing.T) { - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) testCases := []struct { desc string @@ -481,6 +488,7 @@ func TestEnableAllFastAndEnableCanCoexist(t *testing.T) { WithArgs(test.args...). WithArgs("--go=1.22"). // TODO(ldez) remove this line when we will run go1.23 on the CI. (related to intrange, copyloopvar) WithTargetPath(testdataDir, minimalPkg). + WithBinPath(binPath). Runner(). Run(). ExpectExitCode(test.expected...) @@ -553,7 +561,7 @@ func TestPathPrefix(t *testing.T) { }, } - testshared.InstallGolangciLint(t) + binPath := testshared.InstallGolangciLint(t) for _, test := range testCases { test := test @@ -561,6 +569,7 @@ func TestPathPrefix(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs(test.args...). WithTargetPath(testdataDir, "withtests"). + WithBinPath(binPath). Runner(). Run(). ExpectOutputRegexp(test.pattern) diff --git a/test/testdata/configs/gocritic-fix.yml b/test/testdata/configs/gocritic-fix.yml deleted file mode 100644 index 7587a761a884..000000000000 --- a/test/testdata/configs/gocritic-fix.yml +++ /dev/null @@ -1,7 +0,0 @@ -linters-settings: - gocritic: - enabled-checks: - - ruleguard - settings: - ruleguard: - rules: 'ruleguard/rangeExprCopy.go,ruleguard/stringsSimplify.go' diff --git a/test/testdata/configs/output.yml b/test/testdata/configs/output.yml new file mode 100644 index 000000000000..d115cba91b06 --- /dev/null +++ b/test/testdata/configs/output.yml @@ -0,0 +1,6 @@ +linters-settings: + misspell: + locale: US + ignore-words: + - langauge + - Dialogue diff --git a/test/testdata/output.go b/test/testdata/output.go new file mode 100644 index 000000000000..775b6102922c --- /dev/null +++ b/test/testdata/output.go @@ -0,0 +1,10 @@ +//golangcitest:args -Emisspell +//golangcitest:config_path testdata/configs/output.yml +package testdata + +func Misspell() { + // comment with incorrect spelling: occured // want "`occured` is a misspelling of `occurred`" +} + +// the word langauge should be ignored here: it's set in config +// the word Dialogue should be ignored here: it's set in config diff --git a/test/testshared/analysis.go b/test/testshared/analysis.go index 3bc1d8e08898..7c1c812bccac 100644 --- a/test/testshared/analysis.go +++ b/test/testshared/analysis.go @@ -38,6 +38,8 @@ type key struct { // Analyze analyzes the test expectations ('want'). // inspired by https://github.com/golang/tools/blob/b3b5c13b291f9653da6f31b95db100a2e26bd186/go/analysis/analysistest/analysistest.go func Analyze(t *testing.T, sourcePath string, rawData []byte) { + t.Helper() + fileData, err := os.ReadFile(sourcePath) require.NoError(t, err) @@ -168,6 +170,8 @@ func parseExpectations(text string) (lineDelta int, expects []expectation, err e // inspired by https://github.com/golang/tools/blob/b3b5c13b291f9653da6f31b95db100a2e26bd186/go/analysis/analysistest/analysistest.go func checkMessage(t *testing.T, want map[key][]expectation, posn token.Position, kind, name, message string) { + t.Helper() + k := key{posn.Filename, posn.Line} expects := want[k] var unmatched []string diff --git a/test/testshared/install.go b/test/testshared/install.go new file mode 100644 index 000000000000..8eeb7fa8ae3c --- /dev/null +++ b/test/testshared/install.go @@ -0,0 +1,121 @@ +package testshared + +import ( + "fmt" + "io" + "os" + "os/exec" + "path/filepath" + "strconv" + "sync" + "testing" + + "github.com/gofrs/flock" + "github.com/stretchr/testify/require" +) + +// value: "true" +const envGolangciLintInstalled = "GOLANGCI_LINT_INSTALLED" + +// Reduce the number of builds. +// The majority of tests are NOT executed inside the same process, +// then this is just to limit some cases (~60 cases). +var ( + builtLock sync.RWMutex + built bool +) + +func InstallGolangciLint(tb testing.TB) string { + tb.Helper() + + parentPath := findMakefile(tb) + + // Avoids concurrent builds and copies (before the end of the build). + f := flock.New(filepath.Join(parentPath, "test.lock")) + + if ok, _ := strconv.ParseBool(os.Getenv(envGolangciLintInstalled)); !ok { + err := f.Lock() + require.NoError(tb, err) + + defer func() { + errU := f.Unlock() + if errU != nil { + tb.Logf("Can't unlock test.lock: %v", errU) + } + }() + + builtLock.Lock() + defer builtLock.Unlock() + + if !built { + cmd := exec.Command("make", "-C", parentPath, "build") + + output, err := cmd.CombinedOutput() + require.NoError(tb, err, "can't install golangci-lint %s", string(output)) + + built = true + } + } + + // Allow tests to avoid edge-cases with concurrent runs. + binPath := filepath.Join(tb.TempDir(), binaryName) + + err := copyFile(filepath.Join(parentPath, binaryName), binPath) + require.NoError(tb, err) + + abs, err := filepath.Abs(binPath) + require.NoError(tb, err) + + return abs +} + +func findMakefile(tb testing.TB) string { + tb.Helper() + + wd, _ := os.Getwd() + + for wd != "/" { + _, err := os.Stat(filepath.Join(wd, "Makefile")) + if err != nil { + wd = filepath.Dir(wd) + continue + } + + break + } + + here, _ := os.Getwd() + + rel, err := filepath.Rel(here, wd) + require.NoError(tb, err) + + return rel +} + +func copyFile(src, dst string) error { + source, err := os.Open(src) + if err != nil { + return fmt.Errorf("open file %s: %w", src, err) + } + + defer func() { _ = source.Close() }() + + info, err := source.Stat() + if err != nil { + return fmt.Errorf("file %s not found: %w", src, err) + } + + destination, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, info.Mode()) + if err != nil { + return fmt.Errorf("create file %s: %w", dst, err) + } + + defer func() { _ = destination.Close() }() + + _, err = io.Copy(destination, source) + if err != nil { + return fmt.Errorf("copy file %s to %s: %w", src, dst, err) + } + + return nil +} diff --git a/test/testshared/integration/fix.go b/test/testshared/integration/fix.go new file mode 100644 index 000000000000..29d95960b2d6 --- /dev/null +++ b/test/testshared/integration/fix.go @@ -0,0 +1,93 @@ +package integration + +import ( + "os" + "os/exec" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/golangci/golangci-lint/test/testshared" +) + +// value: "1" +const envKeepTempFiles = "GL_KEEP_TEMP_FILES" + +func setupTestFix(t *testing.T) []string { + t.Helper() + + testshared.SkipOnWindows(t) + + tmpDir := filepath.Join(testdataDir, "fix.tmp") + _ = os.RemoveAll(tmpDir) // cleanup previous runs + + if os.Getenv(envKeepTempFiles) == "1" { + t.Logf("Temp dir for fix test: %s", tmpDir) + } else { + t.Cleanup(func() { _ = os.RemoveAll(tmpDir) }) + } + + sourcesDir := filepath.Join(testdataDir, "fix") + + err := exec.Command("cp", "-R", sourcesDir, tmpDir).Run() + require.NoError(t, err) + + return findSources(t, tmpDir, "in", "*.go") +} + +func RunFix(t *testing.T) { + t.Helper() + + runFix(t) +} + +func RunFixPathPrefix(t *testing.T) { + t.Helper() + + runFix(t, "--path-prefix=foobar/") +} + +func runFix(t *testing.T, extraArgs ...string) { + t.Helper() + + binPath := testshared.InstallGolangciLint(t) + + sources := setupTestFix(t) + + for _, input := range sources { + input := input + + t.Run(filepath.Base(input), func(t *testing.T) { + t.Parallel() + + rc := testshared.ParseTestDirectives(t, input) + if rc == nil { + t.Logf("Skipped: %s", input) + return + } + + testshared.NewRunnerBuilder(t). + WithArgs("--disable-all", + "--print-issued-lines=false", + "--print-linter-name=false", + "--out-format=line-number", + "--fix"). + WithArgs(extraArgs...). + WithRunContext(rc). + WithTargetPath(input). + WithBinPath(binPath). + Runner(). + Run(). + ExpectExitCode(rc.ExitCode) + + output, err := os.ReadFile(input) + require.NoError(t, err) + + expectedOutput, err := os.ReadFile(filepath.Join(testdataDir, "fix", "out", filepath.Base(input))) + require.NoError(t, err) + + require.Equal(t, string(expectedOutput), string(output)) + }) + } +} diff --git a/test/testshared/integration/run.go b/test/testshared/integration/run.go new file mode 100644 index 000000000000..b4faf7ea440f --- /dev/null +++ b/test/testshared/integration/run.go @@ -0,0 +1,116 @@ +package integration + +import ( + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/golangci/golangci-lint/pkg/logutils" + "github.com/golangci/golangci-lint/test/testshared" +) + +const testdataDir = "testdata" + +func RunTestdata(t *testing.T) { + t.Helper() + + RunTestSourcesFromDir(t, testdataDir) +} + +func RunTestSourcesFromDir(t *testing.T, dir string) { + t.Helper() + + t.Log(filepath.Join(dir, "*.go")) + + sources := findSources(t, dir, "*.go") + + binPath := testshared.InstallGolangciLint(t) + + cwd, err := os.Getwd() + require.NoError(t, err) + t.Cleanup(func() { _ = os.Chdir(cwd) }) + + err = os.Chdir(dir) + require.NoError(t, err) + + log := logutils.NewStderrLog(logutils.DebugKeyTest) + log.SetLevel(logutils.LogLevelInfo) + + for _, source := range sources { + source := source + t.Run(filepath.Base(source), func(subTest *testing.T) { + subTest.Parallel() + + rel, err := filepath.Rel(dir, source) + require.NoError(t, err) + + testOneSource(subTest, log, binPath, rel) + }) + } +} + +func testOneSource(t *testing.T, log *logutils.StderrLog, binPath, sourcePath string) { + t.Helper() + + rc := testshared.ParseTestDirectives(t, sourcePath) + if rc == nil { + t.Skipf("Skipped: %s", sourcePath) + } + + args := []string{ + "--go=1.22", // TODO(ldez) remove this line when we will run go1.23 on the CI. (related to intrange, copyloopvar) + "--disable-all", + "--out-format=json", + "--max-same-issues=100", + "--max-issues-per-linter=100", + } + + for _, addArg := range []string{"", "-Etypecheck"} { + caseArgs := append([]string{}, args...) + + if addArg != "" { + caseArgs = append(caseArgs, addArg) + } + + cmd := testshared.NewRunnerBuilder(t). + WithBinPath(binPath). + WithArgs(caseArgs...). + WithRunContext(rc). + WithTargetPath(sourcePath). + Runner(). + Command() + + startedAt := time.Now() + + output, err := cmd.CombinedOutput() + + log.Infof("ran [%s] in %s", strings.Join(cmd.Args, " "), time.Since(startedAt)) + + // The returned error will be nil if the test file does not have any issues + // and thus the linter exits with exit code 0. + // So perform the additional assertions only if the error is non-nil. + if err != nil { + var exitErr *exec.ExitError + require.ErrorAs(t, err, &exitErr) + } + + require.Equal(t, rc.ExitCode, cmd.ProcessState.ExitCode(), "Unexpected exit code: %s", string(output)) + + testshared.Analyze(t, sourcePath, output) + } +} + +func findSources(t *testing.T, pathPatterns ...string) []string { + t.Helper() + + sources, err := filepath.Glob(filepath.Join(pathPatterns...)) + require.NoError(t, err) + require.NotEmpty(t, sources) + + return sources +} diff --git a/test/testshared/runner.go b/test/testshared/runner.go index f1f2adcb03c0..72317696c6a3 100644 --- a/test/testshared/runner.go +++ b/test/testshared/runner.go @@ -18,12 +18,8 @@ import ( "github.com/golangci/golangci-lint/pkg/logutils" ) -const ( - // value: "1" - envKeepTempFiles = "GL_KEEP_TEMP_FILES" - // value: "true" - envGolangciLintInstalled = "GOLANGCI_LINT_INSTALLED" -) +// value: "1" +const envKeepTempFiles = "GL_KEEP_TEMP_FILES" type RunnerBuilder struct { tb testing.TB @@ -49,7 +45,6 @@ func NewRunnerBuilder(tb testing.TB) *RunnerBuilder { return &RunnerBuilder{ tb: tb, log: log, - binPath: defaultBinaryName(), command: "run", allowParallelRunners: true, } @@ -214,7 +209,7 @@ func (r *Runner) Install() *Runner { r.tb.Helper() r.installOnce.Do(func() { - InstallGolangciLint(r.tb) + r.binPath = InstallGolangciLint(r.tb) }) return r @@ -338,23 +333,3 @@ func (r *RunnerResult) ExpectHasIssue(issueText string) *RunnerResult { return r.ExpectExitCode(exitcodes.IssuesFound).ExpectOutputContains(issueText) } - -func InstallGolangciLint(tb testing.TB) string { - tb.Helper() - - if os.Getenv(envGolangciLintInstalled) != "true" { - cmd := exec.Command("make", "-C", "..", "build") - - output, err := cmd.CombinedOutput() - if err != nil { - tb.Log(string(output)) - } - - require.NoError(tb, err, "Can't go install golangci-lint %s", string(output)) - } - - abs, err := filepath.Abs(defaultBinaryName()) - require.NoError(tb, err) - - return abs -} diff --git a/test/testshared/runner_unix.go b/test/testshared/runner_unix.go index edba71d54537..ecb2c5fc2a23 100644 --- a/test/testshared/runner_unix.go +++ b/test/testshared/runner_unix.go @@ -3,10 +3,11 @@ package testshared import ( - "path/filepath" "testing" ) +const binaryName = "golangci-lint" + // SkipOnWindows it's a noop function on Unix. func SkipOnWindows(_ testing.TB) {} @@ -20,11 +21,6 @@ func NormalizeFileInString(in string) string { return in } -// defaultBinaryName returns the path to the default binary. -func defaultBinaryName() string { - return filepath.Join("..", "golangci-lint") -} - // normalizeFilePath it's a noop function on Unix. func normalizeFilePath(in string) string { return in diff --git a/test/testshared/runner_windows.go b/test/testshared/runner_windows.go index d6aa865ea182..a562dbe8147b 100644 --- a/test/testshared/runner_windows.go +++ b/test/testshared/runner_windows.go @@ -9,6 +9,8 @@ import ( "testing" ) +const binaryName = "golangci-lint.exe" + // SkipOnWindows skip test on Windows. func SkipOnWindows(tb testing.TB) { tb.Skip("not supported on Windows") @@ -28,11 +30,6 @@ func NormalizeFileInString(in string) string { return strings.ReplaceAll(filepath.FromSlash(in), "\\", "\\\\") } -// defaultBinaryName returns the path to the default binary. -func defaultBinaryName() string { - return filepath.Join("..", "golangci-lint.exe") -} - // normalizeFilePath find Go file path and replace `/` with `\\`. func normalizeFilePath(in string) string { exp := regexp.MustCompile(`(?:^|\b)[\w-/.]+\.go`)