magento-hackathon/Magento-Two-factor-Authentication

View on GitHub

Showing 21 of 21 total issues

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;
            }

      Function adminUserAuthenticateAfter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function adminUserAuthenticateAfter(Varien_Event_Observer $observer)
          {
              if (!Mage::helper('twofactorauth')->isActive()) {
                  return $this;
              }
      Severity: Minor
      Found in src/app/code/community/MageHackDay/TwoFactorAuth/Model/Observer.php - About 1 hr to fix

      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

      Method saveAction has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function saveAction()
          {
              if (!$this->_validateFormKey()) {
                  return $this->_redirect('twofactorauth/customer/configure');
              }

        Function saveAction has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function saveAction()
            {
                if (!$this->_validateFormKey()) {
                    return $this->_redirect('twofactorauth/customer/configure');
                }

        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

        Method adminUserAuthenticateAfter has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function adminUserAuthenticateAfter(Varien_Event_Observer $observer)
            {
                if (!Mage::helper('twofactorauth')->isActive()) {
                    return $this;
                }
        Severity: Minor
        Found in src/app/code/community/MageHackDay/TwoFactorAuth/Model/Observer.php - About 1 hr to fix

          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

              Function checkTfaSubmitted has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function checkTfaSubmitted(Varien_Event_Observer $observer)
                  {
                      $request = $observer->getControllerAction()->getRequest();
              
                      if ($request->getActionName() == 'logout' || !Mage::helper('twofactorauth')->isActive()) {
              Severity: Minor
              Found in src/app/code/community/MageHackDay/TwoFactorAuth/Model/Observer.php - About 45 mins to fix

              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);
                                Severity
                                Category
                                Status
                                Source
                                Language