Skip to content

Commit

Permalink
fix: TypeError: Cannot read property 'errorCount' of undefined
Browse files Browse the repository at this point in the history
Without this patch, there are situations when the .solhintignore file
causes all inputs files being ignored. This is a problem because the
'reports' variable ends up being an empty array, and therefore
reports[0] is undefined.

This patch solves the problem by checking that reports array exists and
has a length greater than 0.

Thanks to Adam Spiers (@aspiers) who originally discovered a bug.

Issue-URL: https://bytemeta.vip/repo/protofire/solhint/issues/239
  • Loading branch information
toruichikawa committed Aug 8, 2022
1 parent 324765d commit ed5416f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion solhint.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ function execMainAction() {
}

if (printReports(reports, formatterFn)) {
if (program.maxWarnings && !reports[0].errorCount && warningsNumberExceeded) {
if (
program.maxWarnings &&
reports &&
reports.length > 0 &&
!reports[0].errorCount &&
warningsNumberExceeded
) {
console.log(
'Solhint found more warnings than the maximum specified (maximum: %s)',
program.maxWarnings
Expand Down

1 comment on commit ed5416f

@aspiers
Copy link

@aspiers aspiers commented on ed5416f Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Issue-URL is incorrect; please see protofire/solhint#351 (comment)

Please sign in to comment.