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

Refactoring + new cops #3

Merged
merged 12 commits into from
May 18, 2014
Merged

Refactoring + new cops #3

merged 12 commits into from
May 18, 2014

Conversation

geniou
Copy link
Collaborator

@geniou geniou commented May 14, 2014

No description provided.

@geniou geniou changed the title Split UnitSpecNaming into separat cops Refactoring + new cop May 14, 2014
This was referenced May 14, 2014
@geniou
Copy link
Collaborator Author

geniou commented May 14, 2014

@yujinakayama since you are very familiar with both rubocop and rspec it would be very nice of you if you could take a look into these changes, and let me know what you think.

@geniou geniou changed the title Refactoring + new cop Refactoring + new cops May 14, 2014
@geniou
Copy link
Collaborator Author

geniou commented May 15, 2014

@bbatsov maybe you could take a look at these changes - especially the new cops. Its the extension of the existing gem to add new rspec rubocop cops as discussed in 1087.

At the moment I prefer prefixing the cops with RSpec so that there will be no conflict with the rubocop cop - or do you have a better idea?

@geniou
Copy link
Collaborator Author

geniou commented May 15, 2014

@nevir sorry for so many changes - I just came from one idea for a cop to the other. Feel free to let me know what you think and what needs to be changed from your point of view.

@bbatsov
Copy link
Contributor

bbatsov commented May 15, 2014

@geniou Namespacing is certainly problematic in the moment. I think we need to add some proper support in RuboCop for that, since I'd hate for people to have to prefix class names like in PHP4 :-). @jonas054 any ideas regarding this? Guess we can have cop sections in the config or something similar...

@geniou
Copy link
Collaborator Author

geniou commented May 15, 2014

@bbatsov I totally agree with you and looking forward to have a better solution.

def on_block(node)
method, _args, _body = *node
_receiver, method_name, _object = *method
@in_describe = true if method_name == :describe

Choose a reason for hiding this comment

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

There are some aliases and shared examples/contexts.

https://github.com/yujinakayama/transpec/blob/master/lib/transpec/rspec_dsl.rb

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Thanks

@nevir
Copy link
Collaborator

nevir commented May 15, 2014

Going through this now, but this looks fantastic so far! Thanks for splitting the file cops apart too :)

module Rubocop
module Cop
# Helper methods for top level describe cops
module TopLevelDescribe
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a fan of this being under the Cop namespace - that should be reserved for cop classes only, IMO. Rubocop::RSpec::TopLevelDescribe maybe?

...then again, there are examples of modules under Cop in the main repo - so, either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I followed the the structure in the main repo - but this does not mean we have to do it the same way.

@nevir
Copy link
Collaborator

nevir commented May 15, 2014

Just nitpicks from me. See geniou#1 (feel free to merge that and this PR once you're happy w/ it)

@jonas054
Copy link

@bbatsov I have an idea regarding name spaces. Basically we include one level of name space in the cop names, so Style/LineLength instead of LineLength in config files, rubocop:disable comments, --only options, etc.

This is relatively easy. I have a solution on branch. The hard part is to make the transition painless for the users. I don't know how to do that.

@geniou
Copy link
Collaborator Author

geniou commented May 15, 2014

@jonas054 Would it be an idea, for the transition, to keep the current behavior for all config values without the "namespace" and just print a warning, that this will be deprecated? In this case the rubocop-rspec gem can use the prefix, and the users have time to migrate.

@bbatsov
Copy link
Contributor

bbatsov commented May 15, 2014

We're pre 1.0. They'll forgive us. :-)

@bbatsov
Copy link
Contributor

bbatsov commented May 15, 2014

(but yes - a deprecation message would be a better option)

@jonas054
Copy link

@geniou I'll try to implement something along those lines.

@geniou
Copy link
Collaborator Author

geniou commented May 18, 2014

@nevir what do you think about the current pull request? Are there any open issues from your point of view? I'm not sure if we should release a new version, but maybe its worth putting it into the master to get some feedback?

The namespace topic is work in progress, but I'm not sure if its worth waiting, since its not clear when a new rubocop version with this feature will be released. I thin I could live with the Prefixes for now. Maybe we have to put a note into the README, that this will change in the future.

expect(cop.offenses.size).to eq(1)
expect(cop.offenses.map(&:line).sort).to eq([4])
expect(cop.messages)
.to eq(['Use `described_class` for tested class / module'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, this is an interesting case, I think the error message should contain the expected class/module to help disambiguate for nested describes like this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. I'll change it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's done.

@nevir
Copy link
Collaborator

nevir commented May 18, 2014

This PR looks good to me (just the one comment above)

Re: release process, I think it's worth getting this out there. There don't appear to be too many users, and - hopefully - most are forgiving of breaking interface changes.

It does make our versioning a bit odd, though; since - I think - it's more important to keep versions roughly in sync w/ rubocop, rather than doing the whole semver thing

@geniou
Copy link
Collaborator Author

geniou commented May 18, 2014

I'm not so sure about the version numbers. For example there is a rubocop version 0.30, but rubocop-rspec is 0.21, because there was no new feature in rubocop-rspec since rubcop 0.21. In this case you don't know if rubocop-rspec its working with the rubocop version or not, or are you planing to release a new version every time a new rubocop version is released? Another example: there is rubocop 0.30.1, and rubocop-rspec with the same version, then there is a new feature in rubocop-rspec, is this then 0.30.1.1?

@nevir
Copy link
Collaborator

nevir commented May 18, 2014

Yeah, that sucks, and is a maintenance headache :-/ (which we see now, even)

How about we just do the semver approach and fully decouple? 1.0(pre) now,
and 1.0 once the namespace code hits?

(0.x being special cased as sometimes breaking changes is never handled
very well)
On Sun, May 18, 2014 at 10:38 AM, Nils notifications@github.com wrote:

I'm not so sure about the version numbers. For example there is a rubocop
version 0.30, but rubocop-rspec is 0.21, because there was no new feature
in rubocop-rspec since rubcop 0.21. In this case you don't know if
rubocop-rspec its working with the rubocop version or not, or are you
planing to release a new version every time a new rubocop version is
released? Another example: there is rubocop 0.30.1, and rubocop-rspec
with the same version, then there is a new feature in rubocop-rspec, is
this then 0.30.1.1?


Reply to this email directly or view it on GitHubhttps://github.com//pull/3#issuecomment-43446052
.

@bbatsov
Copy link
Contributor

bbatsov commented May 18, 2014

@geniou @nevir I definitely think you should keep versioning independent from RuboCop's. Doing a 1.0-pre is one option. Another would be to yank the existing gem version and start with 0.1.x or something like that.

@nevir nevir closed this May 18, 2014
@geniou
Copy link
Collaborator Author

geniou commented May 18, 2014

@nevir you cosed it without mering. Was this on purpose?

@geniou
Copy link
Collaborator Author

geniou commented May 18, 2014

I like the idea of 1.0-pre - I don't know how the naming conventions are, but I think it should be something < 1.0 - but close to it, because its nearly "stable"..

@nevir
Copy link
Collaborator

nevir commented May 18, 2014

Nope, mistake!

@nevir nevir reopened this May 18, 2014
@nevir
Copy link
Collaborator

nevir commented May 18, 2014

Yeah, let's go w/ 1.0pre

nevir added a commit that referenced this pull request May 18, 2014
@nevir nevir merged commit 0f367d2 into rubocop:master May 18, 2014
@nevir
Copy link
Collaborator

nevir commented May 18, 2014

Actually, might as well do the rc# approach, juuuust in case.

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

Successfully merging this pull request may close these issues.

None yet

5 participants