refactor(datasource/dart): Enable strict null checks (#13981)

* refactor(datasource/dart): Enable strict null checks

* Fix coverage
This commit is contained in:
Sergei Zharinov 2022-02-03 18:21:10 +03:00 committed by GitHub
parent 99c0e9cfd0
commit 8e3478e69a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -18,10 +18,14 @@ export class DartDatasource extends Datasource {
lookupName,
registryUrl,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
let result: ReleaseResult = null;
// istanbul ignore if
if (!registryUrl) {
return null;
}
let result: ReleaseResult | null = null;
const pkgUrl = `${registryUrl}api/packages/${lookupName}`;
let raw: HttpResponse<DartResult> = null;
let raw: HttpResponse<DartResult> | null = null;
try {
raw = await this.http.getJson<DartResult>(pkgUrl);
} catch (err) {
@ -31,13 +35,12 @@ export class DartDatasource extends Datasource {
const body = raw?.body;
if (body) {
const { versions, latest } = body;
if (versions && latest) {
result = {
releases: body.versions.map(({ version, published }) => ({
version,
releaseTimestamp: published,
})),
};
const releases = versions?.map(({ version, published }) => ({
version,
releaseTimestamp: published,
}));
if (releases && latest) {
result = { releases };
const pubspec = latest.pubspec;
if (pubspec) {

View file

@ -16,6 +16,7 @@
"lib/datasource/**/types.ts",
"lib/datasource/adoptium-java",
"lib/datasource/artifactory",
"lib/datasource/dart",
"lib/datasource/gitlab-tags/util.ts",
"lib/datasource/helm/common.ts",
"lib/datasource/metadata.ts",
@ -74,6 +75,7 @@
"lib/constants/platform.spec.ts",
"lib/datasource/adoptium-java/**/*.spec.ts",
"lib/datasource/artifactory/**/*.spec.ts",
"lib/datasource/dart/**/*.spec.ts",
"lib/datasource/docker/common.ts",
"lib/datasource/github-releases/common.ts",
"lib/datasource/go/common.ts",