Skip to content

Commit

Permalink
impl: ajusta feedbackMessage a partir de sugestões do CR
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanpsv committed Nov 12, 2020
1 parent 7e51ab9 commit 5bb2573
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions feedbackMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const buildFeedbackMessage = (stylelintOutcomes, root) => {

let feedbackMessage = [];

feedbackMessage.push(feedBackTitleMessage('erro', errorCount));
feedbackMessage.push(feedbackTitleMessage('erro', errorCount));
feedbackMessage = addIssueLineMessage(feedbackMessage, errorIssues, true);

feedbackMessage.push(feedBackTitleMessage('aviso', warningCount));
feedbackMessage.push(feedbackTitleMessage('aviso', warningCount));
feedbackMessage = addIssueLineMessage(feedbackMessage, warningIssues);

return feedbackMessage.join('\n');
Expand Down Expand Up @@ -36,12 +36,9 @@ const extractStylelintIssues = (stylelintOutcomes) => {

const splitIssues = (issues, root) => {
return issues.reduce((total, currentValue) => {
let errorIssues = [];
let warningIssues = [];
const { source, error, warning } = currentValue;

errorIssues = buildIssuesMessage(source, error, root);
warningIssues = buildIssuesMessage(source, warning, root);
const errorIssues = buildIssuesMessage(source, error, root);
const warningIssues = buildIssuesMessage(source, warning, root);

return {
errorIssues: total.errorIssues.concat(...errorIssues),
Expand All @@ -51,7 +48,7 @@ const splitIssues = (issues, root) => {
};

const buildIssuesMessage = (source, issues, root) => {
let messages = [];
const messages = [];
if (issues.length > 0) {
messages.push(buildFileSection(source, root));
issues.map(({ line, text }) => messages.push(buildDetailedMessage(line, text)));
Expand All @@ -66,7 +63,7 @@ const buildFileSection = (filePath, root) => {

const buildDetailedMessage = (line, message) => `- Linha **${line}**: ${message}`;

const feedBackTitleMessage = (issueType, count) => {
const feedbackTitleMessage = (issueType, count) => {
if (count === 0) return `### Nenhum ${issueType} encontrado.`;
if (count === 1) return `### Foi encontrado 1 ${issueType}.\n`;
return `### Foram encontrados ${count} ${issueType}s.\n`;
Expand Down

0 comments on commit 5bb2573

Please sign in to comment.