rugk/xenforo-threema-gateway

View on GitHub

Showing 597 of 597 total issues

The class ThreemaGateway_Tfa_AbstractProvider has a coupling between objects value of 19. Consider to reduce the number of dependencies under 13.
Open

abstract class ThreemaGateway_Tfa_AbstractProvider extends XenForo_Tfa_AbstractProvider
{
    /**
     * Variable, which will be filled with object of the Gateway Permissions class.
     *

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

Method renderVerification has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function renderVerification(XenForo_View $view, $context, array $user,
                                        array $providerData, array $triggerData)
Severity: Minor
Found in src/library/ThreemaGateway/Tfa/Reversed.php - About 35 mins to fix

    Method renderVerification has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function renderVerification(XenForo_View $view, $context, array $user,
                                            array $providerData, array $triggerData)
    Severity: Minor
    Found in src/library/ThreemaGateway/Tfa/Fast.php - About 35 mins to fix

      Method renderVerification has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function renderVerification(XenForo_View $view, $context, array $user,
                                              array $providerData, array $triggerData)
      Severity: Minor
      Found in src/library/ThreemaGateway/Tfa/AbstractProvider.php - About 35 mins to fix

        Method renderVerification has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function renderVerification(XenForo_View $view, $context, array $user,
                                                array $providerData, array $triggerData)
        Severity: Minor
        Found in src/library/ThreemaGateway/Tfa/Conventional.php - About 35 mins to fix

          Function checkForDeliveryReceipt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function checkForDeliveryReceipt(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 35 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 renderHtml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function renderHtml(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit)
              {
                  /** @var array $status */
                  $status = ['libsodium', 'libsodiumphp', 'phpsdk', 'credits'];
                  /** @var array $extraError */
          Severity: Minor
          Found in src/library/ThreemaGateway/Option/Status.php - About 35 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 addLog has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function addLog(&$log, $stringToAdd, $stringToAddDetail = null)
              {
                  // convert to array if necessary or just add string
                  if (is_string($log)) {
                      if ($stringToAddDetail) {
          Severity: Minor
          Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 35 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 saveMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function saveMessage(
                  Threema\MsgApi\Helpers\ReceiveMessageResult $receiveResult,
                  Threema\MsgApi\Messages\ThreemaMessage $threemaMsg
              ) {
                  $dataWriter = XenForo_DataWriter::create('ThreemaGateway_DataWriter_Messages');
          Severity: Minor
          Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 35 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 checkForReceiverCode has a Cognitive Complexity of 7 (exceeds 5 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 35 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 setDataForRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function setDataForRequest(
                  array $confirmRequest,
                  array $setData,
                  array $processOptions = []
              ) {
          Severity: Minor
          Found in src/library/ThreemaGateway/Handler/Action/TfaCallback/Abstract.php - About 35 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 setUserId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function setUserId($newUser = null)
              {
                  // get user ids (or null)
                  if ($this->user === null) {
                      /** @var int|null $oldUserId User id of user (from class) */
          Severity: Minor
          Found in src/library/ThreemaGateway/Handler/Permissions.php - About 35 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 applyFilter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function applyFilter($filterType, $filterData, $failOnError = true)
              {
                  /** @var $success bool */
                  $success = true;
          
          
          Severity: Minor
          Found in src/library/ThreemaGateway/Handler/Action/TfaCallback/TextMessage.php - About 35 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 processMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function processMessage($downloadPath, $debugMode = false)
              {
                  /** @var string $output */
                  $output = '';
          
          
          Severity: Minor
          Found in src/library/ThreemaGateway/Handler/Action/Callback.php - About 35 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 false;
          Severity: Major
          Found in src/library/ThreemaGateway/Tfa/Fast.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return null;
            Severity: Major
            Found in src/library/ThreemaGateway/Tfa/AbstractProvider.php - About 30 mins to fix

              The method getMessageMetaData has a boolean flag argument $groupById, which is a certain sign of a Single Responsibility Principle violation.
              Open

                  public function getMessageMetaData($groupById = false, $ignoreInvalid = true)

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

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

              Avoid too many return statements within this method.
              Open

                      return true;
              Severity: Major
              Found in src/library/ThreemaGateway/Tfa/Fast.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return $controller->responseView(
                            'ThreemaGateway_ViewPublic_TfaManage',
                            'account_two_step_' . $this->_providerId . '_manage',
                            $viewParams
                        );
                Severity: Major
                Found in src/library/ThreemaGateway/Tfa/AbstractProvider.php - About 30 mins to fix

                  The method getAllMessageData has a boolean flag argument $groupByMessageType, which is a certain sign of a Single Responsibility Principle violation.
                  Open

                      public function getAllMessageData(array $metaData, $groupByMessageType = false)

                  BooleanArgumentFlag

                  Since: 1.4.0

                  A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                  Example

                  class Foo {
                      public function bar($flag = true) {
                      }
                  }

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

                  Severity
                  Category
                  Status
                  Source
                  Language