Class: RuboCop::Cop::Glib::JsonUi::NestedActionParameter

Inherits:
BaseNestedParameter show all
Defined in:
lib/glib/rubocop/cops/json_ui/nested_action_parameter.rb

Overview

Enforces using the immediate block parameter instead of outer block variables in nested action blocks (onClick, onClose, onChange, etc.) in JsonUi templates.

Examples:

# bad - parameter shadowing
button onClick: ->(action) do
  action.dialogs_alert onClose: ->(action) do  # shadows outer 'action'
    action.snackbars_alert message: 'Closed'
  end
end

# good
button onClick: ->(action) do
  action.dialogs_alert onClose: ->(subaction) do
    subaction.snackbars_alert message: 'Closed'
  end
end

# bad - using outer variable
button onClick: ->(action) do
  action.dialogs_alert onClose: ->(subaction) do
    action.forms_submit  # using 'action' instead of 'subaction'
  end
end

# good
button onClick: ->(action) do
  action.dialogs_alert onClose: ->(subaction) do
    subaction.forms_submit
  end
end

Constant Summary

Constants inherited from BaseNestedParameter

BaseNestedParameter::MSG_OUTER_VAR

Method Summary

Methods inherited from BaseNestedParameter

#on_block