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

Rubocop: Disable ImplicitSubject #68

Merged
merged 1 commit into from
Dec 17, 2021
Merged

Conversation

bastelfreak
Copy link
Member

Enabling this cop causes a lot of noise in our project, because ruboop
would want us to reformat most of the tests.

Explanation of the cop:
https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject

Enabling this cop causes a lot of noise in our project, because ruboop
would want us to reformat most of the tests.

Explanation of the cop:
https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject
@bastelfreak bastelfreak self-assigned this Dec 16, 2021
@codecov
Copy link

codecov bot commented Dec 16, 2021

Codecov Report

Merging #68 (345fc0a) into master (89dd6c4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #68   +/-   ##
=======================================
  Coverage   27.86%   27.86%           
=======================================
  Files           2        2           
  Lines          61       61           
=======================================
  Hits           17       17           
  Misses         44       44           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89dd6c4...345fc0a. Read the comment docs.

@bastelfreak
Copy link
Member Author

I have a high amount of open modulesync PRs and this change has a huge effect on them. I will hold of with the modulsync PRs until we decided to disable/enable this Cop.

@bastelfreak
Copy link
Member Author

I think we could set EnforcedStyle: single_statement_only as well.

let's take a look at:

it { is_expected.to contain_file('/etc/all-knowing-dns.conf').with_content(%r{listen #{params_set[:listen][0]}}) }

if the cop is disabled or set to one of the enforced styles, it stays the same. I think we use this style in 90% of the tests.

let's take a look at this:

  it {
    is_expected.to contain_service('all-knowing-dns').with(
      ensure: 'running',
      enable: true,
      hasstatus: true,
      hasrestart: true,
      require: 'Package[all-knowing-dns]'
    )
  }

with the style set to disabled or to single_statement_only, it stays the same. If we set it to single_line_only it will be converted to:

  it {
    expect(subject).to contain_service('all-knowing-dns').with(
      ensure: 'running',
      enable: true,
      hasstatus: true,
      hasrestart: true,
      require: 'Package[all-knowing-dns]'
    )
  }

That's why I think EnforcedStyle: single_statement_only would be fine as well.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

single_statement_only would probably still trigger on:

it do
  is_expected.to contain_bla()
  is_expected.to contain_other_bla()
end

I'm fine with disabling this since I'm not sure it really adds much for us. We're not Ruby developers and only use rspec to test Puppet.

@bastelfreak bastelfreak merged commit 96efaa2 into voxpupuli:master Dec 17, 2021
@bastelfreak bastelfreak deleted the style branch December 17, 2021 08:08
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.

2 participants