diff --git a/lib/datasource/cache.ts b/lib/datasource/cache.ts index ecd74cbe79e1764bbf11c59c30366a05dd5bb694..f0ad5eaa3198e2edb6c1fc4c51d9d2496ae87f3d 100644 --- a/lib/datasource/cache.ts +++ b/lib/datasource/cache.ts @@ -60,7 +60,7 @@ export async function cacheAble<TArg, TResult = unknown>({ const cacheKey = JSON.stringify(lookup); const cachedResult = await globalCache.get<TResult>(cacheNamespace, cacheKey); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { logger.trace({ id, lookup }, 'datasource cachedResult'); return cachedResult; } diff --git a/lib/datasource/crate/index.ts b/lib/datasource/crate/index.ts index fe948c1ab79079d860859af6a4b8ecb1f98bc3a9..e8e64eba5eef4dead28d2fe226732913bef9daeb 100644 --- a/lib/datasource/crate/index.ts +++ b/lib/datasource/crate/index.ts @@ -22,7 +22,7 @@ export async function getReleases({ cacheKey ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts index 9ab3c01480fad558b73163869a08a1860e07e17f..0317e4927b2e41d14bd80a536c6203f6de6e8851 100644 --- a/lib/datasource/docker/index.ts +++ b/lib/datasource/docker/index.ts @@ -341,7 +341,7 @@ export async function getDigest( const cacheKey = `${registry}:${repository}:${newTag}`; const cachedResult = await globalCache.get(cacheNamespace, cacheKey); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } const manifestResponse = await getManifestResponse( @@ -386,7 +386,7 @@ async function getTags( cacheKey ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } // AWS ECR limits the maximum number of results to 1000 @@ -486,7 +486,7 @@ async function getLabels( cacheKey ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } try { diff --git a/lib/datasource/galaxy/index.ts b/lib/datasource/galaxy/index.ts index ce6b9e89643596dc87c84c68103c819366f5ae60..b49eca902d18a5f913ab27001b905063a6574e0c 100644 --- a/lib/datasource/galaxy/index.ts +++ b/lib/datasource/galaxy/index.ts @@ -22,7 +22,7 @@ export async function getReleases({ cacheKey ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } diff --git a/lib/datasource/git-refs/index.ts b/lib/datasource/git-refs/index.ts index afd75aed8c0bd0418da369e511d8ac04c01a60df..4b608589da1be93d416e4b6600a7c20107135cac 100644 --- a/lib/datasource/git-refs/index.ts +++ b/lib/datasource/git-refs/index.ts @@ -29,7 +29,7 @@ export async function getRawRefs({ lookupName ); /* istanbul ignore next line */ - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } diff --git a/lib/datasource/git-submodules/index.ts b/lib/datasource/git-submodules/index.ts index b00fe9afa52dd4315f2e9c3ebd08b66f0131e462..bf0dbfda00c94355c6f4c82ce3786cfc2693342c 100644 --- a/lib/datasource/git-submodules/index.ts +++ b/lib/datasource/git-submodules/index.ts @@ -18,7 +18,7 @@ export async function getReleases({ cacheKey ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } diff --git a/lib/datasource/github-releases/index.ts b/lib/datasource/github-releases/index.ts index 8b4c2c89dcd5030afe0ff40111236a1a0fbbd5eb..621a5b0f446d56ef5d0f3b6e8754403709922a00 100644 --- a/lib/datasource/github-releases/index.ts +++ b/lib/datasource/github-releases/index.ts @@ -33,7 +33,7 @@ export async function getReleases({ repo ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } try { diff --git a/lib/datasource/github-tags/index.ts b/lib/datasource/github-tags/index.ts index fea2bae705bd85188e8dc9964415af92f17d1677..6f5ce1689fb140b036dff4e7f2faa26b31d12327 100644 --- a/lib/datasource/github-tags/index.ts +++ b/lib/datasource/github-tags/index.ts @@ -29,7 +29,7 @@ async function getTagCommit( getCacheKey(githubRepo, `tag-${tag}`) ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } let digest: string; @@ -81,7 +81,7 @@ export async function getDigest( getCacheKey(githubRepo, 'commit') ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } let digest: string; @@ -95,9 +95,6 @@ export async function getDigest( 'Error getting latest commit from GitHub repo' ); } - if (!digest) { - return null; - } const cacheMinutes = 10; await globalCache.set( cacheNamespace, @@ -105,7 +102,7 @@ export async function getDigest( digest, cacheMinutes ); - return digest; + return digest || null; } /** @@ -127,7 +124,7 @@ export async function getReleases({ getCacheKey(repo, 'tags') ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } try { diff --git a/lib/datasource/gitlab-tags/index.ts b/lib/datasource/gitlab-tags/index.ts index 15411d83cf8c0c013ded9d40472beee3576ff6bb..93f5169b642307a4d9cb1644936e26b49a0dd833 100644 --- a/lib/datasource/gitlab-tags/index.ts +++ b/lib/datasource/gitlab-tags/index.ts @@ -35,7 +35,7 @@ export async function getReleases({ getCacheKey(depHost, repo) ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } diff --git a/lib/datasource/helm/index.ts b/lib/datasource/helm/index.ts index d646d07d2178fd7de7056ba3ec2997237d97f70b..06854b78883348179b57d4ac3dfb69a53594f949 100644 --- a/lib/datasource/helm/index.ts +++ b/lib/datasource/helm/index.ts @@ -21,7 +21,7 @@ export async function getRepositoryData( const cacheKey = repository; const cachedIndex = await globalCache.get(cacheNamespace, cacheKey); // istanbul ignore if - if (cachedIndex) { + if (cachedIndex !== undefined) { return cachedIndex; } let res: any; diff --git a/lib/datasource/maven/index.ts b/lib/datasource/maven/index.ts index 99efb384dde0ef3dd21b380c904973f82e9fb2ba..d381e81472120e2f2ea4a48eb8d9daaa5bca203c 100644 --- a/lib/datasource/maven/index.ts +++ b/lib/datasource/maven/index.ts @@ -162,7 +162,7 @@ async function getVersionsFromMetadata( cacheKey ); /* istanbul ignore if */ - if (cachedVersions) { + if (cachedVersions !== undefined) { return cachedVersions; } diff --git a/lib/datasource/npm/get.ts b/lib/datasource/npm/get.ts index d2f0e2ab362cc62d063f056b94141fb74583c683..9caed7b5d1a82cb5c8d7e29e6b02383734a61fef 100644 --- a/lib/datasource/npm/get.ts +++ b/lib/datasource/npm/get.ts @@ -75,7 +75,7 @@ export async function getDependency( pkgUrl ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } const headers: OutgoingHttpHeaders = {}; diff --git a/lib/datasource/nuget/v3.ts b/lib/datasource/nuget/v3.ts index 507af6cbea354257df51dc48ab932dc5155fd274..cec3735a4fce7c994a969439d60daa60b5833bc1 100644 --- a/lib/datasource/nuget/v3.ts +++ b/lib/datasource/nuget/v3.ts @@ -24,7 +24,7 @@ export async function getQueryUrl(url: string): Promise<string | null> { const cachedResult = await globalCache.get<string>(cacheNamespace, cacheKey); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } diff --git a/lib/datasource/orb/index.ts b/lib/datasource/orb/index.ts index 0d54db74e9217f98ee6cd6328032fae2c3e64ec2..cb5d4aefdf197d35c41c0efb42d8a2053f749d1d 100644 --- a/lib/datasource/orb/index.ts +++ b/lib/datasource/orb/index.ts @@ -31,7 +31,7 @@ export async function getReleases({ cacheKey ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } const url = 'https://circleci.com/graphql-unstable'; diff --git a/lib/datasource/packagist/index.ts b/lib/datasource/packagist/index.ts index 73d8d3e238ff7bf7f4a70486212b323760bc5786..365990dabdc527250a6de868b8246de959625dab 100644 --- a/lib/datasource/packagist/index.ts +++ b/lib/datasource/packagist/index.ts @@ -236,7 +236,7 @@ async function packagistOrgLookup(name: string): Promise<ReleaseResult> { name ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } let dep: ReleaseResult = null; diff --git a/lib/datasource/pod/index.ts b/lib/datasource/pod/index.ts index ce957dad14780c55ce8260ee77dd6ddc26b8ff5f..d4dfe7ede82fcfee3e671c90ae5361cb38f0faf6 100644 --- a/lib/datasource/pod/index.ts +++ b/lib/datasource/pod/index.ts @@ -158,7 +158,7 @@ export async function getReleases({ podName ); /* istanbul ignore next line */ - if (cachedResult) { + if (cachedResult !== undefined) { logger.debug(`CocoaPods: Return cached result for ${podName}`); return cachedResult; } diff --git a/lib/datasource/repology/index.ts b/lib/datasource/repology/index.ts index e45c10f021ed23d0954a481f22b33593b8aaa26e..d0c144354df5d5317e09c8543b6d5eb9cf16cbb4 100644 --- a/lib/datasource/repology/index.ts +++ b/lib/datasource/repology/index.ts @@ -89,7 +89,7 @@ async function getCachedPackage( cacheKey ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } diff --git a/lib/datasource/ruby-version/index.ts b/lib/datasource/ruby-version/index.ts index c3315f04e16dc2bc3bf061eb36483aab316da2b1..f5665342b25479f5c43f681f54990da1aeb60e0f 100644 --- a/lib/datasource/ruby-version/index.ts +++ b/lib/datasource/ruby-version/index.ts @@ -21,7 +21,7 @@ export async function getReleases( 'all' ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } try { diff --git a/lib/datasource/terraform-module/index.ts b/lib/datasource/terraform-module/index.ts index 62498efef9bb95a9126bd027017186a603c4f2bd..b18997eadb7e30cf7f52f06e3207b07127de5068 100644 --- a/lib/datasource/terraform-module/index.ts +++ b/lib/datasource/terraform-module/index.ts @@ -71,7 +71,7 @@ export async function getReleases({ pkgUrl ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } try { diff --git a/lib/datasource/terraform-provider/index.ts b/lib/datasource/terraform-provider/index.ts index abe32ad04aa3a47a2a782c4b44dd62a94a03231f..a97f2c333ed002f76073e836799f496298f27bc0 100644 --- a/lib/datasource/terraform-provider/index.ts +++ b/lib/datasource/terraform-provider/index.ts @@ -34,7 +34,7 @@ export async function getReleases({ pkgUrl ); // istanbul ignore if - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } try { diff --git a/lib/manager/bazel/update.ts b/lib/manager/bazel/update.ts index 9d9def06e3e57845ca16200af89c5c96e599247f..ea03cc3ff00118990710f38f57b845db0e332407 100644 --- a/lib/manager/bazel/update.ts +++ b/lib/manager/bazel/update.ts @@ -51,7 +51,7 @@ async function getHashFromUrl(url: string): Promise<string | null> { url ); /* istanbul ignore next line */ - if (cachedResult) { + if (cachedResult !== undefined) { return cachedResult; } try { diff --git a/lib/util/cache/global/file.spec.ts b/lib/util/cache/global/file.spec.ts index 7a774e39019ad2a024e5fbffce842f79997fb7e4..e01b33536de1d96c0c746608632bb7efb017c7ea 100644 --- a/lib/util/cache/global/file.spec.ts +++ b/lib/util/cache/global/file.spec.ts @@ -6,8 +6,10 @@ describe('lib/util/cache/global/file', () => { init(os.tmpdir()); }); - it('gets null', async () => { - expect(await global.renovateCache.get('test', 'missing-key')).toBeNull(); + it('returns undefined if no match', async () => { + expect( + await global.renovateCache.get('test', 'missing-key') + ).toBeUndefined(); }); it('sets and gets', async () => { @@ -17,6 +19,6 @@ describe('lib/util/cache/global/file', () => { it('expires', async () => { await global.renovateCache.set('test', 'key', 1234, -5); - expect(await global.renovateCache.get('test', 'key')).toBeNull(); + expect(await global.renovateCache.get('test', 'key')).toBeUndefined(); }); }); diff --git a/lib/util/cache/global/file.ts b/lib/util/cache/global/file.ts index 589dd84e3a52c838e6f2b7f4aff1f60ba3a7c109..e13818c5af40bed027a7bad0d78fe7bbfa8572b7 100644 --- a/lib/util/cache/global/file.ts +++ b/lib/util/cache/global/file.ts @@ -29,7 +29,7 @@ async function get<T = never>(namespace: string, key: string): Promise<T> { } catch (err) { logger.trace({ namespace, key }, 'Cache miss'); } - return null; + return undefined; } async function set( diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index 2ac8bae972b6177270958690f5a1144f89567957..124c3456052b5dca13b58ab132ed767511df9390 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -355,7 +355,7 @@ export async function addReleaseNotes( let releaseNotes: ChangeLogNotes; const cacheKey = getCacheKey(v.version); releaseNotes = await globalCache.get(cacheNamespace, cacheKey); - if (!releaseNotes) { + if (releaseNotes === undefined) { if (input.project.github != null) { releaseNotes = await getReleaseNotesMd( repository, @@ -388,7 +388,7 @@ export async function addReleaseNotes( await globalCache.set( cacheNamespace, cacheKey, - releaseNotes, + releaseNotes || null, cacheMinutes ); } diff --git a/lib/workers/pr/changelog/source-github.ts b/lib/workers/pr/changelog/source-github.ts index 33e7a6c0dafc0f23ad60ae6b5d0ca90f7ac43cb9..24237281af30b168d8a4ee0b01c931570d652720 100644 --- a/lib/workers/pr/changelog/source-github.ts +++ b/lib/workers/pr/changelog/source-github.ts @@ -155,7 +155,7 @@ export async function getChangeLogJSON({ getCacheKey(prev.version, next.version) ); // istanbul ignore else - if (!release) { + if (release === undefined) { release = { version: next.version, date: next.releaseTimestamp, diff --git a/lib/workers/pr/changelog/source-gitlab.ts b/lib/workers/pr/changelog/source-gitlab.ts index 4826fe4dd612cb695d85f143ea1e8436e8f7d170..694519ca0762dd8b6f0468748c69ebbf2a87cea1 100644 --- a/lib/workers/pr/changelog/source-gitlab.ts +++ b/lib/workers/pr/changelog/source-gitlab.ts @@ -135,7 +135,7 @@ export async function getChangeLogJSON({ cacheNamespace, getCacheKey(prev.version, next.version) ); - if (!release) { + if (release === undefined) { release = { version: next.version, date: next.releaseTimestamp, diff --git a/lib/workers/repository/stats.ts b/lib/workers/repository/stats.ts index 167a8b659df7b354eff33cc8eadf393d64c9b60a..dc015fc3b1aebea0d3a1907f61a38583d2d65ca1 100644 --- a/lib/workers/repository/stats.ts +++ b/lib/workers/repository/stats.ts @@ -26,7 +26,7 @@ export function printRequestStats(): void { requestHosts[hostname] = requestHosts[hostname] || []; requestHosts[hostname].push(request.duration); } - logger.trace({ allRequests, requestHosts }, 'full stats'); + logger.debug({ allRequests, requestHosts }, 'full stats'); const hostStats: string[] = []; let totalRequests = 0; for (const [hostname, requests] of Object.entries(requestHosts)) {