rugk/xenforo-threema-gateway

View on GitHub

Showing 597 of 597 total issues

File Callback.php has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Allows XenForo to receive Threema messages by providing a callback.
 *
 * @package ThreemaGateway
Severity: Minor
Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 2 hrs to fix

    ThreemaGateway_Handler_Action_TfaCallback_Abstract has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class ThreemaGateway_Handler_Action_TfaCallback_Abstract extends ThreemaGateway_Handler_Action_Abstract
    {
        /**
         * @var array Cache of models
         */
    Severity: Minor
    Found in src/library/ThreemaGateway/Handler/Action/TfaCallback/Abstract.php - About 2 hrs to fix

      Method handleManage has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          final public function handleManage(XenForo_Controller $controller, array $user, array $providerData)
          {
              $this->gatewayPermissions->setUserId($user);
      
              /** @var XenForo_Input $input */
      Severity: Major
      Found in src/library/ThreemaGateway/Tfa/AbstractProvider.php - About 2 hrs to fix

        Method handleMessageDecline has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function handleMessageDecline(array &$providerData, array $user, $userIp = null)
            {
                /** @var XenForo_Options $xenOptions */
                $xenOptions = XenForo_Application::getOptions();
                /** @var int $blockingTime seconds how long users should be blocked */
        Severity: Major
        Found in src/library/ThreemaGateway/Tfa/Fast.php - About 2 hrs to fix

          Function handleManage has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              final public function handleManage(XenForo_Controller $controller, array $user, array $providerData)
              {
                  $this->gatewayPermissions->setUserId($user);
          
                  /** @var XenForo_Input $input */
          Severity: Minor
          Found in src/library/ThreemaGateway/Tfa/AbstractProvider.php - About 2 hrs 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 create has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function create()
              {
                  $db = XenForo_Application::get('db');
          
                  // set charset
          Severity: Major
          Found in src/library/ThreemaGateway/Installer/MessagesDb.php - About 2 hrs to fix

            Method setDataForRequest has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function setDataForRequest(
                    array $confirmRequest,
                    array $setData,
                    array $processOptions = []
                ) {
            Severity: Major
            Found in src/library/ThreemaGateway/Handler/Action/TfaCallback/Abstract.php - About 2 hrs to fix

              Method processMessage has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function processMessage($downloadPath, $debugMode = false)
                  {
                      /** @var string $output */
                      $output = '';
              
              
              Severity: Major
              Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 2 hrs to fix

                Function getMessageDataByType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getMessageDataByType($messageType, $includeMetaData = true)
                    {
                        /** @var array $output */
                        $output = [];
                
                
                Severity: Minor
                Found in src/library/ThreemaGateway/Model/Messages.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 triggerVerification has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function triggerVerification($context, array $user, $userIp, array &$providerData)
                    {
                        parent::triggerVerification($context, $user, $userIp, $providerData);
                
                        // this 2FA mode requires end-to-end encryption
                Severity: Minor
                Found in src/library/ThreemaGateway/Tfa/Fast.php - About 1 hr to fix

                  Method _getExistingData has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function _getExistingData($data)
                      {
                          /** @var string $messageId */
                          if (!$messageId = $this->_getExistingPrimaryKey($data, 'message_id')) {
                              return false;
                  Severity: Minor
                  Found in src/library/ThreemaGateway/DataWriter/Messages.php - About 1 hr to fix

                    Method _preSave has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function _preSave()
                        {
                            // filter data
                            // also uses existing data as a data base as otherwise the main table
                            // may also get deleted because of missing message id
                    Severity: Minor
                    Found in src/library/ThreemaGateway/DataWriter/Messages.php - About 1 hr to fix

                      Method install has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function install($installedAddon)
                          {
                              /** @var array $providerInstaller An array with the models of all providers */
                              $providerInstaller = self::getProviderInstaller();
                              // check requirements of Gateway
                      Severity: Minor
                      Found in src/library/ThreemaGateway/Installer.php - About 1 hr to fix

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                        <?php
                        /**
                         * Passes data to Tfa model.
                         *
                         * @package ThreemaGateway
                        Severity: Major
                        Found in src/library/ThreemaGateway/ControllerPublic/Login.php and 1 other location - About 1 hr to fix
                        src/library/ThreemaGateway/ControllerAdmin/Login.php on lines 1..47

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 115.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                        <?php
                        /**
                         * Passes data to Tfa model.
                         *
                         * @package ThreemaGateway
                        Severity: Major
                        Found in src/library/ThreemaGateway/ControllerAdmin/Login.php and 1 other location - About 1 hr to fix
                        src/library/ThreemaGateway/ControllerPublic/Login.php on lines 1..47

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 115.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Method verifyFromInput has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData)
                            {
                                /** @var bool $result from parent, for error checking */
                                $result = parent::verifyFromInput($context, $input, $user, $providerData);
                        
                        
                        Severity: Minor
                        Found in src/library/ThreemaGateway/Tfa/Fast.php - About 1 hr to fix

                          Avoid excessively long class names like ThreemaGateway_Model_TfaPendingMessagesConfirmation. Keep class name length under 40.
                          Open

                          class ThreemaGateway_Model_TfaPendingMessagesConfirmation extends XenForo_Model
                          {
                              /**
                               * @var string database table name
                               */

                          LongClassName

                          Since: 2.9

                          Detects when classes or interfaces are declared with excessively long names.

                          Example

                          class ATooLongClassNameThatHintsAtADesignProblem {
                          
                          }
                          
                          interface ATooLongInterfaceNameThatHintsAtADesignProblem {
                          
                          }

                          Source https://phpmd.org/rules/naming.html#longclassname

                          Avoid excessively long class names like ThreemaGateway_Listener_TfaMessageCallback. Keep class name length under 40.
                          Open

                          class ThreemaGateway_Listener_TfaMessageCallback
                          {
                              /**
                               * Presave listener: Checks whether text messages contain code used for the receiver 2FA.
                               *

                          LongClassName

                          Since: 2.9

                          Detects when classes or interfaces are declared with excessively long names.

                          Example

                          class ATooLongClassNameThatHintsAtADesignProblem {
                          
                          }
                          
                          interface ATooLongInterfaceNameThatHintsAtADesignProblem {
                          
                          }

                          Source https://phpmd.org/rules/naming.html#longclassname

                          Avoid excessively long class names like ThreemaGateway_Option_ThreemaGatewaySecret. Keep class name length under 40.
                          Open

                          class ThreemaGateway_Option_ThreemaGatewaySecret
                          {
                              /**
                               * @var int Chars not to censor when displaying secret
                               */

                          LongClassName

                          Since: 2.9

                          Detects when classes or interfaces are declared with excessively long names.

                          Example

                          class ATooLongClassNameThatHintsAtADesignProblem {
                          
                          }
                          
                          interface ATooLongInterfaceNameThatHintsAtADesignProblem {
                          
                          }

                          Source https://phpmd.org/rules/naming.html#longclassname

                          Avoid excessively long class names like ThreemaGateway_DataWriter_TfaPendingMessagesConfirmation. Keep class name length under 40.
                          Open

                          class ThreemaGateway_DataWriter_TfaPendingMessagesConfirmation extends XenForo_DataWriter
                          {
                              /**
                               * Gets the fields that are defined for the table. See parent for explanation.
                               *

                          LongClassName

                          Since: 2.9

                          Detects when classes or interfaces are declared with excessively long names.

                          Example

                          class ATooLongClassNameThatHintsAtADesignProblem {
                          
                          }
                          
                          interface ATooLongInterfaceNameThatHintsAtADesignProblem {
                          
                          }

                          Source https://phpmd.org/rules/naming.html#longclassname

                          Severity
                          Category
                          Status
                          Source
                          Language