rugk/xenforo-threema-gateway

View on GitHub
src/library/ThreemaGateway/Installer.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

    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

      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

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

      class ThreemaGateway_Installer
      {
          /**
           * At the installation this will check the XenForo version and
           * add the 2FA provider to the table.

      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

      Missing class import via use statement (line '44', column '41').
      Open

                  $permissionsInstaller = new ThreemaGateway_Installer_Permissions;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '113', column '33').
      Open

              $pendReqInstaller = new ThreemaGateway_Installer_TfaPendingConfirmMsgs;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '65', column '38').
      Open

                  $keystoreInstaller = new ThreemaGateway_Installer_Keystore;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '83', column '39').
      Open

                  $messageDbInstaller = new ThreemaGateway_Installer_MessagesDb;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '88', column '37').
      Open

                  $pendReqInstaller = new ThreemaGateway_Installer_TfaPendingConfirmMsgs;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '96', column '38').
      Open

                  $throttleInstaller = new ThreemaGateway_Installer_ActionThrottle;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '131', column '34').
      Open

              $keystoreInstaller = new ThreemaGateway_Installer_Keystore;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '28', column '23').
      Open

                  throw new XenForo_Exception($error);

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '177', column '50').
      Open

              $providerInstaller['conventional'] = new ThreemaGateway_Installer_TfaProvider(

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '118', column '35').
      Open

              $messageDbInstaller = new ThreemaGateway_Installer_MessagesDb;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '185', column '42').
      Open

              $providerInstaller['fast'] = new ThreemaGateway_Installer_TfaProvider(

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '108', column '34').
      Open

              $throttleInstaller = new ThreemaGateway_Installer_ActionThrottle;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '136', column '37').
      Open

              $permissionsInstaller = new ThreemaGateway_Installer_Permissions;

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '181', column '46').
      Open

              $providerInstaller['reversed'] = new ThreemaGateway_Installer_TfaProvider(

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid using static access to class 'XenForo_Model' in method 'uninstall'.
      Open

              $userFieldModel = XenForo_Model::create('XenForo_Model_UserField');

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid assigning values to variables in if clauses and the like (line '143', column '13').
      Open

          public static function uninstall()
          {
              // delete throttle table
              /** @var ThreemaGateway_Installer_ActionThrottle $throttleInstaller */
              $throttleInstaller = new ThreemaGateway_Installer_ActionThrottle;

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid using static access to class 'ThreemaGateway_Option_PrivateKeyPath' in method 'uninstall'.
      Open

                  ThreemaGateway_Option_PrivateKeyPath::removePrivateKey($xenOptions->threema_gateway_privatekeyfile);

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class 'ThreemaGateway_Option_DebugModeLog' in method 'uninstall'.
      Open

                  ThreemaGateway_Option_DebugModeLog::removeLog($xenOptions->threema_gateway_logreceivedmsgs);

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class 'XenForo_DataWriter' in method 'uninstall'.
      Open

                  $userFieldWriter = XenForo_DataWriter::create('XenForo_DataWriter_UserField');

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class 'XenForo_Application' in method 'uninstall'.
      Open

              $xenOptions = XenForo_Application::getOptions();

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class 'XenForo_DataWriter' in method 'install'.
      Open

                  $userFieldWriter = XenForo_DataWriter::create('XenForo_DataWriter_UserField');

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      There are no issues that match your filters.

      Category
      Status