Skip to content
Snippets Groups Projects
Unverified Commit afa98f54 authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

refactor(datasource/sbt): Enable strict null checks (#14003)

parent 9304e94e
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ export async function getArtifactSubdirs(
searchRoot: string,
artifact: string,
scalaVersion: string
): Promise<string[]> {
): Promise<string[] | null> {
const { body: indexContent } = await downloadHttpProtocol(
ensureTrailingSlash(searchRoot),
'sbt'
......@@ -53,8 +53,8 @@ export async function getArtifactSubdirs(
export async function getPackageReleases(
searchRoot: string,
artifactSubdirs: string[]
): Promise<string[]> {
artifactSubdirs: string[] | null
): Promise<string[] | null> {
if (artifactSubdirs) {
const releases: string[] = [];
const parseReleases = (content: string): string[] =>
......@@ -77,7 +77,7 @@ export async function getPackageReleases(
return null;
}
export function getLatestVersion(versions: string[]): string | null {
export function getLatestVersion(versions: string[] | null): string | null {
if (versions?.length) {
return versions.reduce((latestVersion, version) =>
compare(version, latestVersion) === 1 ? version : latestVersion
......@@ -88,8 +88,8 @@ export function getLatestVersion(versions: string[]): string | null {
export async function getUrls(
searchRoot: string,
artifactDirs: string[],
version: string
artifactDirs: string[] | null,
version: string | null
): Promise<Partial<ReleaseResult>> {
const result: Partial<ReleaseResult> = {};
......@@ -141,6 +141,11 @@ export async function getReleases({
lookupName,
registryUrl,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
// istanbul ignore if
if (!registryUrl) {
return null;
}
const [groupId, artifactId] = lookupName.split(':');
const groupIdSplit = groupId.split('.');
const artifactIdSplit = artifactId.split('_');
......
......@@ -23,7 +23,7 @@ async function resolvePluginReleases(
rootUrl: string,
artifact: string,
scalaVersion: string
): Promise<string[]> {
): Promise<string[] | null> {
const searchRoot = `${rootUrl}/${artifact}`;
const parse = (content: string): string[] =>
parseIndexDir(content, (x) => !regEx(/^\.+$/).test(x));
......@@ -72,6 +72,11 @@ export async function getReleases({
lookupName,
registryUrl,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
// istanbul ignore if
if (!registryUrl) {
return null;
}
const [groupId, artifactId] = lookupName.split(':');
const groupIdSplit = groupId.split('.');
const artifactIdSplit = artifactId.split('_');
......
......@@ -7,6 +7,6 @@ export function parseIndexDir(
content: string,
filterFn = (x: string): boolean => !regEx(/^\.+/).test(x)
): string[] {
const unfiltered = content.match(/(?<=href=['"])[^'"]*(?=\/['"])/g) || [];
const unfiltered = content.match(/(?<=href=['"])[^'"]*(?=\/['"])/g) ?? [];
return unfiltered.filter(filterFn);
}
......@@ -82,7 +82,6 @@
"lib/datasource/aws-machine-image/index.ts",
"lib/datasource/bitbucket-tags/index.ts",
"lib/datasource/cdnjs/index.ts",
"lib/datasource/clojure/index.ts",
"lib/datasource/crate/index.ts",
"lib/datasource/datasource.ts",
"lib/datasource/docker/common.ts",
......@@ -130,8 +129,6 @@
"lib/datasource/rubygems/get-rubygems-org.ts",
"lib/datasource/rubygems/get.ts",
"lib/datasource/rubygems/index.ts",
"lib/datasource/sbt-package/index.ts",
"lib/datasource/sbt-plugin/index.ts",
"lib/datasource/terraform-module/base.ts",
"lib/datasource/terraform-module/index.ts",
"lib/datasource/terraform-provider/index.ts",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment