magento-hackathon/Magento-Two-factor-Authentication

View on GitHub
src/app/code/community/MageHackDay/TwoFactorAuth/controllers/Adminhtml/TwofactorauthController.php

Summary

Maintainability
F
3 days
Test Coverage

Function qrSubmitAction has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    public function qrSubmitAction()
    {
        if ( ! $this->getRequest()->isPost()) {
            return;
        }

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File TwofactorauthController.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * adminhtml controller to enforce Two Factor Authentication
 *

    Method qrSubmitAction has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function qrSubmitAction()
        {
            if ( ! $this->getRequest()->isPost()) {
                return;
            }

      Method resetAction has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function resetAction()
          {
              if ( ! Mage::helper('twofactorauth/auth')->isReAuthenticated()) {
                  $this->_getSession()->addError($this->__('Access Denied.'));
                  $this->_redirectReferer();

        Method answerAction has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function answerAction()
            {
                $questionId = (int) Mage::app()->getRequest()->getPost('question_id');
                if ( ! $questionId) {
                    $this->_redirect('*/*/interstitial');

          Function _isAllowed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function _isAllowed()
              {
                  $action = $this->getRequest()->getActionName();
          
                  if ($action == 'resetUser') {

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Avoid too many return statements within this method.
          Open

                      return;

            Avoid too many return statements within this method.
            Open

                        return FALSE;

              Avoid too many return statements within this method.
              Open

                      return;

                Avoid too many return statements within this method.
                Open

                                return;

                  Avoid too many return statements within this method.
                  Open

                                  return;

                    Avoid too many return statements within this method.
                    Open

                                    return;

                      Avoid too many return statements within this method.
                      Open

                              return TRUE;

                        Avoid too many return statements within this method.
                        Open

                                return;

                          Avoid too many return statements within this method.
                          Open

                                      return ($hasToken && $authenticated);

                            Function answerAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function answerAction()
                                {
                                    $questionId = (int) Mage::app()->getRequest()->getPost('question_id');
                                    if ( ! $questionId) {
                                        $this->_redirect('*/*/interstitial');

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            There are no issues that match your filters.

                            Category
                            Status