rubocop / guard-rubocop

Guard plugin for RuboCop
MIT License
262 stars 55 forks source link

Can not handle guard default ignore? #8

Closed tune closed 9 years ago

tune commented 10 years ago

In guard document, it declare that guard default setting ignore following folders.

ignore ... This comes in handy when you have large amounts of non-source data in you project. By default .rbx, .bundle, .DS_Store, .git, .hg ,.svn, bundle, log, tmp, vendor/bundle are ignored.

But it seems guard-rubocop cannot ignore part of them, at least vendor/bundle.

tune@CentOS  git clone https://github.com/yujinakayama/guard-rubocop.git
Cloning into 'guard-rubocop'...
remote: Counting objects: 496, done.
remote: Compressing objects: 100% (240/240), done.
remote: Total 496 (delta 219), reused 481 (delta 205)
Receiving objects: 100% (496/496), 60.77 KiB, done.
Resolving deltas: 100% (219/219), done.

tune@CentOS  cd guard-rubocop 
tune@CentOS  bundle install --path=vendor/bundle
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake (10.1.0) 
Installing ast (1.1.0) 
...
Installing ruby_gntp (0.3.4) 
Installing simplecov-rcov (0.2.3) 
Your bundle is complete!
It was installed into ./vendor/bundle

tune@CentOS  bundle exec guard
17:06:02 - WARN - Guard::RSpec DEPRECATION WARNING: The :keep_failed option is deprecated. Please set new :failed_mode option value to :keep instead. https://github.com/guard/guard-rspec#list-of-available-options
17:06:02 - INFO - Guard is using GNTP to send notifications.
17:06:02 - INFO - Guard is using TerminalTitle to send notifications.
17:06:02 - INFO - Guard::RSpec is running
17:06:02 - INFO - Running all specs
................................................................................

Finished in 0.09299 seconds
80 examples, 0 failures
Coverage report generated for RSpec to /home/tune/guard-rubocop/spec/coverage. 120 / 120 LOC (100.0%) covered.
17:06:02 - ERROR - Error sending notification with gntp: Connection refused - connect(2)

17:06:02 - INFO - Inspecting Ruby code style of all files
Inspecting 2029 files
....CCCCCCCCCCCCCCCCCWCCCWCCC...
yujinakayama commented 10 years ago

The Guard's default ignore patterns are applied to modified file paths detected by Guard.

With your log, RuboCop was running against all files rather than modified files by all_on_start feature. In this case, guard-rubocop runs rubocop with no arguments internally, and rubocop will find all ruby files under the current working directory so the Guard's ignore patterns won't be applied.

Though I'll consider whether guard-rubocop should handle this case or not, I'd suggest adding some Excludes patterns to your .rubocop.yml like this for now.

tune commented 10 years ago

Thank you for your quick response. Above solution meets my requirements.

nilbus commented 9 years ago

I agree that excludes in .rubocop.yml is the best place to do this, because it covers both guard and running rubocop manually.