Skip to content

Commit

Permalink
feat(output): remove footer containing totals of each type of entry
Browse files Browse the repository at this point in the history
Closes #2
  • Loading branch information
JamieMason committed May 2, 2022
1 parent 6eac010 commit 9a85f42
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 222 deletions.
138 changes: 0 additions & 138 deletions .github/README_CONTENT.md

This file was deleted.

9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,7 @@ module.exports = gitLogFormatter.withConfig({
// Translations for plain text used when formatting
label: {
error: 'error',
warning: 'warning',
banner: 'REPORT COMPLETE',
totalFiles: 'Files',
totalAssignees: 'Assignees',
totalWarningsByEmail: `Warnings assigned to %s`,
totalErrorsByEmail: `Errors assigned to %s`,
totalWarnings: 'Warnings',
totalErrors: 'Errors',
warning: 'warning'
},
// Increase if you have files with 1000s of lines
locationColumnWidth: 8,
Expand Down
78 changes: 2 additions & 76 deletions src/formatters/git-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ interface FinalConfig {
error: string;
/** @example "warning" */
warning: string;
/** @example "REPORT COMPLETE" */
banner: string;
/** @example "Files" */
totalFiles: string;
/** @example "Assignees" */
totalAssignees: string;
/** @example "Warnings assigned to %s" */
totalWarningsByEmail: string;
/** @example "Errors assigned to %s" */
totalErrorsByEmail: string;
/** @example "Warnings" */
totalWarnings: string;
/** @example "Errors" */
totalErrors: string;
};
/** Increase if you have files with 1000s of lines */
locationColumnWidth: number;
Expand Down Expand Up @@ -108,13 +94,6 @@ export const defaultConfig: FinalConfig = Object.freeze({
label: {
error: 'error',
warning: 'warning',
banner: 'REPORT COMPLETE',
totalFiles: 'Files',
totalAssignees: 'Assignees',
totalWarningsByEmail: `Warnings assigned to %s`,
totalErrorsByEmail: `Errors assigned to %s`,
totalWarnings: 'Warnings',
totalErrors: 'Errors',
},
locationColumnWidth: 8,
style: {
Expand All @@ -140,17 +119,6 @@ export const createGitLogFormatter: CreateGitLogFormatter = (config) => {
const locationColumnWidth = getConfig<number>('locationColumnWidth');
const errorLabel = getConfig<string>('label.error');
const warningLabel = getConfig<string>('label.warning');
const bannerLabel = getConfig<string>('label.banner');
const totalFilesLabel = getConfig<string>('label.totalFiles');
const totalAssigneesLabel = getConfig<string>('label.totalAssignees');
const totalWarningsByEmailLabel = getConfig<string>(
'label.totalWarningsByEmail',
).replace('%s', `${emailRegExp}`);
const totalErrorsByEmailLabel = getConfig<string>(
'label.totalErrorsByEmail',
).replace('%s', `${emailRegExp}`);
const totalWarningsLabel = getConfig<string>('label.totalWarnings');
const totalErrorsLabel = getConfig<string>('label.totalErrors');
const styledError = getConfig<Chalk>('style.error');
const styledFilePath = getConfig<Chalk>('style.filePath');
const styledWarning = getConfig<Chalk>('style.warning');
Expand Down Expand Up @@ -194,9 +162,6 @@ export const createGitLogFormatter: CreateGitLogFormatter = (config) => {
gutter.length,
);

const cols = (col1: string | number, col2: string | number) =>
`${rightAlignToCol1(`${col1}`)}${col1}${gutter}${col2}`;

const formatMessage = ({
commit: rawCommit,
date: rawDate,
Expand All @@ -222,14 +187,6 @@ export const createGitLogFormatter: CreateGitLogFormatter = (config) => {
emailRegExp ? emailRegExp.test(email) : true;

const authors = new Set();
const total = {
all: 0,
errors: 0,
userErrors: 0,
userWarnings: 0,
visible: 0,
warnings: 0,
};

const body = results.reduce((output, result) => {
if (result.messages.length > 0) {
Expand All @@ -244,20 +201,7 @@ export const createGitLogFormatter: CreateGitLogFormatter = (config) => {
authors.add(item.email);
return item;
})
.filter(isIncluded)
.map((item) => {
if (item.message.severity === 2) {
total.userErrors++;
} else if (item.message.severity === 1) {
total.userWarnings++;
}
return item;
});

total.errors += result.errorCount;
total.warnings += result.warningCount;
total.all += result.messages.length;
total.visible += items.length;
.filter(isIncluded);

if (items.length > 0) {
output += `\n${styledFilePath(result.filePath)}\n`;
Expand All @@ -270,25 +214,7 @@ export const createGitLogFormatter: CreateGitLogFormatter = (config) => {
return output;
}, '');

const banner = chalk.inverse(` ${bannerLabel} `);

let footer = '';

if (emailRegExp) {
const totalWarnings = `${total.userWarnings}/${total.warnings}`;
const totalErrors = `${total.userErrors}/${total.errors}`;
footer += `${cols(results.length, totalFilesLabel)}\n`;
footer += `${cols(totalWarnings, totalWarningsByEmailLabel)}\n`;
footer += `${cols(totalErrors, totalErrorsByEmailLabel)}\n`;
footer += `${cols(authors.size, totalAssigneesLabel)}\n`;
} else {
footer += `${cols(results.length, totalFilesLabel)}\n`;
footer += `${cols(total.warnings, totalWarningsLabel)}\n`;
footer += `${cols(total.errors, totalErrorsLabel)}\n`;
footer += `${cols(authors.size, totalAssigneesLabel)}\n`;
}

return `${body}\n${banner}\n\n${footer}`;
return body;
};

formatter.defaultConfig = defaultConfig;
Expand Down

0 comments on commit 9a85f42

Please sign in to comment.