-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit f7e4d1d
Fix handling of missing lib examples folder
The `rulefunction.MissingExamples` function was previously relying on the github.com/arduino/go-paths-helper IsDirCheck() method for two things
- Does examples path exist?
- Is examples path a folder?
The code made the unreasonable assumption that IsDirCheck() would return `false, nil` if the path did not exist, and an
error only if some unexpected failure occurred. That is not how IsDirCheck() is intended to work, as is clearly described
in its documentation. A bug fix to align the method's behavior with that stated in its docs caused it to correctly return
an error when the path did not exist, which caused an inappropriate panic from the `rulefunction.MissingExamples`
function when checking an examples folder that did not exist.
There is a dedicated method for checking path existence. By calling this method before `IsDirCheck()`, the code can
achieve its intended behavior of handling missing examples folders gracefully, only panicing in the event of some
unexpected failure that can't be handled without risking spurious linting results.1 parent 0d75f45 commit f7e4d1d
File tree
4 files changed
+28
-8
lines changed- internal/rule/rulefunction
- testdata/libraries/ExamplesFile
- src
4 files changed
+28
-8
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1456 | 1456 |
| |
1457 | 1457 |
| |
1458 | 1458 |
| |
1459 | - | ||
1459 | + | ||
1460 | + | ||
1460 | 1461 |
| |
1461 | 1462 |
| |
1462 | 1463 |
| |
1463 | - | ||
1464 | - | ||
1465 | - | ||
1466 | - | ||
1467 | - | ||
1468 | - | ||
1469 | - | ||
1464 | + | ||
1465 | + | ||
1466 | + | ||
1467 | + | ||
1468 | + | ||
1469 | + | ||
1470 | + | ||
1471 | + | ||
1472 | + | ||
1473 | + | ||
1474 | + | ||
1475 | + | ||
1476 | + | ||
1477 | + | ||
1478 | + | ||
1479 | + | ||
1480 | + | ||
1470 | 1481 |
| |
1471 | 1482 |
| |
1472 | 1483 |
| |
|
Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | + | ||
2 | + | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
9 | + |
Whitespace-only changes.
0 commit comments