detain/myadmin-opensrs-domains

View on GitHub

Showing 90 of 90 total issues

Function activate_domain has a Cognitive Complexity of 378 (exceeds 5 allowed). Consider refactoring.
Open

    public static function activate_domain($id)
    {
        page_title('Activate Domain');
        $settings = get_module_settings('domains');
        $db = get_module_db('domains');
Severity: Minor
Found in src/Plugin.php - About 1 wk 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 activate_domain has 536 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function activate_domain($id)
    {
        page_title('Activate Domain');
        $settings = get_module_settings('domains');
        $db = get_module_db('domains');
Severity: Major
Found in src/Plugin.php - About 2 days to fix

    Function searchDomain has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function searchDomain($domain, $function)
        {
            $final = [];
            $tlds = get_available_domain_tlds_by_tld();
            $tldPrices = get_service_tld_pricing();
    Severity: Minor
    Found in src/OpenSRS.php - About 1 day 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

    File OpenSRS.php has 680 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * OpenSRS Domain Related Functionality
     * @author Joe Huss <detain@interserver.net>
     * @copyright 2019
    Severity: Major
    Found in src/OpenSRS.php - About 1 day to fix

      File Plugin.php has 623 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Detain\MyAdminOpenSRS;
      
      use Detain\MyAdminOpenSRS\OpenSRS;
      Severity: Major
      Found in src/Plugin.php - About 1 day to fix

        Function listDomainsByExpireyDate has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function listDomainsByExpireyDate($startDate = false, $endDate = false)
            {
                if ($startDate == false) {
                    $startDate = date('Y-m-d', strtotime(date('Y').'-01-01 +45 days'));
                }
        Severity: Minor
        Found in src/OpenSRS.php - About 1 day 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 getEventTypes has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getEventTypes()
            {
                return [
                    'types' => [
                        'domain' => [
        Severity: Major
        Found in src/OpenSRS.php - About 3 hrs to fix

          Method xmlRequest has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function xmlRequest($action, $object, $options, $extra = null)
              {
                  $username = OPENSRS_USERNAME;
                  $privateKey = OPENSRS_KEY;
                  $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
          Severity: Major
          Found in src/OpenSRS.php - About 3 hrs to fix

            Method searchDomain has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function searchDomain($domain, $function)
                {
                    $final = [];
                    $tlds = get_available_domain_tlds_by_tld();
                    $tldPrices = get_service_tld_pricing();
            Severity: Major
            Found in src/OpenSRS.php - About 2 hrs to fix

              OpenSRS has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class OpenSRS
              {
                  public $id;
                  public $cookie;
                  public $osrsHandlerAllInfo;
              Severity: Minor
              Found in src/OpenSRS.php - About 2 hrs to fix

                Method loadDomainInfo has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function loadDomainInfo()
                    {
                        $callstring = [
                            'func' => 'lookupGetDomain',
                            'attributes' => [
                Severity: Major
                Found in src/OpenSRS.php - About 2 hrs to fix

                  Function xmlRequest has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function xmlRequest($action, $object, $options, $extra = null)
                      {
                          $username = OPENSRS_USERNAME;
                          $privateKey = OPENSRS_KEY;
                          $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
                  Severity: Minor
                  Found in src/OpenSRS.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 listDomainsByExpireyDate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function listDomainsByExpireyDate($startDate = false, $endDate = false)
                      {
                          if ($startDate == false) {
                              $startDate = date('Y-m-d', strtotime(date('Y').'-01-01 +45 days'));
                          }
                  Severity: Major
                  Found in src/OpenSRS.php - About 2 hrs to fix

                    Avoid excessively long variable names like $osrsHandlerWhoisPrivacy. Keep variable name length under 20.
                    Open

                        public $osrsHandlerWhoisPrivacy;
                    Severity: Minor
                    Found in src/OpenSRS.php by phpmd

                    LongVariable

                    Since: 0.2

                    Detects when a field, formal or local variable is declared with a long name.

                    Example

                    class Something {
                        protected $reallyLongIntName = -3; // VIOLATION - Field
                        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                            $otherReallyLongName = -5; // VIOLATION - Local
                            for ($interestingIntIndex = 0; // VIOLATION - For
                                 $interestingIntIndex < 10;
                                 $interestingIntIndex++ ) {
                            }
                        }
                    }

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

                    The class OpenSRS has 17 fields. Consider redesigning OpenSRS to keep the number of fields under 15.
                    Open

                    class OpenSRS
                    {
                        public $id;
                        public $cookie;
                        public $osrsHandlerAllInfo;
                    Severity: Minor
                    Found in src/OpenSRS.php by phpmd

                    TooManyFields

                    Since: 0.1

                    Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

                    Example

                    class Person {
                       protected $one;
                       private $two;
                       private $three;
                       [... many more fields ...]
                    }

                    Source https://phpmd.org/rules/codesize.html#toomanyfields

                    Function checkDomainAvailable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function checkDomainAvailable($domain)
                        {
                            $result = self::lookupDomain($domain);
                            if ($result === false) {
                                return false;
                    Severity: Minor
                    Found in src/OpenSRS.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 request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function request($callstring)
                        {
                            if (is_string($callstring)) {
                                $callstring = json_decode($callstring, true);
                                $action = $callstring['func'];
                    Severity: Minor
                    Found in src/OpenSRS.php - About 1 hr to fix

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

                                          myadmin_log('domains', 'error', 'This Line `'.$xml[$error->line - 1].'` gave a '.$levels[$error->level].' #'.$error->code.' `'.$error->message.'` at Line '.$error->line.' Column '.$error->column.' File '.$error->file, __LINE__, __FILE__, self::$module);
                      Severity: Minor
                      Found in src/OpenSRS.php by phpmd

                      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

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

                          public static function request($callstring)
                          {
                              if (is_string($callstring)) {
                                  $callstring = json_decode($callstring, true);
                                  $action = $callstring['func'];
                      Severity: Minor
                      Found in src/OpenSRS.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

                      The property $error_levels is not named in camelCase.
                      Open

                      class OpenSRS
                      {
                          public $id;
                          public $cookie;
                          public $osrsHandlerAllInfo;
                      Severity: Minor
                      Found in src/OpenSRS.php by phpmd

                      CamelCasePropertyName

                      Since: 0.2

                      It is considered best practice to use the camelCase notation to name attributes.

                      Example

                      class ClassName {
                          protected $property_name;
                      }

                      Source

                      Severity
                      Category
                      Status
                      Source
                      Language