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

Cop idea: Negative #valid? method #1015

Closed
ydakuka opened this issue Jun 10, 2023 · 2 comments · Fixed by #1097
Closed

Cop idea: Negative #valid? method #1015

ydakuka opened this issue Jun 10, 2023 · 2 comments · Fixed by #1097
Labels
enhancement New feature or request

Comments

@ydakuka
Copy link

ydakuka commented Jun 10, 2023

Actual behavior

I have the code:

class AdvertsController < ApplicationController
  # PATCH /adverts/:id
  def update
    render :edit unless @form.valid?
  end
end

I run rubocop:

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop spec/forms/advert_form_spec.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

Expected behavior

I expected to receive the following code:

class AdvertsController < ApplicationController
  # PATCH /adverts/:id
  def update
    render :edit if @form.invalid?
  end
end
@ydakuka
Copy link
Author

ydakuka commented Jun 10, 2023

Linked: rubocop/rubocop-rspec#1660

@fatkodima
Copy link
Contributor

This should be handled by existing Style/InvertibleUnlessCondition cop - https://docs.rubocop.org/rubocop/1.52/cops_style.html#styleinvertibleunlesscondition

koic added a commit to koic/rubocop-rails that referenced this issue Aug 28, 2023
…tive Support methods

Resolves rubocop#1015.

This PR makes `Style/InvertibleUnlessCondition` aware of Active Support methods.
It still inherits the default disabled.
koic added a commit to koic/rubocop-rails that referenced this issue Aug 28, 2023
…tive Support methods

Resolves rubocop#1015.

This PR makes `Style/InvertibleUnlessCondition` aware of Active Support methods.
It still inherits the default disabled.
@koic koic added the enhancement New feature or request label Aug 31, 2023
@koic koic closed this as completed in #1097 Sep 4, 2023
koic added a commit that referenced this issue Sep 4, 2023
…tion_aware_of_as_methods

[Fix #1015] Make `Style/InvertibleUnlessCondition` aware of Active Support methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants