Skip to content

Commit

Permalink
refactor: remove string interpolations (#22840)
Browse files Browse the repository at this point in the history
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
RahulGautamSingh and rarkins committed Jun 24, 2023
1 parent 4e78c17 commit 444ea13
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 22 deletions.
22 changes: 14 additions & 8 deletions lib/config-validator.ts
Expand Up @@ -34,11 +34,17 @@ async function validate(
const massagedConfig = massageConfig(migratedConfig);
const res = await validateConfig(massagedConfig, isPreset);
if (res.errors.length) {
logger.error({ errors: res.errors }, `${desc} contains errors`);
logger.error(
{ file: desc, errors: res.errors },
'Found errors in configuration'
);
returnVal = 1;
}
if (res.warnings.length) {
logger.warn({ warnings: res.warnings }, `${desc} contains warnings`);
logger.warn(
{ file: desc, warnings: res.warnings },
'Found errors in configuration'
);
returnVal = 1;
}
}
Expand All @@ -54,19 +60,19 @@ type PackageJson = {
try {
if (!(await pathExists(file))) {
returnVal = 1;
logger.error(`${file} does not exist`);
logger.error({ file }, 'File does not exist');
break;
}
const parsedContent = await getParsedContent(file);
try {
logger.info(`Validating ${file}`);
await validate(file, parsedContent);
} catch (err) {
logger.warn({ err }, `${file} is not valid Renovate config`);
logger.warn({ file, err }, 'File is not valid Renovate config');
returnVal = 1;
}
} catch (err) {
logger.warn({ err }, `${file} could not be parsed`);
logger.warn({ file, err }, 'File could not be parsed');
returnVal = 1;
}
}
Expand All @@ -83,11 +89,11 @@ type PackageJson = {
logger.info(`Validating ${file}`);
await validate(file, parsedContent);
} catch (err) {
logger.warn({ err }, `${file} is not valid Renovate config`);
logger.warn({ file, err }, 'File is not valid Renovate config');
returnVal = 1;
}
} catch (err) {
logger.warn({ err }, `${file} could not be parsed`);
logger.warn({ file, err }, 'File could not be parsed');
returnVal = 1;
}
}
Expand Down Expand Up @@ -116,7 +122,7 @@ type PackageJson = {
try {
await validate(file, fileConfig);
} catch (err) {
logger.error({ err }, `${file} is not valid Renovate config`);
logger.error({ file, err }, 'File is not valid Renovate config');
returnVal = 1;
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/modules/manager/gomod/artifacts.ts
Expand Up @@ -36,7 +36,10 @@ function getUpdateImportPathCmds(
);
if (invalidMajorDeps.length > 0) {
invalidMajorDeps.forEach(({ depName }) =>
logger.warn(`Could not get major version of ${depName!}. Ignoring`)
logger.warn(
{ depName },
'Ignoring dependency: Could not get major version'
)
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/pub/artifacts.ts
Expand Up @@ -96,7 +96,7 @@ export async function updateArtifacts({
if (err.message === TEMPORARY_ERROR) {
throw err;
}
logger.warn({ err }, `Failed to update ${lockFileName} file`);
logger.warn({ lockfile: lockFileName, err }, `Failed to update lock file`);
return [
{
artifactError: {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/gitea/index.ts
Expand Up @@ -737,7 +737,7 @@ const platform: Platform = {
for (const issue of issues) {
if (issue.state === 'open' && issue.number !== activeIssue.number) {
// TODO: types (#7154)
logger.warn(`Closing duplicate Issue #${issue.number!}`);
logger.warn({ issueNo: issue.number! }, 'Closing duplicate issue');
// TODO #7154
await helper.closeIssue(config.repository, issue.number!);
}
Expand Down
7 changes: 5 additions & 2 deletions lib/modules/platform/github/index.ts
Expand Up @@ -1192,7 +1192,7 @@ export async function ensureIssue({
}
for (const i of issues) {
if (i.state === 'open' && i.number !== issue.number) {
logger.warn(`Closing duplicate issue ${i.number}`);
logger.warn({ issueNo: i.number }, 'Closing duplicate issue');
// TODO #7154
await closeIssue(i.number!);
}
Expand Down Expand Up @@ -1693,7 +1693,10 @@ export async function mergePr({
'GitHub blocking PR merge -- will keep trying'
);
} else {
logger.warn({ err }, `Failed to ${config.mergeMethod} merge PR`);
logger.warn(
{ mergeMethod: config.mergeMethod, err },
'Failed to merge PR'
);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/versioning/ruby/index.ts
Expand Up @@ -141,7 +141,7 @@ const getNewValue = ({
break;
// istanbul ignore next
default:
logger.warn(`Unsupported strategy ${rangeStrategy}`);
logger.warn({ rangeStrategy }, 'Unsupported range strategy');
}
}
if (newValue && regEx(/^('|")/).exec(currentValue)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/versioning/ruby/range.ts
Expand Up @@ -98,7 +98,7 @@ type GemRequirement = [string, Version];
const ltr = (version: string, range: string): boolean => {
const gemVersion = create(version);
if (!gemVersion) {
logger.warn(`Invalid ruby version '${version}'`);
logger.warn({ version }, `Invalid ruby version`);
return false;
}
const requirements: GemRequirement[] = range.split(',').map(_parse);
Expand All @@ -120,7 +120,7 @@ const ltr = (version: string, range: string): boolean => {
);
// istanbul ignore next
default:
logger.warn(`Unsupported operator '${operator}'`);
logger.warn({ operator }, `Unsupported operator`);
return false;
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/versioning/ruby/strategies/replace.ts
Expand Up @@ -31,7 +31,7 @@ export function replacePart(part: Range, to: string): Range {
return part;
// istanbul ignore next
default:
logger.warn(`Unsupported operator '${operator}'`);
logger.warn({ operator }, `Unsupported ruby versioning operator`);
return { operator: '', delimiter: ' ', version: '' };
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/exec/docker/index.ts
Expand Up @@ -123,7 +123,7 @@ export async function getDockerTag(
return version;
}
} else {
logger.error(`No ${packageName} releases found`);
logger.error({ packageName }, `Docker exec: no releases found`);
return 'latest';
}
logger.warn(
Expand Down
2 changes: 1 addition & 1 deletion lib/util/http/bitbucket.ts
Expand Up @@ -34,7 +34,7 @@ export class BitbucketHttp extends Http<BitbucketHttpOptions> {

// istanbul ignore if: this should never happen
if (is.nullOrUndefined(resolvedURL)) {
logger.error(`Bitbucket: cannot parse path ${path}`);
logger.error({ path }, 'Bitbucket: cannot parse path');
throw new Error(`Bitbucket: cannot parse path ${path}`);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/workers/global/config/parse/host-rules-from-env.ts
Expand Up @@ -32,7 +32,7 @@ export function hostRulesFromEnv(env: NodeJS.ProcessEnv): HostRule[] {
if (splitEnv.length === 0) {
// host-less rule
} else if (splitEnv.length === 1) {
logger.warn(`Cannot parse ${envName} env`);
logger.warn({ env: envName }, 'Cannot parse env');
continue;
} else {
matchHost = splitEnv.join('.');
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/update/branch/index.ts
Expand Up @@ -873,7 +873,7 @@ export async function processBranch(
throw err;
}
// Otherwise don't throw here - we don't want to stop the other renovations
logger.error({ err }, `Error ensuring PR: ${String(err.message)}`);
logger.error({ err }, `Error ensuring PR`);
}
if (!branchExists) {
return {
Expand Down
5 changes: 4 additions & 1 deletion lib/workers/repository/update/pr/changelog/release-notes.ts
Expand Up @@ -364,7 +364,10 @@ export async function getReleaseNotesMd(
}
}
} catch (err) /* istanbul ignore next */ {
logger.warn({ err }, `Error parsing ${changelogFile}`);
logger.warn(
{ file: changelogFile, err },
`Error parsing changelog file`
);
}
}
}
Expand Down

0 comments on commit 444ea13

Please sign in to comment.