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
Exclude pattern is not make effect when setting in ~/.rubocop.yml for emacs flycheck. #1368
Comments
Thanks. Would you like to submit a pull request? |
Sorry, I think this feature is added in newest version flycheck. Thanks very much. |
Hi, I think something still borken this feature. when I run follow command, rubocop check is skipped as expect. rubocop --display-cop-names --force-exclusion --format emacs --cache false --config ~/.rubocop.yml db/schema.rb But, when I open db/schema.rb with a opened emacs frame, rubocop check is still invoked. Warning (flycheck): Syntax checker ruby-rubocop reported too many errors (4929) and is disabled.
Warning (flycheck): Syntax checker ruby-rubocop reported too many errors (4929) and is disabled. |
I think, flycheck just not try to mark current buffer to show warning message, but, rubocop is run |
Hmm, what happens if you run:
That is, when you run |
@fmdkdd , sorry, the correct command is: rubocop --display-cop-names --force-exclusion --format emacs --cache false --config ~/.rubocop.yml db/schema.rb ~/.rubocop.yml config like this: AllCops:
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- 'db/schema.rb'
- 'db/migrate/*'
- 'bin/bundle'
- 'bin/rails'
- 'bin/rake'
- 'bin/setup'
- 'bin/spring'
- 'config/**/*'
- 'script/**/*'
- !ruby/regexp /old_and_unused\.rb$/
TargetRubyVersion:
2.3 But, if run with |
Okay, so Testing on my side,
The file is ignored, and rubocop reports no warnings. Same inside Emacs. Are you sure you are using the latest Flycheck version? When browsing |
yes, same as you, following command rubocop work fine. rubocop --display-cop-names --force-exclusion --format emacs --cache false `readlink -e db/schema.rb`
I think i use newest flycheck, d2b3c32
rubocop --display-cop-names --force-exclusion --format emacs --cache false --config /home/zw963/.rubocop.yml --stdin /home/zw963/IKCRM/ikcrm_cms/db/schema.rb < /home/zw963/IKCRM/ikcrm_cms/db/schema.rb |
That's it? No output, no warnings? |
@fmdkdd, sure it have. 4929 line warn, should I post that here? following is some example: /home/zw963/IKCRM/ikcrm_cms/db/schema.rb:2:1: C: Layout/EmptyLineAfterMagicComment: Add an empty line after magic comments.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:15:1: C: Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:16:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:17:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:18:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:19:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:20:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:21:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:22:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
..... |
Okay so Perhaps Emacs is picking up a different
Is it the same as |
I only one rubocop executable. -*- mode: compilation; default-directory: "~/IKCRM/ikcrm_cms/db/" -*-
Compilation started at Tue Dec 5 00:38:09
rubocop --display-cop-names --force-exclusion --format emacs --cache false --config /home/zw963/.rubocop.yml --stdin /home/zw963/IKCRM/ikcrm_cms/db/schema.rb < /home/zw963/IKCRM/ikcrm_cms/db/schema.rb Above is full report when I open $: cd /home/zw963/IKCRM/ikcrm_cms/db/
$: rubocop --display-cop-names --force-exclusion --format emacs --cache false --config /home/zw963/.rubocop.yml --stdin /home/zw963/IKCRM/ikcrm_cms/db/schema.rb < /home/zw963/IKCRM/ikcrm_cms/db/schema.rb
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:2:1: C: Layout/EmptyLineAfterMagicComment: Add an empty line after magic comments.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:15:1: C: Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:16:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:17:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:18:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:19:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:20:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:21:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:22:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:23:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
/home/zw963/IKCRM/ikcrm_cms/db/schema.rb:24:16: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
... |
Ahah! So it was an issue with the handling of paths in So You might want to signal this issue with the rubocop developers. Otherwise, I think we can fix this in Flycheck by specifying as cc @Simplify |
@fmdkdd According to the rubocop documentation Include/Exclude rules are relative to the location of config file, so no wonder that it does not work. In one of my old projects that still have @zw963 Copy your
|
@Simplify Indeed, thank you for correcting me. Specifying project-specific exclude/include paths into a global config file seems like a bad idea (although, I understand the file |
Yes, that one is almost always present. In some cases where old non-rails app is ported to rails or if you use multiple databases you may not need/use it, at least not as |
@Simplify , Yes, I did like that, but following command is worked. ╭─ 10:08 zw963 ⮀ ~/IKCRM/ikcrm_cms ⮀
╰─ $ rubocop --display-cop-names --force-exclusion --format emacs --cache false db/schema.rb It is not worked only when working-directory in Thanks, I have resolve this problem now follow your's advise, but i am not copy ~/.rubocop into my Exclude:
- 'schema.rb'
- 'db/schema.rb'
... |
Ok, I see. Not expected behavior after reading rubocop docs... The problem is that flycheck sets default directory where your configuration file is located, so that becomes |
Ok, pull request tested with several scenarios:
|
GH-1368 - Run rubocop from ruby project directory
Please see follow links, thanks
rubocop/rubocop#5139 (comment)
The text was updated successfully, but these errors were encountered: