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

Add additional namespace to cops #232

Closed
backus opened this issue Oct 27, 2016 · 3 comments
Closed

Add additional namespace to cops #232

backus opened this issue Oct 27, 2016 · 3 comments

Comments

@backus
Copy link
Collaborator

backus commented Oct 27, 2016

After @JonRowe's feedback in #228 I'd like to start by at least adding an additional namespace for our cops. This change can be pretty simple:

diff --git i/lib/rubocop/cop/rspec/leading_subject.rb w/lib/rubocop/cop/rspec/leading_subject.rb
index c9b813a..d87e927 100644
--- i/lib/rubocop/cop/rspec/leading_subject.rb
+++ w/lib/rubocop/cop/rspec/leading_subject.rb
@@ -31,6 +31,10 @@ module RuboCop

         MSG = 'Declare `subject` above any other `let` declarations'.freeze

+        def self.cop_name
+          "RSpec/Style/LeadingSubject"
+        end
+
         def_node_matcher :subject?, '(block $(send nil :subject ...) args ...)'

         def on_block(node)

we could also add another namespace (might be too much nesting idk) and define a cop_name method which just defines name.split('::').last(3).join('/'). This might be a mess though since, as I've noted before, we can't just do class RuboCop::RSpec::Cop < RuboCop::Cop::Cop because RuboCop::Cop::Cop mutates some class level state on the inherited hook which I don't know how to avoid.

The point of this name spacing would be to start creating an end-user visible differentiation between stylistic and opinionated cops which should be treated differently from linting and best practice cops

@backus
Copy link
Collaborator Author

backus commented Oct 27, 2016

@bquorning interested what you think here. I know there are a few parts of the rubocop codebase which assume a cop name has a single namespace but, as far as I can tell, deviating from this contract doesn't break anything

@bquorning
Copy link
Collaborator

I’m not completely sold on the idea. This feels like something that belongs inside RuboCop proper.

They have the Rails cops (which really should be a separate project) – they ought to be namespaced as well, I guess.

@pirj
Copy link
Member

pirj commented Nov 6, 2020

FactoryBot and Rails namespaces were added in #1019
Speaking of separating cops by their importance or purpose seems to be a task nobody is willing to take.

@pirj pirj closed this as completed Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants