Rubocop: Style/MixinGrouping registers offense for rspec's include-expectation

Created on 26 Mar 2017  路  4Comments  路  Source: rubocop-hq/rubocop

The new Style/MixinGrouping incorrectly registers an offense when rspec's include-expectation is used with multiple elements.


Expected behavior

Rubocop does not register an offense.

Actual behavior

Rubocop registers an offense.

Steps to reproduce the problem

Create the following file, e.g. as mixin_grouping_spec.rb:

require 'rspec'

describe 'rubocop Style/MixinGrouping' do
  it 'should not register an offense for rspec-include' do
    expect([1, 2, 3]).to include(1, 2)
  end
end

Call rubocop mixin_grouping_spec.rb:

$ rubocop mixin_grouping_spec.rb
Inspecting 1 file
C

Offenses:

mixin_grouping_spec.rb:5:26: C: Put include mixins in separate statements.
    expect([1, 2, 3]).to include(1, 2)
                         ^^^^^^^^^^^^^

1 file inspected, 1 offense detected

RuboCop version

$ rubocop -V
0.48.0 (using Parser 2.4.0.0, running on ruby 2.4.0 x86_64-darwin16)
bug

Most helpful comment

Another false positive:

  config.include Mongoid::Matchers, type: :model

All 4 comments

Another false positive:

  config.include Mongoid::Matchers, type: :model

Hi, I think the something is happening for extend

lib/client_side_validations/active_record.rb:8:1: C: Style/MixinGrouping: Put extend mixins in separate statements.
ClientSideValidations::Extender.extend 'ActiveRecord', %w(Uniqueness)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@tagliala: It is fixed for all methods on master, but it is has not gone into any release yet. 馃檪

@Drenmi thanks for answering.

I'm pretty confident I'm using master branch

Using rubocop 0.48.0 from git://github.com/bbatsov/rubocop.git (at master@e50e7ad)

$ bundle exec rubocop -d
For ~/dev/client_side_validations: configuration from ~/dev/client_side_validations/.rubocop.yml
Default configuration from ~/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-e50e7ad6356b/config/default.yml
Inheriting configuration from ~/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-e50e7ad6356b/config/enabled.yml
Inheriting configuration from ~/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-e50e7ad6356b/config/disabled.yml

[...]

Offenses:

lib/client_side_validations/active_record.rb:8:1: W: Lint/UnneededDisable: Unnecessary disabling of Style/MixinGrouping.
# rubocop:disable Style/MixinGrouping
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

edit: Please ignore me, it's fixed 馃憤 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bquorning picture bquorning  路  3Comments

lepieru picture lepieru  路  3Comments

Aqualon picture Aqualon  路  3Comments

Ana06 picture Ana06  路  3Comments

tedPen picture tedPen  路  3Comments