adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.79k stars 265 forks source link

cli: Cleanly skip broken symlinks that are ignored #654

Closed adrienverge closed 5 months ago

adrienverge commented 5 months ago

Before this commit, yamllint would output "[Errno 2] No such file or directory" when running on a directory which contained a broken symbolic link, even if the file is set to be ignored in yamllint configuration.

This commit fixes that, and adds corresponding tests.

As a side effect this changes yamllint.linter.run(stream, config), so tools that would use this API need to filter ignored files beforehand.

Fixes https://github.com/adrienverge/yamllint/issues/399

coveralls commented 5 months ago

Coverage Status

coverage: 99.824% (+0.001%) from 99.823% when pulling 8673efdba632a4ceb1403aa5fb5088eb709e758e on fix/ignore-broken-symlinks into f66855bf2d73357047118de68ce8224297c3ef5a on master.

adrienverge commented 5 months ago

Hello @andrewimeson, this change is related to https://github.com/adrienverge/yamllint/pull/524#discussion_r1061698032 and https://github.com/adrienverge/yamllint/pull/524#discussion_r1052261762. After reading the code, I think it's a good change, i.e. yamllint.linter.run(stream, config) should lint the YAML input it is given (independently of the filename), and the filter for ignored files should be done upstream. But if you think differently don't hesitate to say so :)