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

exclude reader methods that ends with a question mark #326

Closed
wants to merge 2 commits into from

Conversation

pmenglund
Copy link
Contributor

As attr_reader can't deal with variables ending with '?'

Another possible work around it is to use:
class Foo
attr_reader :empty
alias_method :empty?, :empty
end

As attr_reader can't deal with variables ending with '?'

Another possible  work around it is to use:
class Foo
  attr_reader :empty
  alias_method :empty?, :empty
end
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 122e589 on pmenglund:master into 650e402 on bbatsov:master.

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 3, 2013

Personally, I use alias_method in situations like this. That said I'm ok with this addition if it's controlled by a configuration variable. Name it AllowPredicates and set it to false by default.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 10aa812 on pmenglund:master into 650e402 on bbatsov:master.

private

def predicate?(method_name)
!(method_name[-1] == '?' || TrivialAccessors.allow_predicates)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something is a predicate method even if allow_predicates is false. For clarity's sake I think the || should not be part of that method.

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 7, 2013

I've done a few changes to that cop to address another issue. Please, rebase your changes on top of the current master.

@bbatsov bbatsov closed this in bdeebef Jul 9, 2013
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 9, 2013

I did the necessary changes myself.

@pmenglund
Copy link
Contributor Author

Great! I wouldn't have time to get back to this until the weekend...

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 9, 2013

You're welcome :-)

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

Successfully merging this pull request may close these issues.

3 participants