Skip to content
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

Ignore/exclude files #11

Open
cveneziani opened this issue Jul 25, 2014 · 20 comments
Open

Ignore/exclude files #11

cveneziani opened this issue Jul 25, 2014 · 20 comments
Labels

Comments

@cveneziani
Copy link

Is there a way to tell to rubycritic to exclude some file patterns?

@guilhermesimoes
Copy link
Contributor

As of now, no. But I was thinking of implementing just that as a solution for issue #7.

The reason for delaying that feature is that I'm torn between having it as a cli option (a --ignore-files flag like the Churn gem) or having it as a dotfile (a .rubycritic.yml file like the Rubocop gem).

I think the file approach is more powerful and flexible but honestly I'm tired of each gem having its own dotfile.

I can totally see why this would be good to have but I'm curious, what's your use case?

@cveneziani
Copy link
Author

I agree, the file approach is a better solution. And a file can be committed within the project repository.

My first use case is that I want to focus on some parts of the project. So I want to disable other parts and specially tests. That way I'll just have an overview of the classes that interest me.

@milgner
Copy link

milgner commented Jul 25, 2014

Same here. Currently RubyCritic complains about generated files like schema.rb and also about repetitions in my specs, which I don't really care about that much.

@guilhermesimoes
Copy link
Contributor

Actually, for Rails projects running rubycritic app lib should be enough.

But don't worry guys, this on my radar now.

@milgner
Copy link

milgner commented Jul 26, 2014

Fantastic! And thank you for a great gem! 👍

@cveneziani
Copy link
Author

Great! 😄

@midwire
Copy link

midwire commented Jul 28, 2014

I am looking forward to this feature, as I don't want to run against 'vendor'. Also, thank you @guilhermesimoes for a useful gem!

@born4new
Copy link

What's the status for this feature @guilhermesimoes ? Did you decide which you wanted to go with it? (yml config or CLI)

@deepredsky
Copy link

+1 to adding the command line flag to ignore a pattern or path

@nunosilva800 nunosilva800 self-assigned this Dec 18, 2015
@troessner
Copy link
Contributor

Due to RC's nature this is not really trivial since we aggregate multiple tools and those tools have a different understanding of how you can exclude and include paths. And some might not even offer an "exclude" functionality.
Nevertheless I can see that this feature would be highly valuable.
I'll take the first step for getting this feature going when I'll address #77

@solars
Copy link

solars commented Mar 7, 2016

is there anything that let's me exclude certain method calls?
e.g. I get a lot of complaints about calls to Rails.logger etc - which should be ignored

@troessner
Copy link
Contributor

No, not at the moment I'm afraid.
This kind of functionality would be great though ;)
What you can do right now is use special configurations for each analyzer that will be respected by RubyCritic as you can see here
With Reek you can also generate such a configuration via "reek --todo your_path" which is unfortunately not possible for flog and flay.

@solars
Copy link

solars commented Mar 8, 2016

@troessner thanks a lot for the reply! I'll have a look at the config options. --todo doesn't seem to be included in my version of reek/rubycritic and currently parser blocks an update - I'll try to resolve it adapt the config. Thanks a lot!

@troessner
Copy link
Contributor

The latest version of RubyCritic bundles Reek 3.11 which includes the --todo flag, so you just need to update RubyCritic and you're good to go ;)

@solars
Copy link

solars commented Mar 8, 2016

@troessner thanks a lot! And keep up the great work :)

@LyzioOh
Copy link

LyzioOh commented Apr 9, 2018

Hi @cveneziani
I don't know if you still have a problem with more recent versions of RubyCritic (I work with version 3.3.0 right now). If so, here is a possible solution:

Define a rake task : you can specify paths as a FileList. Filelist are essentially arrays with helper method. So you can easily white list or black list whatever path you want.
Example :

RubyCritic::RakeTask.new do |task|

	# Name of RubyCritic task.
	task.name    = 'quality_audit'

	excluded_files = [
		"app/jobs/file1.rb",
		"app/jobs/file2.rb"
	]

	task.paths = FileList['app/**/*.rb','lib/**/*.rb' ] - excluded_files

	# You can pass all the options here in that are shown by "rubycritic -h" except for
	# "-p / --path" since that is set separately. Defaults to ''.
	task.options = ''

	# Defaults to false
	task.verbose = true
end

I propose we close this issue, except if you prefer we write the solution in the Readme ?
This solution have been cooked with @Atheane

@cveneziani
Copy link
Author

Well, nowadays, I just run it on app and lib folders.

@nunosilva800
Copy link
Collaborator

I still think there's a the need for this feature since rubycritic should not rely on rake / rails to work flawlessly. The tools rubycritic uses already support similar flags...

@deepredsky
Copy link

i have also gotten used to running it just in app and lib folders. I think it would be nice to have flags which then maps to the corresponding flag to the underlying tools.

@philCryoport
Copy link

Note my comment here where the .reek.yml -- which includes an exclude-this-file statement -- is being ignored by rubycritic: #270 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests