Skip to content

rector: CombineIfRector #4880

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sreichel
Copy link
Contributor

@sreichel sreichel commented Jul 8, 2025

@sreichel sreichel added this to the 20.15.0 milestone Jul 8, 2025
@sreichel sreichel added the chore label Jul 8, 2025
@github-actions github-actions bot added Component: PayPal Relates to Mage_Paypal Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: Cms Relates to Mage_Cms Component: Reports Relates to Mage_Reports Component: CatalogInventory Relates to Mage_CatalogInventory Component: Checkout Relates to Mage_Checkout Component: lib/Varien Relates to lib/Varien Component: Sales Relates to Mage_Sales Component: Usa Relates to Mage_Usa Component: Customer Relates to Mage_Customer Component: Eav Relates to Mage_Eav Component: lib/Mage Relates to lib/Mage Component: Adminhtml Relates to Mage_Adminhtml Component: ProductAlert Relates to Mage_ProductAlert Component: Page Relates to Mage_Page Component: Api PageRelates to Mage_Api Component: Cron Relates to Mage_Cron Component: Captcha Relates to Mage_Captcha Component: CurrencySymbol Relates to Mage_CurrencySymbol Component: CatalogRule Relates to Mage_CatalogRule Component: SalesRule Relates to Mage_SalesRule Component: Wishlist Relates to Mage_Wishlist Component: Weee Relates to Mage_Weee Component: Tax Relates to Mage_Tax Component: Rule Relates to Mage_Rule labels Jul 8, 2025
@github-actions github-actions bot added Component: Review Relates to Mage_Review Component: Payment Relates to Mage_Payment Component: Index Relates to Mage_Index Component: Downloadable Relates to Mage_Downloadable Component: Bundle Relates to Mage_Bundle Component: CatalogIndex Relates to Mage_CatalogIndex Component: Log Relates to Mage_Log Component: ConfigurableSwatches Relates to Mage_ConfigurableSwatches Component: CatalogSearch Relates to Mage_CatalogSearch Component: Centinel Relates to Mage_Centinel Component: Install Relates to Mage_Install Component: Rss Relates to Mage_Rss Component: lib/* Relates to lib/* phpstan rector labels Jul 8, 2025
Copy link

sonarqubecloud bot commented Jul 8, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

) {
return true;
}
if (($attribute = $this->getAttribute()) && (!$attribute->isScopeGlobal() && $this->getDataObject() && $this->getDataObject()->getId() && $this->getDataObject()->getStoreId())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a long one. Also, it can simplify to return $condition

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. This doesnt enhance readability.

@@ -160,19 +160,17 @@ public function canReturnToStock()
*/
public function canReturnItemsToStock()
{
if (is_null($this->_canReturnToStock)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh boy.. setting something in a if and also in a setter.

'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCreditMemoUrl()),
]);
}
if ($this->_isAllowedAction('creditmemo') && $this->getInvoice()->getOrder()->canCreditmemo() && ($orderPayment->canRefundPartialPerInvoice() && $this->getInvoice()->canRefund() && $orderPayment->getAmountPaid() > $orderPayment->getAmountRefunded() || $orderPayment->canRefund() && !$this->getInvoice()->getIsUsedForRefund())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is also way too long to process. Can refactor do these in a seperate line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check all long lines later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. It would be nice if after a certain character cutoff Rector could stack conditions vertically for better readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hoped php-cs-fixer would jump in to fix it, but seems i have to do it manually.

@sreichel sreichel marked this pull request as draft July 11, 2025 00:40
@sreichel sreichel modified the milestones: 20.15.0, 20.16.0 Jul 12, 2025
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: Api PageRelates to Mage_Api 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: CatalogInventory Relates to Mage_CatalogInventory Component: CatalogRule Relates to Mage_CatalogRule Component: CatalogSearch Relates to Mage_CatalogSearch Component: Centinel Relates to Mage_Centinel Component: Checkout Relates to Mage_Checkout Component: Cms Relates to Mage_Cms Component: ConfigurableSwatches Relates to Mage_ConfigurableSwatches Component: Core Relates to Mage_Core Component: Cron Relates to Mage_Cron Component: CurrencySymbol Relates to Mage_CurrencySymbol Component: Customer Relates to Mage_Customer Component: Downloadable Relates to Mage_Downloadable Component: Eav Relates to Mage_Eav Component: Index Relates to Mage_Index Component: Install Relates to Mage_Install Component: lib/Mage Relates to lib/Mage Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* Component: Log Relates to Mage_Log Component: Page Relates to Mage_Page Component: Payment Relates to Mage_Payment Component: PayPal Relates to Mage_Paypal Component: ProductAlert Relates to Mage_ProductAlert Component: Reports Relates to Mage_Reports Component: Review Relates to Mage_Review Component: Rss Relates to Mage_Rss Component: Rule Relates to Mage_Rule Component: Sales Relates to Mage_Sales Component: SalesRule Relates to Mage_SalesRule Component: Tax Relates to Mage_Tax Component: Usa Relates to Mage_Usa Component: Weee Relates to Mage_Weee Component: Wishlist Relates to Mage_Wishlist phpstan rector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants