Repository navigation
Conversation
When source code is piped in and --stdin-filename is given, check the filename against the configured exclude_paths (honouring --force-exclusion) in the same way as for files passed on the command line. Previously the exclusion configuration was ignored for piped input. Fixes troessner#1429
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by winshyon · project thread
Description
When source is piped in with
--stdin-filename(as editor integrations such as ALE do), Reek ignoredexclude_paths, even with--force-exclusion.Application#source_from_pipebuilt the source directly and never went through the exclusion check thatSourceLocatorapplies to files given on the command line.Following the approach suggested in the issue, this extracts that check into a public
SourceLocator#excluded_file?(path)(formerly the privateignore_file?, logic unchanged) and uses it insource_from_pipe: if the stdin filename is excluded, no sources are reported. The semantics match those for a file passed on the command line:exclude_pathsis skipped;--force-exclusion.As with command-line files,
exclude_pathsentries are globbed against the filesystem, so the exclusion applies when the stdin filename refers to an existing file (the editor-integration case).Tests:
features/command_line_interface/stdin.feature: two new scenarios (file excluded directly; file in an excluded directory, with and without--force-exclusion). Both fail onmasterand pass with the change.spec/reek/source/source_locator_spec.rb: specs for#excluded_file?, including a path that does not exist on disk.No CHANGELOG entry since the changelog appears to be written at release time with PR numbers; happy to add one if you prefer.
Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to help projects with open issues. The change was prepared with Claude Code and verified as listed below. If it doesn't fit, isn't up to your bar, or you'd simply rather not take it — please feel free to close it, no hard feelings at all 🙂
Related issue
Fixes #1429
Checklist
bundle exec rake ci(Ruby 3.3.6): spec 1120 examples / 0 failures, features 127 scenarios passed, rubocop no offenses, quality 134 examples / 0 failuresCHANGELOG.mdis updated — left for release time (see above)🤖 Generated with Claude Code