mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	feature(package-directory-mismatch): allow test package names in version paths (#1547)
This commit is contained in:
		| @@ -141,6 +141,13 @@ func (r *PackageDirectoryMismatchRule) Apply(file *lint.File, _ lint.Arguments) | ||||
| 			return nil | ||||
| 		} | ||||
|  | ||||
| 		if file.IsTest() { | ||||
| 			// External test package (directory + '_test' suffix) | ||||
| 			if r.semanticallyEqual(packageName, parentDirName+"_test") { | ||||
| 				return nil | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		failure = fmt.Sprintf("package name %q does not match directory name %q or parent directory name %q", packageName, dirName, parentDirName) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -37,6 +37,7 @@ func TestPackageDirectoryMismatch(t *testing.T) { | ||||
| 	// Test version directories (v1, v2, etc.) | ||||
| 	testRule(t, "package_directory_mismatch/api/v1/api", &rule.PackageDirectoryMismatchRule{}, config) | ||||
| 	testRule(t, "package_directory_mismatch/api/V1/api", &rule.PackageDirectoryMismatchRule{}, config) | ||||
| 	testRule(t, "package_directory_mismatch/api/V1/api_test", &rule.PackageDirectoryMismatchRule{}, config) | ||||
| 	testRule(t, "package_directory_mismatch/api/v1v/api", &rule.PackageDirectoryMismatchRule{}, config) | ||||
| 	testRule(t, "package_directory_mismatch/api/v2/v2", &rule.PackageDirectoryMismatchRule{}, config) | ||||
|  | ||||
|   | ||||
							
								
								
									
										1
									
								
								testdata/package_directory_mismatch/api/V1/api_test.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								testdata/package_directory_mismatch/api/V1/api_test.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| package api_test | ||||
		Reference in New Issue
	
	Block a user