diff --git a/.eslintrc.js b/.eslintrc.js index c74a7caf07f47f63ef5218a54184b048ec43f5d6..c2c970e27d2e4bc56f229f95dae3bebd465ed1ec 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -41,7 +41,7 @@ module.exports = { 'prefer-destructuring': 0, 'prefer-template': 0, 'no-underscore-dangle': 0, - + 'no-negated-condition': 'error', 'sort-imports': [ 'error', { diff --git a/lib/config/migration.ts b/lib/config/migration.ts index 9f9b7f6bd83b0469c48e876d68e7a6d54850d179..423b884bebd3ec267b5ba04a376eb8975d926362 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -465,11 +465,11 @@ export function migrateConfig( delete migratedConfig.node.enabled; migratedConfig.travis = migratedConfig.travis || {}; migratedConfig.travis.enabled = true; - if (!Object.keys(migratedConfig.node).length) { - delete migratedConfig.node; - } else { + if (Object.keys(migratedConfig.node).length) { const subMigrate = migrateConfig(migratedConfig.node, key); migratedConfig.node = subMigrate.migratedConfig; + } else { + delete migratedConfig.node; } } else if (is.array(val)) { const newArray = []; diff --git a/lib/config/validation.ts b/lib/config/validation.ts index d379f7e6e4bdc8c02ad76f43c6dae58c19dd72c6..40638d09c6dce7ee6cbb4ec6191a987574bfe37a 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -179,12 +179,7 @@ export async function validateConfig( }); } } else if (type === 'array' && val) { - if (!is.array(val)) { - errors.push({ - depName: 'Configuration Error', - message: `Configuration option \`${currentPath}\` should be a list (Array)`, - }); - } else { + if (is.array(val)) { for (const [subIndex, subval] of val.entries()) { if (is.object(subval)) { const subValidation = await module.exports.validateConfig( @@ -297,12 +292,7 @@ export async function validateConfig( ', ' )}`, }); - } else if (!is.nonEmptyArray(regexManager.fileMatch)) { - errors.push({ - depName: 'Configuration Error', - message: `Each Regex Manager must contain a fileMatch array`, - }); - } else { + } else if (is.nonEmptyArray(regexManager.fileMatch)) { let validRegex = false; for (const matchString of regexManager.matchStrings) { try { @@ -337,6 +327,11 @@ export async function validateConfig( } } } + } else { + errors.push({ + depName: 'Configuration Error', + message: `Each Regex Manager must contain a fileMatch array`, + }); } } } @@ -379,6 +374,11 @@ export async function validateConfig( message: `${currentPath}: ${key} should be inside a \`packageRule\` only`, }); } + } else { + errors.push({ + depName: 'Configuration Error', + message: `Configuration option \`${currentPath}\` should be a list (Array)`, + }); } } else if (type === 'string') { if (!is.string(val)) { diff --git a/lib/datasource/github-releases/index.ts b/lib/datasource/github-releases/index.ts index ed526de93a4fa5fc3dbbac195e5128a11582a79f..8bd862f07e0f22bea8559e3b74fed6f50afcc37a 100644 --- a/lib/datasource/github-releases/index.ts +++ b/lib/datasource/github-releases/index.ts @@ -49,10 +49,9 @@ export async function getReleases({ registryUrl ?? 'https://github.com/' ); const apiBaseUrl = - sourceUrlBase !== 'https://github.com/' - ? `${sourceUrlBase}api/v3/` - : `https://api.github.com/`; - + sourceUrlBase === 'https://github.com/' + ? `https://api.github.com/` + : `${sourceUrlBase}api/v3/`; const url = `${apiBaseUrl}repos/${repo}/releases?per_page=100`; const res = await http.getJson<GithubRelease[]>(url, { paginate: true, diff --git a/lib/datasource/github-tags/index.ts b/lib/datasource/github-tags/index.ts index 70411550dec358079671b5d3c6c0f2280677f1d4..b26efa501e4130b1ce3cb47672474e1aaacbe74d 100644 --- a/lib/datasource/github-tags/index.ts +++ b/lib/datasource/github-tags/index.ts @@ -43,9 +43,9 @@ async function getTagCommit( registryUrl ?? 'https://github.com/' ); const apiBaseUrl = - sourceUrlBase !== 'https://github.com/' - ? `${sourceUrlBase}api/v3/` - : `https://api.github.com/`; + sourceUrlBase === 'https://github.com/' + ? `https://api.github.com/` + : `${sourceUrlBase}api/v3/`; let digest: string; try { const url = `${apiBaseUrl}repos/${githubRepo}/git/refs/tags/${tag}`; @@ -103,9 +103,9 @@ export async function getDigest( registryUrl ?? 'https://github.com/' ); const apiBaseUrl = - sourceUrlBase !== 'https://github.com/' - ? `${sourceUrlBase}api/v3/` - : `https://api.github.com/`; + sourceUrlBase === 'https://github.com/' + ? `https://api.github.com/` + : `${sourceUrlBase}api/v3/`; let digest: string; try { const url = `${apiBaseUrl}repos/${repo}/commits?per_page=1`; @@ -148,10 +148,9 @@ async function getTags({ registryUrl ?? 'https://github.com/' ); const apiBaseUrl = - sourceUrlBase !== 'https://github.com/' - ? `${sourceUrlBase}api/v3/` - : `https://api.github.com/`; - + sourceUrlBase === 'https://github.com/' + ? `https://api.github.com/` + : `${sourceUrlBase}api/v3/`; // tag const url = `${apiBaseUrl}repos/${repo}/tags?per_page=100`; type GitHubTag = { diff --git a/lib/datasource/sbt-plugin/index.ts b/lib/datasource/sbt-plugin/index.ts index 30e44550f659b0b15c5456bb9f8bc629ef4879b1..590774beeb04a855642ca2967198de085c37e5a5 100644 --- a/lib/datasource/sbt-plugin/index.ts +++ b/lib/datasource/sbt-plugin/index.ts @@ -36,9 +36,9 @@ async function resolvePluginReleases( const scalaVersions = scalaVersionItems.map((x) => x.replace(/^scala_/, '') ); - const searchVersions = !scalaVersions.includes(scalaVersion) - ? scalaVersions - : [scalaVersion]; + const searchVersions = scalaVersions.includes(scalaVersion) + ? [scalaVersion] + : scalaVersions; for (const searchVersion of searchVersions) { const searchSubRoot = `${searchRoot}/scala_${searchVersion}`; const subRootContent = await downloadHttpProtocol( diff --git a/lib/manager/buildkite/extract.ts b/lib/manager/buildkite/extract.ts index 0281d1b9ed3d51114bc06bb96f7d0a427f35edfb..cd01753bc134d3846b0292c6f58e090b708cf4ea 100644 --- a/lib/manager/buildkite/extract.ts +++ b/lib/manager/buildkite/extract.ts @@ -35,13 +35,7 @@ export function extractPackageFile(content: string): PackageFile | null { if (depName.startsWith('https://') || depName.startsWith('git@')) { logger.debug({ dependency: depName }, 'Skipping git plugin'); skipReason = SkipReason.GitPlugin; - } else if (!isVersion(currentValue)) { - logger.debug( - { currentValue }, - 'Skipping non-pinned current version' - ); - skipReason = SkipReason.InvalidVersion; - } else { + } else if (isVersion(currentValue)) { const splitName = depName.split('/'); if (splitName.length === 1) { repo = `buildkite-plugins/${depName}-buildkite-plugin`; @@ -54,6 +48,12 @@ export function extractPackageFile(content: string): PackageFile | null { ); skipReason = SkipReason.InvalidDependencySpecification; } + } else { + logger.debug( + { currentValue }, + 'Skipping non-pinned current version' + ); + skipReason = SkipReason.InvalidVersion; } const dep: PackageDependency = { depName, diff --git a/lib/manager/dockerfile/extract.ts b/lib/manager/dockerfile/extract.ts index df99044ddc8ecf352c46596dc81c3c4f6b90ab1d..fae09b1aff9eabb5f8cad312d13343155eb2bfd1 100644 --- a/lib/manager/dockerfile/extract.ts +++ b/lib/manager/dockerfile/extract.ts @@ -103,12 +103,7 @@ export function extractPackageFile(content: string): PackageFile | null { { image: copyFromMatch.groups.image }, 'Skipping alias COPY --from' ); - } else if (!Number.isNaN(Number(copyFromMatch.groups.image))) { - logger.debug( - { image: copyFromMatch.groups.image }, - 'Skipping index reference COPY --from' - ); - } else { + } else if (Number.isNaN(Number(copyFromMatch.groups.image))) { const dep = getDep(copyFromMatch.groups.image); logger.debug( { @@ -119,6 +114,11 @@ export function extractPackageFile(content: string): PackageFile | null { 'Dockerfile COPY --from' ); deps.push(dep); + } else { + logger.debug( + { image: copyFromMatch.groups.image }, + 'Skipping index reference COPY --from' + ); } } if (!deps.length) { diff --git a/lib/manager/gomod/extract.ts b/lib/manager/gomod/extract.ts index 5ea27cdcbc9e2b643433b75a8c082190da7c9e3c..8bc055941ce99247508db941b759bd6d2a54abac 100644 --- a/lib/manager/gomod/extract.ts +++ b/lib/manager/gomod/extract.ts @@ -21,10 +21,10 @@ function getDep( depType: type, currentValue, }; - if (!isVersion(currentValue)) { - dep.skipReason = SkipReason.UnsupportedVersion; - } else { + if (isVersion(currentValue)) { dep.datasource = datasourceGo.id; + } else { + dep.skipReason = SkipReason.UnsupportedVersion; } const digestMatch = /v0\.0.0-\d{14}-([a-f0-9]{12})/.exec(currentValue); if (digestMatch) { diff --git a/lib/manager/gradle/gradle-updates-report.ts b/lib/manager/gradle/gradle-updates-report.ts index 7244037a6ca3bfbde6052eed14e19093283fc421..1398fb99a43877bd8f47a955dc0b3bbef9a6aa54 100644 --- a/lib/manager/gradle/gradle-updates-report.ts +++ b/lib/manager/gradle/gradle-updates-report.ts @@ -116,13 +116,13 @@ function combineReposOnDuplicatedDependencies( const existingDependency = accumulator.find( (dep) => dep.name === currentValue.name && dep.group === currentValue.group ); - if (!existingDependency) { - accumulator.push(currentValue); - } else { + if (existingDependency) { const nonExistingRepos = currentValue.repos.filter( (repo) => !existingDependency.repos.includes(repo) ); existingDependency.repos.push(...nonExistingRepos); + } else { + accumulator.push(currentValue); } return accumulator; } diff --git a/lib/manager/leiningen/extract.ts b/lib/manager/leiningen/extract.ts index 179cab020fd4e3e3fb8259ed4451ec41654369b6..360c4ce3d9ab47adb6792337e5ad04a1f2ef689b 100644 --- a/lib/manager/leiningen/extract.ts +++ b/lib/manager/leiningen/extract.ts @@ -16,7 +16,7 @@ export function trimAtKey(str: string, kwName: string): string | null { } export function expandDepName(name: string): string { - return !name.includes('/') ? `${name}:${name}` : name.replace('/', ':'); + return name.includes('/') ? name.replace('/', ':') : `${name}:${name}`; } export interface ExtractContext { diff --git a/lib/manager/npm/post-update/index.ts b/lib/manager/npm/post-update/index.ts index ea37ca644622cbba87a2a03bdda7e32ce66bd69d..9f2adda8373026d58a9332505784235558820dda 100644 --- a/lib/manager/npm/post-update/index.ts +++ b/lib/manager/npm/post-update/index.ts @@ -545,14 +545,14 @@ export async function getAdditionalFiles( lockFile, config.reuseExistingBranch ? config.branchName : config.baseBranch ); - if (res.lockFile !== existingContent) { + if (res.lockFile === existingContent) { + logger.debug(`${lockFile} hasn't changed`); + } else { logger.debug(`${lockFile} needs updating`); updatedArtifacts.push({ name: lockFile, contents: res.lockFile.replace(new RegExp(`${token}`, 'g'), ''), }); - } else { - logger.debug(`${lockFile} hasn't changed`); } } await resetNpmrcContent(fullLockFileDir, npmrcContent); @@ -611,15 +611,15 @@ export async function getAdditionalFiles( lockFileName, config.reuseExistingBranch ? config.branchName : config.baseBranch ); - if (res.lockFile !== existingContent) { + if (res.lockFile === existingContent) { + logger.debug("yarn.lock hasn't changed"); + } else { logger.debug('yarn.lock needs updating'); updatedArtifacts.push({ name: lockFileName, contents: res.lockFile, }); await updateYarnOffline(lockFileDir, config.localDir, updatedArtifacts); - } else { - logger.debug("yarn.lock hasn't changed"); } } await resetNpmrcContent(fullLockFileDir, npmrcContent); @@ -675,14 +675,14 @@ export async function getAdditionalFiles( lockFile, config.reuseExistingBranch ? config.branchName : config.baseBranch ); - if (res.lockFile !== existingContent) { + if (res.lockFile === existingContent) { + logger.debug("pnpm-lock.yaml hasn't changed"); + } else { logger.debug('pnpm-lock.yaml needs updating'); updatedArtifacts.push({ name: lockFile, contents: res.lockFile, }); - } else { - logger.debug("pnpm-lock.yaml hasn't changed"); } } await resetNpmrcContent(fullLockFileDir, npmrcContent); @@ -790,14 +790,14 @@ export async function getAdditionalFiles( 'utf8' ); } - if (newContent !== existingContent) { + if (newContent === existingContent) { + logger.trace('File is unchanged'); + } else { logger.debug('File is updated: ' + lockFilePath); updatedArtifacts.push({ name: filename, contents: newContent, }); - } else { - logger.trace('File is unchanged'); } } catch (err) { if (config.updateType === 'lockFileMaintenance') { diff --git a/lib/manager/terraform/resources.ts b/lib/manager/terraform/resources.ts index 85cd763e2ff6a5971db18534e38679e04ce4e203..62c986261c8806d5779c4b0137604b0c3f8986d2 100644 --- a/lib/manager/terraform/resources.ts +++ b/lib/manager/terraform/resources.ts @@ -71,26 +71,26 @@ export function analyseTerraformResource( switch (dep.managerData.resourceType) { case TerraformResourceTypes.docker_container: - if (!dep.managerData.image) { - dep.skipReason = SkipReason.InvalidDependencySpecification; - } else { + if (dep.managerData.image) { applyDockerDependency(dep, dep.managerData.image); + } else { + dep.skipReason = SkipReason.InvalidDependencySpecification; } break; case TerraformResourceTypes.docker_image: - if (!dep.managerData.name) { - dep.skipReason = SkipReason.InvalidDependencySpecification; - } else { + if (dep.managerData.name) { applyDockerDependency(dep, dep.managerData.name); + } else { + dep.skipReason = SkipReason.InvalidDependencySpecification; } break; case TerraformResourceTypes.docker_service: - if (!dep.managerData.image) { - dep.skipReason = SkipReason.InvalidDependencySpecification; - } else { + if (dep.managerData.image) { applyDockerDependency(dep, dep.managerData.image); + } else { + dep.skipReason = SkipReason.InvalidDependencySpecification; } break; diff --git a/lib/platform/azure/azure-helper.ts b/lib/platform/azure/azure-helper.ts index d94fd1b55f32d1c2aa65f1d34b0b78bcf12c274e..b72175cee0c32d1d01878d88c4dcdd5d0787a839 100644 --- a/lib/platform/azure/azure-helper.ts +++ b/lib/platform/azure/azure-helper.ts @@ -26,12 +26,12 @@ export function getStorageExtraCloneOpts(config: HostRule): GitOptions { if (!config.token && config.username && config.password) { authType = 'basic'; authValue = toBase64(`${config.username}:${config.password}`); - } else if (config.token.length !== 52) { - authType = 'bearer'; - authValue = config.token; - } else { + } else if (config.token.length === 52) { authType = 'basic'; authValue = toBase64(`:${config.token}`); + } else { + authType = 'bearer'; + authValue = config.token; } add(authValue); return { diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 98ac60fc365b84c6f635a82db70d01b3ee92a42a..410d12fcf4028f92e92c69707d8ba7c53a67e915 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -123,11 +123,10 @@ export async function getJsonFile(fileName: string): Promise<any | null> { const { body } = await bitbucketServerHttp.getJson<FileData>( `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/browse/${fileName}?limit=20000` ); - if (!body.isLastPage) { - logger.warn({ size: body.size }, `The file is too big`); - } else { + if (body.isLastPage) { return JSON.parse(body.lines.map((l) => l.text).join('')); } + logger.warn({ size: body.size }, `The file is too big`); } catch (err) { // no-op } diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index f449b22b825bbc50b534d6bba6c49624e9fb09b2..bdbe2b31e4f319c13ff3f362ed35d9f599c4cc09 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -728,14 +728,14 @@ const platform: Platform = { { repository: config.repository, issue, comment: c.id }, 'Comment added' ); - } else if (comment.body !== body) { + } else if (comment.body === body) { + logger.debug(`Comment #${comment.id} is already up-to-date`); + } else { const c = await helper.updateComment(config.repository, issue, body); logger.debug( { repository: config.repository, issue, comment: c.id }, 'Comment updated' ); - } else { - logger.debug(`Comment #${comment.id} is already up-to-date`); } return true; diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 3fb7a9965dbf725d09192ca1280bc6a6f7044690..7c48180185f8e2733f8f0b5b6e0799b6f733be21 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -628,11 +628,11 @@ async function getOpenPrs(): Promise<PrList> { if (hasNegativeReview) { pr.canMerge = false; pr.canMergeReason = `hasNegativeReview`; - } else if (!canMergeStates.includes(pr.mergeStateStatus)) { + } else if (canMergeStates.includes(pr.mergeStateStatus)) { + pr.canMerge = true; + } else { pr.canMerge = false; pr.canMergeReason = `mergeStateStatus = ${pr.mergeStateStatus}`; - } else { - pr.canMerge = true; } // https://developer.github.com/v4/enum/mergestatestatus if (pr.mergeStateStatus === 'DIRTY') { diff --git a/lib/platform/index.ts b/lib/platform/index.ts index f3c5a420658c682c112c77bfa6205c1654131eb2..1ed921fa67c4bf95418580b2f0d3a8ea237fb9a7 100644 --- a/lib/platform/index.ts +++ b/lib/platform/index.ts @@ -90,17 +90,18 @@ export async function initPlatform( const platformInfo = await platform.initPlatform(config); const returnConfig: any = { ...config, ...platformInfo }; let gitAuthor: string; + // istanbul ignore else if (config?.gitAuthor) { logger.debug(`Using configured gitAuthor (${config.gitAuthor})`); gitAuthor = config.gitAuthor; - } else if (!platformInfo?.gitAuthor) { + } else if (platformInfo?.gitAuthor) { + logger.debug(`Using platform gitAuthor: ${String(platformInfo.gitAuthor)}`); + gitAuthor = platformInfo.gitAuthor; + } else { logger.debug( 'Using default gitAuthor: Renovate Bot <renovate@whitesourcesoftware.com>' ); gitAuthor = 'Renovate Bot <renovate@whitesourcesoftware.com>'; - } /* istanbul ignore next */ else { - logger.debug(`Using platform gitAuthor: ${String(platformInfo.gitAuthor)}`); - gitAuthor = platformInfo.gitAuthor; } const gitAuthorParsed = parseGitAuthor(gitAuthor); // istanbul ignore if diff --git a/lib/versioning/hex/index.ts b/lib/versioning/hex/index.ts index 4fbbc1393b424b2d3f8971b0381cc374b620781e..9482680515e7cec9d308386a5b205051128c751c 100644 --- a/lib/versioning/hex/index.ts +++ b/lib/versioning/hex/index.ts @@ -32,10 +32,10 @@ function npm2hex(input: string): string { if (i < res.length - 1 && res[i + 1].includes('||')) { output += res[i] + ' or '; i += 1; - } else if (!operators.includes(res[i])) { - output += res[i] + ' and '; - } else { + } else if (operators.includes(res[i])) { output += res[i] + ' '; + } else { + output += res[i] + ' and '; } } return output; @@ -78,7 +78,7 @@ const getNewValue = ({ newSemver = newSemver.replace( /\^\s*(\d+\.\d+)/, (_str, p1: string) => - `~> ${rangeStrategy !== 'bump' ? p1.slice(0, -2) : p1}` + `~> ${rangeStrategy === 'bump' ? p1 : p1.slice(0, -2)}` ); } else { newSemver = newSemver.replace(/~\s*(\d+\.\d+\.\d)/, '~> $1'); diff --git a/lib/versioning/ivy/parse.ts b/lib/versioning/ivy/parse.ts index 1b1c8ba59847f1b02e25bd08565bc46ff4f37c58..568bdb5eff3202b06b5e333ad70e24282c4d10e7 100644 --- a/lib/versioning/ivy/parse.ts +++ b/lib/versioning/ivy/parse.ts @@ -21,7 +21,7 @@ function parseDynamicRevision(str: string): Revision | null { const value = str.replace(LATEST_REGEX, '').toLowerCase() || null; return { type: REV_TYPE_LATEST, - value: value !== 'integration' ? value : null, + value: value === 'integration' ? null : value, }; } diff --git a/lib/versioning/maven/compare.ts b/lib/versioning/maven/compare.ts index 775d4b210227c5eb36168e1c13628c7b05c3d761..4e13d83ea106bfc6180f2e9dcc85782a24ef4420 100644 --- a/lib/versioning/maven/compare.ts +++ b/lib/versioning/maven/compare.ts @@ -547,9 +547,9 @@ function autoExtendMavenRange( if (interval.leftValue && interval.rightValue) { const correctRepresentation = - compare(interval.leftValue, interval.rightValue) !== 1 - ? rangeToStr(range) - : null; + compare(interval.leftValue, interval.rightValue) === 1 + ? null + : rangeToStr(range); return correctRepresentation || currentRepresentation; } return rangeToStr(range); diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts index 406faf98eb0b4b62b3622c19d8f5821b2452c8d5..7986565fa7e6bf214d710d05fc7f7a0f29976433 100644 --- a/lib/workers/branch/index.ts +++ b/lib/workers/branch/index.ts @@ -390,18 +390,10 @@ export async function processBranch( for (const cmd of commands) { if ( - !allowedPostUpgradeCommands.some((pattern) => + allowedPostUpgradeCommands.some((pattern) => regEx(pattern).test(cmd) ) ) { - logger.warn( - { - cmd, - allowedPostUpgradeCommands, - }, - 'Post-upgrade task did not match any on allowed list' - ); - } else { const compiledCmd = allowPostUpgradeCommandTemplating ? template.compile(cmd, upgrade) : cmd; @@ -416,6 +408,14 @@ export async function processBranch( { cmd: compiledCmd, ...execResult }, 'Executed post-upgrade task' ); + } else { + logger.warn( + { + cmd, + allowedPostUpgradeCommands, + }, + 'Post-upgrade task did not match any on allowed list' + ); } } diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index 805d0dd43eae046219d7477c73707cd8e6ef8f69..fd1f58aafc7b3a029cc11ba6f0020be664268527 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -117,9 +117,7 @@ export async function getReleaseNotes( ? `${baseUrl}${repository}/tags/${release.tag}` : `${baseUrl}${repository}/releases/${release.tag}`; releaseNotes.body = massageBody(releaseNotes.body, baseUrl); - if (!releaseNotes.body.length) { - releaseNotes = null; - } else { + if (releaseNotes.body.length) { try { if (baseUrl !== 'https://gitlab.com/') { releaseNotes.body = linkify(releaseNotes.body, { @@ -129,6 +127,8 @@ export async function getReleaseNotes( } catch (err) /* istanbul ignore next */ { logger.warn({ err, baseUrl, repository }, 'Error linkifying'); } + } else { + releaseNotes = null; } } }); @@ -317,10 +317,9 @@ export async function addReleaseNotes( return input; } const output: ChangeLogResult = { ...input, versions: [] }; - const repository = - input.project.github != null - ? input.project.github.replace(/\.git$/, '') - : input.project.gitlab; + const repository = input.project.github + ? input.project.github.replace(/\.git$/, '') + : input.project.gitlab; const cacheNamespace = input.project.github ? 'changelog-github-notes' : 'changelog-gitlab-notes'; diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index 3d3c6ee31d1a2ada2b1a2708f301e6b53b0b26ff..7b3579f15c253c0270a020b876097a2a103d8239 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -280,15 +280,15 @@ export async function lookupUpdates( } res.updates.push(update); } - } else if (!currentValue) { - res.skipReason = SkipReason.InvalidValue; - } else { + } else if (currentValue) { logger.debug(`Dependency ${depName} has unsupported value ${currentValue}`); if (!pinDigests && !currentDigest) { res.skipReason = SkipReason.InvalidValue; } else { delete res.skipReason; } + } else { + res.skipReason = SkipReason.InvalidValue; } // Record if the dep is fixed to a version diff --git a/lib/workers/repository/process/write.ts b/lib/workers/repository/process/write.ts index c83bb8fa469fbcfa4477e3b0aeaa171d844ad30d..b6ebcdf108814d3b43dac93b993a51a3ad7ada9f 100644 --- a/lib/workers/repository/process/write.ts +++ b/lib/workers/repository/process/write.ts @@ -15,7 +15,7 @@ export async function writeUpdates( let branches = allBranches; logger.debug( `Processing ${branches.length} branch${ - branches.length !== 1 ? 'es' : '' + branches.length === 1 ? '' : 'es' }: ${branches .map((b) => b.branchName) .sort() diff --git a/test/http-mock.ts b/test/http-mock.ts index 1317d730986f95e1a4126186e40d626483a8a94d..85c87181609cbd2805878a114beec65d67761640 100644 --- a/test/http-mock.ts +++ b/test/http-mock.ts @@ -88,10 +88,10 @@ type TestRequest = { }; function onMissing(req: TestRequest, opts?: TestRequest): void { - if (!opts) { - missingLog.push(` ${req.method} ${req.href}`); - } else { + if (opts) { missingLog.push(` ${opts.method} ${opts.href}`); + } else { + missingLog.push(` ${req.method} ${req.href}`); } }