Skip to content

Fix stack level too deep error if target directory contains ** #9039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2020

Conversation

unasuke
Copy link
Contributor

@unasuke unasuke commented Nov 13, 2020

RuboCop exits with SystemStackError because "stack level too deep" if the target directory has the "**" directory.

foo
└── **
    └── bar.rb
Traceback (most recent call last):
        9197: from exe/rubocop:12:in `<main>'
        9196: from /Users/unasuke/.rbenv/versions/2.7.1/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
        9195: from exe/rubocop:13:in `block in <main>'
        9194: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli.rb:41:in `run'
        9193: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli.rb:72:in `execute_runners'
        9192: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli.rb:65:in `run_command'
        9191: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli/environment.rb:18:in `run'
        9190: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/cli/command.rb:11:in `run'
         ... 9185 levels...
           4: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/target_finder.rb:101:in `wanted_dir_patterns'
           3: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/target_finder.rb:101:in `flat_map'
           2: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/target_finder.rb:101:in `each'
           1: from /Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/target_finder.rb:101:in `block in wanted_dir_patterns'
/Users/unasuke/src/github.com/rubocop-hq/rubocop/lib/rubocop/target_finder.rb:97:in `wanted_dir_patterns': stack level too deep (SystemStackError)

If directory name end with /**/, escape dir name to /\**\ to inspect files under the **/ directory.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

Sorry, something went wrong.

@unasuke unasuke force-pushed the fix_stack_level_too_deep branch from 7e95a9d to 6b15ba3 Compare November 13, 2020 06:40
@unasuke
Copy link
Contributor Author

unasuke commented Nov 13, 2020

I need advice on what to do windows environment...

@unasuke unasuke force-pushed the fix_stack_level_too_deep branch from 6b15ba3 to 79c79b9 Compare November 13, 2020 10:24
@unasuke
Copy link
Contributor Author

unasuke commented Nov 13, 2020

Cannot create a directory with containing * charactor on Windows.
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions

So I disabled the test case in Windows...

@unasuke unasuke force-pushed the fix_stack_level_too_deep branch from 79c79b9 to 3fdc92b Compare November 13, 2020 11:24
@unasuke unasuke force-pushed the fix_stack_level_too_deep branch from 7b48648 to dd2aaa8 Compare November 13, 2020 12:37
Copy link
Member

@koic koic left a comment

Choose a reason for hiding this comment

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

👍

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 13, 2020

The changes look good, but your branch has to be rebased on top of the current master branch due to merge conflicts.

@marcandre
Copy link
Contributor

marcandre commented Nov 13, 2020

The changes look good, but your branch has to be rebased on top of the current master branch due to merge conflicts.

In the future, you can use the new way to handle changelog entries (rake changelog:..., see CONTRIBUTING) to avoid these :-)

Verified

This commit was signed with the committer’s verified signature.
alex-oleshkevich Alex Oleshkevich
Co-authored-by: Koichi ITO <koic.ito@gmail.com>

RuboCop exits with SystemStackError because "stack level too deep"
if the target directory has the "**" directory.

```
foo
└── **
    └── bar.rb
```

If directory name end with '/**/', escape dir name to `/\**\` to
inspect files under the '**/' directory.
@unasuke unasuke force-pushed the fix_stack_level_too_deep branch from dd2aaa8 to c1e4009 Compare November 14, 2020 06:29
@unasuke
Copy link
Contributor Author

unasuke commented Nov 14, 2020

Thank you. I rebased this.

@koic koic merged commit f59ee25 into rubocop:master Nov 14, 2020
@koic
Copy link
Member

koic commented Nov 14, 2020

Thanks!

@unasuke unasuke deleted the fix_stack_level_too_deep branch November 14, 2020 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants