-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
More cops(rules) #60
Comments
I want to do "Use only ascii symbols in identifiers and comments". The list is a great idea, by the way. |
It's yours then. |
I've written a cop for "Prefer %w to the literal array syntax when you need an array of strings." and now it detects that style rule on various code files from the project. Should I correct them to match this new rule too? |
This can be crossed off the list:
I'm going to work on "When using reduce with short blocks, name the arguments |a, e|" |
I guess I crossed it off just as you were typing this comment. :-) Great, looking forward to it. |
I'll do "Use %r only for regular expressions matching more than one '/' character". |
I'll look into "Avoid more than three levels of block nesting." |
Great, @emou. I'd suggest to actually use a customizable param for that particular check(instead of hardcoding 3), since a lot of people might disagree with the number prescribed by default. |
I'll do 'Favor %r if you have more than 1 '/' characters in your regexp'. |
#60 : Use the attr family of functions to define trivial accessors or mutators.
What do you think about an indentation Cop? ps. Could you use a task list? I think that's more clear. |
Yep, that would be a great addition. The ruby interpreter detect misaligned ps. Will do! |
Done. |
@jonas054 @yujinakayama I think we should try to wrap this issue before 1.0. I'd suggest we continue the old practice of doing a cop at time until we're out of cops. I'll start with the unneeded |
I'll do Avoid self where not required. |
I'll do the implicit begin next. |
I'll do "Comment annotation should be all upper case and at the beginning of the comment". |
I'll do "Prefer modules to classes with only class methods" next. |
Hey guys,
Here's a list of the more important rules that we should implement in the future.
Kernel#loop
with break rather thanbegin/end/until
orbegin/end/while
for post-loop tests.return
where not required for flow of control.self
where not required. (It is only required when calling a self write accessor.)(\)
where not required. In practice, avoid using line continuations at all~~.reduce
with short blocks, name the arguments|a, e| (accumulator, element)
.def +(other)
)# TODO improve performance
).module_function
over extend self when you want to turn a module's instance methods into class methods.attr
family of functions to define trivial accessors or mutators.def self.method
to define singleton methods. This makes the code easier to refactor since the class name is not repeated.fail
method. Useraise
only when catching an exception and re-raising it (because here you're not failing, but explicitly and purposefully raising an exception).return
from an ensure block. If you explicitly return from a method inside an ensure block, the return will take precedence over any exception being raised, and the method will return as if no exception had been raised at all. In effect, the exception will be silently thrown away.begin
blocks where possible.Exception
class. This will trap signals and calls to exit, requiring you to kill -9 the process.%w
to the literal array syntax when you need an array of strings.%r
only for regular expressions matching more than one '/' character.alias_method
will do.if
,unless
, etc.private
andprotected
.private
andprotected
as much as method definitions.Details and examples about most rules are available in the guide itself.
I'm opening this ticket mostly so we can discuss who would like to implement what, so that we don't end up with two people working on the same cop. When somebody(me included) starts to work on a cop he'd write a comment here; when he's done - we'd scratch the rule from the list.
So, who'd like to pick a task first? :-)
@jonas054, @vsakarov, @emou
The text was updated successfully, but these errors were encountered: