From 3629f6a6f625db1e3da4303be586a39e9dcece41 Mon Sep 17 00:00:00 2001 From: d35ha Date: Tue, 11 Jun 2024 10:07:38 +0000 Subject: [PATCH] Extend the linter to check the package name against its folder and nuspec file --- scripts/test/lint.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/test/lint.py b/scripts/test/lint.py index de5257e93..503bb3d4c 100644 --- a/scripts/test/lint.py +++ b/scripts/test/lint.py @@ -253,12 +253,26 @@ def check(self, path): return True +class PackageIdNotMatchingFolderOrNuspecName(Lint): + name = "package ID doesn't match package folder name or nuspec file name" + recommendation = "make sure the package ID is the same as the package folder name and the nuspec file name" + + def check(self, path): + dom = minidom.parse(str(path)) + pkg_id = dom.getElementsByTagName("id")[0].firstChild.data + + nuspec = path.parts[-1] + folder = path.parts[-2] + + return not (pkg_id == folder == nuspec[:-len(".nuspec")]) + NUSPEC_LINTS = ( IncludesRequiredFieldsOnly(), VersionFormatIncorrect(), DoesNotListDependencyCommonVm(), DependencyContainsUppercaseChar(), VersionNotUpdated(), + PackageIdNotMatchingFolderOrNuspecName(), )