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

An error occurred while Style/ConditionalAssignment with EnforcedStyle: assign_inside_condition #10737

Closed
naft-a opened this issue Jun 22, 2022 · 0 comments · Fixed by #10738
Closed
Assignees
Labels

Comments

@naft-a
Copy link

naft-a commented Jun 22, 2022

Expected behavior

Rubocop linting should pass with no errors.

Actual behavior

Rubocop raises the error An error occurred while Style/ConditionalAssignment cop was inspecting and
rubocop --debug did not provide any useful info.

Steps to reproduce the problem

Error is raised for the line failures += 1 in this method:

    def perform(action = nil)
      failures = 0

      @collection.each do |object|
        yield(object)
      rescue ActiveRecord::RecordInvalid
        failures += 1
      end

      redirect_to request.referer || @return_path, notice: notice_message(@collection.length, failures, action)
    end

RuboCop version

$ [bundle exec] rubocop -V
1.27.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 3.0.2 x86_64-linux)
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.2
  - rubocop-rspec 2.9.0
@dvandersluis dvandersluis self-assigned this Jun 22, 2022
@dvandersluis dvandersluis changed the title An error occurred while Style/ConditionalAssignment An error occurred while Style/ConditionalAssignment with EnforcedStyle: assign_inside_condition Jun 22, 2022
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jun 22, 2022
…EnforcedStyle: assign_inside_condition` when op-assigning a variable inside a `resbody`.
koic added a commit that referenced this issue Jun 23, 2022
[Fix #10737] Fix crash in `Style/ConditionalAssignment` with `EnforcedStyle: assign_inside_condition` when op-assigning a variable inside a `resbody`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants