mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
feature: package-directory-mismatch - ignore main_test package name (#1545)
Thanks for the PR @uloamaka !
This commit is contained in:
committed by
GitHub
parent
bc38b79980
commit
d32d4a008f
@@ -121,6 +121,10 @@ func (r *PackageDirectoryMismatchRule) Apply(file *lint.File, _ lint.Arguments)
|
||||
}
|
||||
|
||||
if file.IsTest() {
|
||||
// treat main_test differently because it's a common package name for tests
|
||||
if packageName == "main_test" {
|
||||
return nil
|
||||
}
|
||||
// External test package (directory + '_test' suffix)
|
||||
if r.semanticallyEqual(packageName, dirName+"_test") {
|
||||
return nil
|
||||
|
||||
@@ -53,6 +53,7 @@ func TestPackageDirectoryMismatch(t *testing.T) {
|
||||
testRule(t, "package_directory_mismatch/test/good", &rule.PackageDirectoryMismatchRule{}, config)
|
||||
testRule(t, "package_directory_mismatch/test/bad_test", &rule.PackageDirectoryMismatchRule{}, config)
|
||||
testRule(t, "package_directory_mismatch/test/bad", &rule.PackageDirectoryMismatchRule{}, config)
|
||||
testRule(t, "package_directory_mismatch/test/main_test", &rule.PackageDirectoryMismatchRule{}, config)
|
||||
}
|
||||
|
||||
func TestPackageDirectoryMismatchWithDefaultConfig(t *testing.T) {
|
||||
|
||||
1
testdata/package_directory_mismatch/test/main_test.go
vendored
Normal file
1
testdata/package_directory_mismatch/test/main_test.go
vendored
Normal file
@@ -0,0 +1 @@
|
||||
package main_test
|
||||
Reference in New Issue
Block a user