|
12 | 12 | from . import Check, MirrorsCheck, RepoCheck |
13 | 13 |
|
14 | 14 |
|
| 15 | +DEPRECATED_HASHES = frozenset({"md5", "rmd160", "sha1", "whirlpool"}) |
| 16 | + |
| 17 | + |
15 | 18 | class MultiMovePackageUpdate(results.ProfilesResult, results.Warning): |
16 | 19 | """Entry for package moved multiple times in profiles/updates files.""" |
17 | 20 |
|
@@ -174,7 +177,7 @@ class UnusedLicensesCheck(RepoCheck): |
174 | 177 | """Check for unused license files.""" |
175 | 178 |
|
176 | 179 | _source = sources.RepositoryRepoSource |
177 | | - known_results = frozenset([UnusedLicenses]) |
| 180 | + known_results = frozenset({UnusedLicenses}) |
178 | 181 |
|
179 | 182 | def __init__(self, *args): |
180 | 183 | super().__init__(*args) |
@@ -213,7 +216,7 @@ class UnusedMirrorsCheck(MirrorsCheck, RepoCheck): |
213 | 216 | """Check for unused mirrors.""" |
214 | 217 |
|
215 | 218 | _source = sources.RepositoryRepoSource |
216 | | - known_results = frozenset([UnusedMirrors]) |
| 219 | + known_results = frozenset({UnusedMirrors}) |
217 | 220 |
|
218 | 221 | def start(self): |
219 | 222 | master_mirrors = set() |
@@ -249,7 +252,7 @@ class UnusedEclassesCheck(RepoCheck): |
249 | 252 | """Check for unused eclasses.""" |
250 | 253 |
|
251 | 254 | _source = sources.RepositoryRepoSource |
252 | | - known_results = frozenset([UnusedEclasses]) |
| 255 | + known_results = frozenset({UnusedEclasses}) |
253 | 256 |
|
254 | 257 | def __init__(self, *args): |
255 | 258 | super().__init__(*args) |
@@ -291,7 +294,7 @@ class LicenseGroupsCheck(RepoCheck): |
291 | 294 | """Scan license groups for unknown licenses.""" |
292 | 295 |
|
293 | 296 | _source = (sources.EmptySource, (base.repo_scope,)) |
294 | | - known_results = frozenset([UnknownLicenses]) |
| 297 | + known_results = frozenset({UnknownLicenses}) |
295 | 298 |
|
296 | 299 | def __init__(self, *args): |
297 | 300 | super().__init__(*args) |
@@ -682,7 +685,7 @@ class ManifestCollisionCheck(Check): |
682 | 685 | """ |
683 | 686 |
|
684 | 687 | _source = (sources.RepositoryRepoSource, (), (("source", sources.PackageRepoSource),)) |
685 | | - known_results = frozenset([ConflictingChksums, MatchingChksums]) |
| 688 | + known_results = frozenset({ConflictingChksums, MatchingChksums}) |
686 | 689 |
|
687 | 690 | def __init__(self, *args): |
688 | 691 | super().__init__(*args) |
@@ -746,13 +749,45 @@ class ProjectMetadataCheck(RepoCheck): |
746 | 749 | """Check projects.xml for issues.""" |
747 | 750 |
|
748 | 751 | _source = (sources.EmptySource, (base.repo_scope,)) |
749 | | - known_results = frozenset([EmptyProject]) |
| 752 | + known_results = frozenset({EmptyProject}) |
750 | 753 |
|
751 | 754 | def __init__(self, *args): |
752 | 755 | super().__init__(*args) |
753 | 756 | self.repo = self.options.target_repo |
754 | 757 |
|
755 | 758 | def finish(self): |
756 | | - for _key, project in self.repo.projects_xml.projects.items(): |
| 759 | + for project in self.repo.projects_xml.projects.values(): |
757 | 760 | if not project.recursive_members: |
758 | 761 | yield EmptyProject(project) |
| 762 | + |
| 763 | + |
| 764 | +class DeprecatedRepoHash(results.Warning): |
| 765 | + """Repositories ``manifest-hashes`` defines deprecated hashes. |
| 766 | +
|
| 767 | + The repository defines deprecated hashes in ``manifest-hashes``. |
| 768 | + """ |
| 769 | + |
| 770 | + def __init__(self, hashes): |
| 771 | + super().__init__() |
| 772 | + self.hashes = tuple(hashes) |
| 773 | + |
| 774 | + @property |
| 775 | + def desc(self): |
| 776 | + s = pluralism(self.hashes) |
| 777 | + hashes = ", ".join(self.hashes) |
| 778 | + return f"defines deprecated manifest-hash{s}: [ {hashes} ]" |
| 779 | + |
| 780 | + |
| 781 | +class RepoManifestHashCheck(RepoCheck): |
| 782 | + """Check ``manifest-hashes`` config for issues.""" |
| 783 | + |
| 784 | + _source = (sources.EmptySource, (base.repo_scope,)) |
| 785 | + known_results = frozenset({DeprecatedRepoHash}) |
| 786 | + |
| 787 | + def __init__(self, *args): |
| 788 | + super().__init__(*args) |
| 789 | + self.repo = self.options.target_repo |
| 790 | + |
| 791 | + def finish(self): |
| 792 | + if deprecated_hashes := DEPRECATED_HASHES.intersection(self.repo.config.manifests.hashes): |
| 793 | + yield DeprecatedRepoHash(sorted(deprecated_hashes)) |
0 commit comments