Skip to content

Removed unreachable code #17256

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions app/code/Magento/CatalogSearch/Block/Advanced/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,11 @@ public function getCurrencyCount()
*
* @param AbstractAttribute $attribute
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getCurrency($attribute)
{
return $this->_storeManager->getStore()->getCurrentCurrencyCode();

$baseCurrency = $this->_storeManager->getStore()->getBaseCurrency()->getCurrencyCode();
return $this->getAttributeValue(
$attribute,
'currency'
) ? $this->getAttributeValue(
$attribute,
'currency'
) : $baseCurrency;
}

/**
Expand Down
11 changes: 4 additions & 7 deletions app/code/Magento/MediaStorage/Model/File/Storage/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,10 @@ public function saveDir($dir)
*/
public function saveFile($file, $overwrite = true)
{
if (isset(
$file['filename']
) && !empty($file['filename']) && isset(
$file['content']
) && !empty($file['content'])
if (isset($file['filename'])
&& !empty($file['filename'])
&& isset($file['content'])
&& !empty($file['content'])
) {
try {
$filename = isset(
Expand All @@ -307,8 +306,6 @@ public function saveFile($file, $overwrite = true)
} else {
throw new \Magento\Framework\Exception\LocalizedException(__('Wrong file info format'));
}

return false;
}

/**
Expand Down
13 changes: 1 addition & 12 deletions app/code/Magento/Sales/Model/Service/CreditmemoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,11 @@ public function __construct(
* @param int $id Credit Memo Id
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function cancel($id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Some static tests fails because with your refactoring the method parameter $id is not used any more.
Please, add a @SuppressWarnings(PHPMD.UnusedFormalParameter) directive in method's docblock to avoid the static test to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed it.

{
throw new \Magento\Framework\Exception\LocalizedException(__('You can not cancel Credit Memo'));
try {
$creditmemo = $this->creditmemoRepository->get($id);
$creditmemo->setState(\Magento\Sales\Model\Order\Creditmemo::STATE_CANCELED);
foreach ($creditmemo->getAllItems() as $item) {
$item->cancel();
}
$this->eventManager->dispatch('sales_order_creditmemo_cancel', ['creditmemo' => $creditmemo]);
$this->creditmemoRepository->save($creditmemo);
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('Could not cancel creditmemo'), $e);
}
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ public function getRemoveUrl($track)
public function getCarrierTitle($code)
{
$carrier = $this->_carrierFactory->create($code);
if ($carrier) {
return $carrier->getConfigData('title');
} else {
return __('Custom Value');
}
return false;
return $carrier ? $carrier->getConfigData('title') : __('Custom Value');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ public function execute()
$this->_redirect('adminhtml/*/edit', ['_current' => true]);
return;
}
$this->_redirect('adminhtml/*/');
return;
}
}