Skip to content

Codacy warning fixes #8949

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

Closed
wants to merge 9 commits into from
Closed

Conversation

HansSchouten
Copy link
Contributor

@HansSchouten HansSchouten commented Mar 20, 2017

Description

This pull request fixes a number of errors and warnings reported by Codacy.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@orlangur orlangur self-assigned this May 17, 2017
@orlangur orlangur added this to the May 2017 milestone May 17, 2017
@@ -17,8 +22,7 @@ public function execute()
{
$data = $this->getRequest()->getPostValue();
$isNew = $this->getRequest()->getParam('is_new');
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$this->resultRedirect = $this->resultRedirectFactory->create();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why need this instead of local variable?

__('We can\'t add the order status right now.')
);
if ($this->updateStatus($isNew, $data, $statusCode) !== false) {
return $this->resultRedirect;
Copy link
Contributor

Choose a reason for hiding this comment

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

Such logic seems quite confusing to me.

Random piece of code is moved to a separate method which may return boolean or object :)

Please change method name to isStatusUpdated and return true instead of object there.

}
return $this->resultRedirect->setPath(
Copy link
Contributor

Choose a reason for hiding this comment

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

Two returns is not a good practice. Simply change to

return $isNew 
    ? $this->resultRedirect->setPath('sales/*/new')
    : $this->resultRedirect->setPath('sales/*/edit' ...

['status' => $this->getRequest()->getParam('status')]
);
}
return $this->resultRedirect->setPath('sales/*/');
Copy link
Contributor

Choose a reason for hiding this comment

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

Where this new return comes from?

}

/**
* Check if template body has a reference to the same config path
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty logical change 👍

@orlangur
Copy link
Contributor

orlangur commented Jun 6, 2017

Closing this PR for now. Feel free to reopen if you would like to continue at any time.
Thank you for collaboration.

@orlangur orlangur closed this Jun 6, 2017
magento-devops-reposync-svc pushed a commit that referenced this pull request Jun 21, 2024
[Bengals Team] Test Fixes and Automation Tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants