rugk/xenforo-threema-gateway

View on GitHub

Showing 597 of 597 total issues

Method getLogData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getLogData(
        Threema\MsgApi\Helpers\ReceiveMessageResult $receiveResult,
        Threema\MsgApi\Messages\ThreemaMessage $threemaMsg
    ) {
        $eol = PHP_EOL;
Severity: Minor
Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 1 hr to fix

    Avoid using undefined variables such as '$cryptTool' which will lead to PHP notices.
    Open

            $this->cryptTool       = $cryptTool;

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$error' which will lead to PHP notices.
    Open

                throw new XenForo_Exception($error);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$error' which will lead to PHP notices.
    Open

            if (!self::meetsRequirements($error)) {

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

        protected function _getExistingData($data)
        {
            // try primary key first
            /** @var string $requestId */
            if ($requestId = $this->_getExistingPrimaryKey($data, 'request_id')) {

      Method queryCredits has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected static function queryCredits(array &$status, array &$extraError)
          {
              /** @var ThreemaGateway_Handler_Permissions $permissions */
              $permissions = ThreemaGateway_Handler_Permissions::getInstance();
      
      
      Severity: Minor
      Found in src/library/ThreemaGateway/Option/Status.php - About 1 hr to fix

        Function ReceiveCallback has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var ReceiveCallback = (function () {
            'use strict';
            var me = {};
            var $inputElem;
            var $hiddenElem;
        Severity: Minor
        Found in src/js/ThreemaGateway/options.js - About 1 hr to fix

          Method checkForReceiverCode has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function checkForReceiverCode(ThreemaGateway_Handler_Action_Callback $handler,
                                                  Threema\MsgApi\Helpers\ReceiveMessageResult $receiveResult,
                                                  Threema\MsgApi\Messages\ThreemaMessage $threemaMsg,
                                                  &$output,
                                                  &$saveMessage,
          Severity: Minor
          Found in src/library/ThreemaGateway/Listener/TfaMessageCallback.php - About 1 hr to fix

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

                protected static function checkTecRequire(array &$status, array &$extraError)
                {
                    // optional check: HTTPS
                    if (!XenForo_Application::$secure) {
                        $extraError[]['text'] = new XenForo_Phrase('option_threema_gateway_status_no_https');
            Severity: Minor
            Found in src/library/ThreemaGateway/Option/Status.php - About 1 hr to fix

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

                  public function processPending(array $processOptions = [])
                  {
                      if (!$this->pendingRequests) {
                          $this->preProcessPending();
                      }
              Severity: Minor
              Found in src/library/ThreemaGateway/Handler/Action/TfaCallback/Abstract.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

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

                  public function getMessageMetaData($groupById = false, $ignoreInvalid = true)
                  {
                      /** @var array $limitOptions */
                      $limitOptions = $this->prepareLimitFetchOptions($this->fetchOptions);
              
              
              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

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

                  public static function getRandomBytes($number)
                  {
                      /** @var string $output */
                      $output = '';
              
              
              Severity: Minor
              Found in src/library/ThreemaGateway/Helper/Random.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 validatePreConditions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function validatePreConditions(&$errorString)
                  {
                      /** @var XenForo_Options $options */
                      $options = XenForo_Application::getOptions();
              
              
              Severity: Minor
              Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 1 hr to fix

                Method uninstall has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function uninstall()
                    {
                        // delete throttle table
                        /** @var ThreemaGateway_Installer_ActionThrottle $throttleInstaller */
                        $throttleInstaller = new ThreemaGateway_Installer_ActionThrottle;
                Severity: Minor
                Found in src/library/ThreemaGateway/Installer.php - About 1 hr to fix

                  Method validateRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function validateRequest(&$errorString)
                      {
                          // access token validation (authentication of Gateway server)
                          /** @var XenForo_Options $options */
                          $options = XenForo_Application::getOptions();
                  Severity: Minor
                  Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (!$this->input->inRequest('from') ||
                                !$this->input->inRequest('to') ||
                                !$this->input->inRequest('messageId') ||
                                !$this->input->inRequest('date') ||
                                !$this->input->inRequest('nonce') ||
                    Severity: Major
                    Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 1 hr to fix

                      Function actionTwoStepEnable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function actionTwoStepEnable()
                          {
                              /** @var XenForo_ControllerResponse_View $parent */
                              $parent = parent::actionTwoStepEnable();
                      
                      
                      Severity: Minor
                      Found in src/library/ThreemaGateway/ControllerPublic/Account.php - About 55 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

                      Function triggerVerification has a Cognitive Complexity of 9 (exceeds 5 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 55 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 variables with short names like $db. Configured minimum length is 3.
                      Open

                              $db = XenForo_Application::get('db');

                      ShortVariable

                      Since: 0.2

                      Detects when a field, local, or parameter has a very short name.

                      Example

                      class Something {
                          private $q = 15; // VIOLATION - Field
                          public static function main( array $as ) { // VIOLATION - Formal
                              $r = 20 + $this->q; // VIOLATION - Local
                              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                  $r += $this->q;
                              }
                          }
                      }

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

                      Avoid variables with short names like $db. Configured minimum length is 3.
                      Open

                              $db = XenForo_Application::get('db');

                      ShortVariable

                      Since: 0.2

                      Detects when a field, local, or parameter has a very short name.

                      Example

                      class Something {
                          private $q = 15; // VIOLATION - Field
                          public static function main( array $as ) { // VIOLATION - Formal
                              $r = 20 + $this->q; // VIOLATION - Local
                              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                  $r += $this->q;
                              }
                          }
                      }

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

                      Severity
                      Category
                      Status
                      Source
                      Language