[QA] Ruby Coding Conventions and RuboCop (was: Rubocop style checker)

Dan Duvall dduvall at wikimedia.org
Thu Nov 20 00:38:18 UTC 2014


I've added some more exceptions to our guide if anyone has an opinion on
them.[1] (Željko beat me to the `ClassLength` exclusion.)

In general, I think these metric rules are overzealous (aside from line
length). Can you really quantify the quality of a class/method by measuring
the number of lines it has? Maybe by its max number of operations
(`O(...)`), but that's still impossible enough to leave up to the good
faith of the developer.

IMO, we shouldn't make rubocop voting until we iron out all the
overzealousness of RuboCop. I've submitted a pull request to help us create
base configuration that's more congruent with the actual style guide.[2]
Ironically enough, it has failed the Travis CI check because of an
overzealous `GuardClause` check. (Seriously, who can't read an `if`
statement ... :)

[1]
https://www.mediawiki.org/w/index.php?title=Manual%3ACoding_conventions%2FRuby&diff=1272349&oldid=1247792
[2] https://github.com/bbatsov/rubocop/pull/1454

On Thu, Nov 13, 2014 at 10:40 AM, Dan Duvall <dduvall at wikimedia.org> wrote:

> Before we make rubocop voting, we need to ensure that all repositories
> have a .rubocop.yml that includes our exceptions to the rules.[1] I'd also
> like to make some additions and effectively ignore all violations that
> aren't apart of the bbatsov style guide (almost everything in `Metrics/*`
> aside from `LineLength`).
>
> [1] https://www.mediawiki.org/wiki/Manual:Coding_conventions/Ruby
>
> On Thu, Nov 13, 2014 at 7:22 AM, Antoine Musso <hashar+wmf at free.fr> wrote:
>
>> Le 13/11/2014 15:54, Željko Filipin a écrit :
>> > I think it is the time to make rubocop jobs voting. I did not notice any
>> > problems. Does anybody disagree?
>>
>> Reviewing the changes to oojs/ui there were some oddities:
>>
>> Style/WordArray:
>> https://gerrit.wikimedia.org/r/#/c/172742/1/bin/testsuitegenerator.rb
>>
>> In a hash that enforce the use of %w(foo bar) for keys, but apparently
>> not for values!  That is rather inconsistent.
>>
>> There is no complains for:
>>
>>   foo = {
>>     'key' => ['Foo', 'Bar']
>>   }
>>
>> But there is for:
>>
>>   foo = {
>>     ['key1', 'key2'] => 'value'
>>   }
>>
>>
>> Style/CommentIndentation:
>>
>> Request indentation to use spaces even when the file is tab indented.
>> The autocorrect ends up mixing tab and spaces. Examples:
>>
>>  https://gerrit.wikimedia.org/r/#/c/172738/1/bin/docparser.rb
>>  https://gerrit.wikimedia.org/r/#/c/172719/3/bin/doccomparer.rb
>>
>>
>>
>>
>> --
>> Antoine "hashar" Musso
>>
>>
>> _______________________________________________
>> QA mailing list
>> QA at lists.wikimedia.org
>> https://lists.wikimedia.org/mailman/listinfo/qa
>>
>
>
>
> --
> Dan Duvall
> Automation Engineer
> Wikimedia Foundation <http://wikimediafoundation.org>
>



-- 
Dan Duvall
Automation Engineer
Wikimedia Foundation <http://wikimediafoundation.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.wikimedia.org/pipermail/qa/attachments/20141119/9e71fcc0/attachment.html>


More information about the QA mailing list