Class: RuboCop::Cop::Glib::JsonUi::NestedBlockParameter

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

Overview

Enforces using the immediate block parameter instead of outer block variables in nested view blocks (childViews, content) in JsonUi templates.

Examples:

# bad - using outer variable
scroll.panels_form childViews: ->(form) do
  scroll.label text: 'TEST'  # using 'scroll' instead of 'form'
end

# good
scroll.panels_form childViews: ->(form) do
  form.label text: 'TEST'
end

# bad - parameter shadowing
scroll.panels_form childViews: ->(form) do
  form.panels_responsive childViews: ->(form) do  # shadows outer 'form'
    form.fields_text name: 'user[field]'
  end
end

# good
scroll.panels_form childViews: ->(form) do
  form.panels_responsive childViews: ->(res) do
    res.fields_text name: 'user[field]'
  end
end

Constant Summary

Constants inherited from BaseNestedParameter

BaseNestedParameter::MSG_OUTER_VAR

Method Summary

Methods inherited from BaseNestedParameter

#on_block