Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSDoc for the summary table creator function #78

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion dist/formatters/utils/no-internal-summary-table-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ const fs = require('fs');
const process = require('process');
const createAsciiTable = require('./create-ascii-table');

/**
* Generates a summary table and optionally a CSV from linting messages for a specific rule.
*
* This function processes an array of linting messages, filters them by a specified rule ID,
* and then generates a summary table and optionally a CSV file based on these messages.
*
* The summary table is always created and returned while the CSV file is created only if the
* `createCSV` flag is set to `true`.
*
* @param {Object[]} messages - An array of linting message objects to be processed.
* @param {string} ruleId - The ID of the linting rule to filter messages by.
* @param {boolean} [createCSV=true] - A boolean flag indicating whether to create a CSV file (`true`)
* or not. Defaults to `true`.
aruniverse marked this conversation as resolved.
Show resolved Hide resolved
* @returns {string} The generated summary table as a string.
*/
module.exports = function(messages, ruleId, createCSV = true) {
const problemFiles = new Map();
const errorTracker = new Map();
Expand Down Expand Up @@ -41,7 +56,7 @@ module.exports = function(messages, ruleId, createCSV = true) {
});

if (problemFiles.size === 0 || errorTracker.size === 0 || tagViolationsTracker.size === 0)
return;
return '';

// iterate over the problemFiles and for each value, remove the last comma from locations
for (const [key, value] of problemFiles.entries()) {
Expand Down
Loading