Skip to content

Conversation

@sreichel
Copy link
Contributor

@sreichel sreichel commented Jan 2, 2026

Copilot AI review requested due to automatic review settings January 2, 2026 13:27
@sreichel sreichel added the chore label Jan 2, 2026
@github-actions github-actions bot added Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: Cms Relates to Mage_Cms Component: lib/Varien Relates to lib/Varien Component: Sales Relates to Mage_Sales Component: Customer Relates to Mage_Customer Component: Eav Relates to Mage_Eav Component: Adminhtml Relates to Mage_Adminhtml Component: Page Relates to Mage_Page Component: Captcha Relates to Mage_Captcha Component: Tax Relates to Mage_Tax Component: Newsletter Relates to Mage_Newsletter Component: Bundle Relates to Mage_Bundle Component: CatalogIndex Relates to Mage_CatalogIndex Component: Api2 Relates to Mage_Api2 Component: ImportExport Relates to Mage_ImportExport Component: Directory Relates to Mage_Directory Component: ConfigurableSwatches Relates to Mage_ConfigurableSwatches Component: CatalogSearch Relates to Mage_CatalogSearch Component: lib/* Relates to lib/* Component: lib/Magento Relates to lib/Magento rector labels Jan 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR applies the Rector rule ChangeIfElseValueAssignToEarlyReturnRector to refactor if-else value assignment patterns into early return patterns, improving code readability and reducing cognitive complexity.

Key changes:

  • Eliminates intermediate variable assignments by returning values directly
  • Converts if-else blocks to early return patterns throughout the codebase
  • Enables the ChangeIfElseValueAssignToEarlyReturnRector rule in .rector.php

Reviewed changes

Copilot reviewed 56 out of 56 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.rector.php Removes the rule from the skip list to enable ChangeIfElseValueAssignToEarlyReturnRector
lib/Varien/Simplexml/Element.php Refactors getParent() to use early return for _parent check
lib/Varien/Object.php Refactors toString() to use early return for empty format check
lib/Varien/Filter/Template.php Refactors includeDirective() and templateDirective() to use early returns for error cases
lib/Varien/Data/Form/Element/Abstract.php Refactors getLabelHtml() and getHtml() to use early returns
lib/Varien/Data/Collection/Db.php Simplifies _getMappedField() using null coalescing operator
lib/Magento/Profiler/OutputAbstract.php Refactors _renderColumnValue() to use early return for time formatting
app/code/core/Mage/Tax/Helper/Data.php Refactors getIncExcText() to use early return
app/code/core/Mage/Sales/Model/Resource/Order/Status.php Refactors _getLoadSelect() to use early return for default_state condition
app/code/core/Mage/Sales/Model/Order.php Refactors getCustomerName() to use early return
app/code/core/Mage/Page/Block/Html/Pager.php Refactors getPages() to use early return for simple page range case
app/code/core/Mage/Page/Block/Html/Head.php Refactors _getFaviconFile() to use early return
app/code/core/Mage/Page/Block/Html.php Refactors getPrintLogoUrl() to use early return
app/code/core/Mage/Newsletter/Model/Template.php Refactors getProcessedTemplate() to use early return for preprocess check
app/code/core/Mage/ImportExport/Model/Resource/Import/Data.php Refactors getIterator() to use early return and updates docblock return type
app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php Refactors _getAttributeConditionSql() to use early return for static attributes
app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php Refactors getDefaultGroupId() to use early return
app/code/core/Mage/Eav/Model/Entity/Attribute/Frontend/Abstract.php Refactors getClass() to use early return
app/code/core/Mage/Eav/Model/Attribute/Data/Multiline.php Refactors extractValue() to use early return
app/code/core/Mage/Eav/Model/Attribute/Data/Datetime.php Refactors _getFormFilter() to use early return for datetime filter
app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php Refactors _getFormFilter() to use early return for date filter
app/code/core/Mage/Directory/Model/Country.php Refactors formatAddress() to use early return
app/code/core/Mage/Customer/Block/Address/Renderer/Default.php Refactors getFormat() to use early return for country format
app/code/core/Mage/Customer/Block/Address/Edit.php Refactors getTitle() to use early return
app/code/core/Mage/Core/Model/Cache.php Refactors getTagsByType() and _getInvalidatedTypes() to use early returns, updates docblock
app/code/core/Mage/Core/Controller/Request/Http.php Refactors getBasePath() to use early return
app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php Refactors getProductImgByLabel() to use early return
app/code/core/Mage/Cms/Block/Block.php Refactors getCacheKeyInfo() to use early return
app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php Refactors _unifyField() to use early return for datetime backend type
app/code/core/Mage/CatalogIndex/Model/Resource/Aggregation.php Refactors getCacheData() to use early return
app/code/core/Mage/CatalogIndex/Model/Data/Abstract.php Refactors getTaxClassId() to use early return
app/code/core/Mage/Catalog/Model/Resource/Collection/Abstract.php Refactors _getLoadAttributesSelect() to use early return for store-specific selection
app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php Refactors getMainStoreTable() to use early return
app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php Refactors _calcSelectionPrice() to use early return
app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php Refactors getSku() to use early return
app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php Refactors _getUniqueFileName() to use early return for database storage check
app/code/core/Mage/Catalog/Model/Category.php Refactors _getAttribute() to use early return
app/code/core/Mage/Catalog/Block/Seo/Sitemap/Tree/Pager.php Refactors getPages() to use early return
app/code/core/Mage/Catalog/Block/Product/Widget/Html/Pager.php Refactors getPages() to use early return
app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php Refactors getPrice() to use early return
app/code/core/Mage/Catalog/Block/Navigation.php Refactors getCategoryUrl() to use early return
app/code/core/Mage/Captcha/Model/Zend.php Refactors _getFontPath() to use early return
app/code/core/Mage/Bundle/Model/Product/Price.php Refactors _getMaximalCustomOptionPrice() to use early return
app/code/core/Mage/Api2/Block/Adminhtml/Roles/Tab/Users.php Refactors getUsers() to use early return for JSON encoding
app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php Refactors _initStatus() to use early return
app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php Refactors renderHeader() to use early return for sortable columns
app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php Refactors _getDeleteUrl() to use early return
app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Grid.php Refactors decorateState() to use early return
app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging/Grid.php Refactors getCollection() to use early return
app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php Refactors getPackages() to use early return
app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php Refactors getHeaderText() to use early return
app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Shipping/Address.php Refactors getAddress() to use early return
app/code/core/Mage/Adminhtml/Block/Sales/Order/Create.php Refactors getCancelUrl() to use early return
app/code/core/Mage/Adminhtml/Block/Dashboard/Searches/Renderer/Searchquery.php Refactors render() to use early return for long query strings
app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php Refactors getBillingAddressHtml() to use early return

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions github-actions bot added the Component: Log Relates to Mage_Log label Jan 2, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
4.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

fballiano added a commit to MahoCommerce/maho that referenced this pull request Jan 3, 2026
Converts nested if statements to early returns for better code readability.

Thanks to @sreichel for finding this rector rule.
See: OpenMage/magento-lts#5210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Component: Adminhtml Relates to Mage_Adminhtml Component: Api2 Relates to Mage_Api2 Component: Bundle Relates to Mage_Bundle Component: Captcha Relates to Mage_Captcha Component: Catalog Relates to Mage_Catalog Component: CatalogIndex Relates to Mage_CatalogIndex Component: CatalogSearch Relates to Mage_CatalogSearch Component: Cms Relates to Mage_Cms Component: ConfigurableSwatches Relates to Mage_ConfigurableSwatches Component: Core Relates to Mage_Core Component: Customer Relates to Mage_Customer Component: Directory Relates to Mage_Directory Component: Eav Relates to Mage_Eav Component: ImportExport Relates to Mage_ImportExport Component: lib/Magento Relates to lib/Magento Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* Component: Log Relates to Mage_Log Component: Newsletter Relates to Mage_Newsletter Component: Page Relates to Mage_Page Component: Sales Relates to Mage_Sales Component: Tax Relates to Mage_Tax phpstan rector

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant