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

Fix Rubocop Rails/NegateInclude issues #12337

Merged

Conversation

cyrillefr
Copy link
Contributor

@cyrillefr cyrillefr commented Apr 4, 2024

What? Why?

Fixes one of many rubocop issues

  • cop class: RuboCop::Cop::Rails::NegateInclude
  • idea: replacing !array.include?(2) with array.exclude?(2)
  • .rubocop_todo.yml updated

What should we test?

Nothing: the rubocop should raise no offenses when checking linters at Integration.

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

 - cop class: RuboCop::Cop::Rails::NegateInclude
 -  replaced !array.include?(2) by array.exclude?(2)
@cyrillefr
Copy link
Contributor Author

Hello @dacook or @sigmundpetersen ,

could someone relaunch checks, there is a strange error that do not show up locally.
Thanks :)

@sigmundpetersen
Copy link
Contributor

Hey @cyrillefr I have run the spec 10 times, consistently failing.
It really looks like the flaky spec #10027 that somehow got consistent as part of this PR 🤷
Maybe @filipefurtad0 or @openfoodfoundation/core-devs have some insight

@cyrillefr
Copy link
Contributor Author

Really weird this kind of behaviour that arise on my PR (why me :))
I have looked at the code and there was a comment to switch from JS to Capybara.
So, I have changed the code, it works locally. Maybe it going to solve the problem.
And that is a good use case to try to solve flaky # 10027

@sigmundpetersen
Copy link
Contributor

Yay, looks good @cyrillefr 🎉
That's even better, fixing a flaky spec at the same time 😄
Let's wait for the devs' review 👍

@cyrillefr
Copy link
Contributor Author

So, is this luck or what ?
Maybe something have changed overnight in testing env, or may the code change.

Hello @sigmundpetersen ,
I don't know if what I have done is the real solution, may be some additional testing to be sure ?
Also, there are 2 issues in one PR here, it is a bit untidy.
Should I leave(close) this PR and make a new one to address the flaky and a new tidy one for the rubocop issue ?

@cyrillefr
Copy link
Contributor Author

Ah, @sigmundpetersen , sorry, did not see your reply.

@sigmundpetersen
Copy link
Contributor

I think everything is fine @cyrillefr !
We can just close the flaky issue if the devs think this will close it 👍

checkbox_id = "order_cycle_incoming_exchange_0_select_all_variants"
page.execute_script("document.getElementById('#{checkbox_id}').scrollIntoView()")
elmnt = find_field(id: checkbox_id)
scroll_to(elmnt, align: :top)
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • That's great to incorporate the latest recommended method.
  • By looking at the flaky spec, we are not getting the element bycheckbox_id
  • Like the proposed changes, I think it's worth trying to use the built-in capybara method as opposed to running the JS script for the purpose
  • Let's hope for the best now :)

Copy link
Collaborator

@chahmedejaz chahmedejaz left a comment

Choose a reason for hiding this comment

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

Great work! 🎉

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Nice one, thanks @cyrillefr 🙏

@rioug rioug added the technical changes only These pull requests do not contain user facing changes and are grouped in release notes label Apr 9, 2024
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Great, thanks!

I have seen problematic corrections of this cop in the past because it can't know the type of object at run time but these fixes seem all good. 👍

I think that we can merge this straight away.

@mkllnk mkllnk merged commit c9c94fc into openfoodfoundation:master Apr 9, 2024
52 checks passed
@cyrillefr cyrillefr deleted the FixRailsNegateIncludeRubocopIssue branch April 9, 2024 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical changes only These pull requests do not contain user facing changes and are grouped in release notes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Rubocop Rails/NegateInclude
5 participants