Skip to content

Commit

Permalink
lint-diff: fix warning count
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingluscas committed Jul 24, 2018
1 parent 7b4e1f0 commit b0f5939
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/lint-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
equals,
filter,
find,
length,
map,
merge,
objOf,
pipe,
pipeP,
Expand Down Expand Up @@ -65,9 +67,28 @@ const filterLinterMessages = changedFileLineMap => (linterOutput) => {
return filterMessages(result)
}

const countBySeverity = severity =>
pipe(
filter(propEq('severity', severity)),
length
)

const countWarningMessages = countBySeverity(1)

const warningCount = (result) => {
const transform = {
warningCount: countWarningMessages(result.messages),
}

return merge(result, transform)
}

return pipe(
prop('results'),
map(filterMessagesByFile),
map(pipe(
filterMessagesByFile,
warningCount
)),
objOf('results')
)(linterOutput)
}
Expand Down

0 comments on commit b0f5939

Please sign in to comment.