hnhdigital-os/php-virtualmin-api

View on GitHub

Showing 137 of 137 total issues

VirtualServersClient has 63 functions (exceeds 20 allowed). Consider refactoring.
Open

class VirtualServersClient extends VirtualminClient
{

    /**
     * Clone Domain.
Severity: Major
Found in src/VirtualServersClient.php - About 1 day to fix

    File VirtualServersClient.php has 508 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace HnhDigital\Virtualmin;
    
    class VirtualServersClient extends VirtualminClient
    Severity: Major
    Found in src/VirtualServersClient.php - About 1 day to fix

      The class VirtualServersClient has an overall complexity of 120 which is very high. The configured complexity threshold is 50.
      Open

      class VirtualServersClient extends VirtualminClient
      {
      
          /**
           * Clone Domain.
      Severity: Minor
      Found in src/VirtualServersClient.php by phpmd

      The class VirtualServersClient has 63 non-getter- and setter-methods. Consider refactoring VirtualServersClient to keep number of methods under 25.
      Open

      class VirtualServersClient extends VirtualminClient
      {
      
          /**
           * Clone Domain.
      Severity: Minor
      Found in src/VirtualServersClient.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

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

      The class VirtualServersClient has 63 public methods. Consider refactoring VirtualServersClient to keep number of public methods under 10.
      Open

      class VirtualServersClient extends VirtualminClient
      {
      
          /**
           * Clone Domain.
      Severity: Minor
      Found in src/VirtualServersClient.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

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

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

          public function create($domain, $password, array $options = [])
          {
              $parameters = [];
              $parameters['domain'] = $domain;
              $parameters['pass'] = $password;
      Severity: Major
      Found in src/VirtualServersClient.php and 1 other location - About 2 hrs to fix
      src/VirtualServersClient.php on lines 169..188

      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 131.

      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

          public function createAlias($parent_domain, $domain, array $options = [])
          {
              $parameters = [];
              $parameters['alias'] = $parent_domain;
              $parameters['domain'] = $domain;
      Severity: Major
      Found in src/VirtualServersClient.php and 1 other location - About 2 hrs to fix
      src/VirtualServersClient.php on lines 106..125

      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 131.

      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

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

          private $create_domain_options = [
              'desc',
              'email',
              'user',
              'group',
      Severity: Minor
      Found in src/VirtualServersClient.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

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

          private $create_domain_option_defaults = [
              'quota' => 'UNLIMITED',
              'uquota' => 'UNLIMITED',
          ];
      Severity: Minor
      Found in src/VirtualServersClient.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

      Method call has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function call($program, $parameters = [])
          {
              $url = sprintf('%s://%s:%s/virtual-server/remote.cgi?program=%s&json=1', $this->mode, $this->server, $this->port, $program);
      
              foreach ($parameters as $key => &$value) {
      Severity: Minor
      Found in src/VirtualminClient.php - About 1 hr to fix

        Avoid using short method names like ServerClient::ip(). The configured minimum method name length is 3.
        Open

            public function ip()
            {
                $parameters = [];
                $parameters['name-only'] = true;
        
        
        Severity: Minor
        Found in src/ServerClient.php by phpmd

        ShortMethodName

        Since: 0.2

        Detects when very short method names are used.

        Example

        class ShortMethod {
            public function a( $index ) { // Violation
            }
        }

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

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

            protected function call($program, $parameters = [])
            {
                $url = sprintf('%s://%s:%s/virtual-server/remote.cgi?program=%s&json=1', $this->mode, $this->server, $this->port, $program);
        
                foreach ($parameters as $key => &$value) {
        Severity: Minor
        Found in src/VirtualminClient.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 class VirtualServersClient has 63 public methods and attributes. Consider reducing the number of public items to less than 45.
        Open

        class VirtualServersClient extends VirtualminClient
        {
        
            /**
             * Clone Domain.
        Severity: Minor
        Found in src/VirtualServersClient.php by phpmd

        ExcessivePublicCount

        Since: 0.1

        A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

        Example

        public class Foo {
            public $value;
            public $something;
            public $var;
            // [... more more public attributes ...]
        
            public function doWork() {}
            public function doMoreWork() {}
            public function doWorkAgain() {}
            // [... more more public methods ...]
        }

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

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

            public function disableAwstats($domain = false, $user = false)
        Severity: Minor
        Found in src/VirtualServersClient.php by phpmd

        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

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

            public function disableDav($domain = false, $user = false)
        Severity: Minor
        Found in src/VirtualServersClient.php by phpmd

        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

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

            public function enableVirus($domain = false, $user = false)
        Severity: Minor
        Found in src/VirtualServersClient.php by phpmd

        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

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

                    throw new \Exception($result['error']);
        Severity: Minor
        Found in src/VirtualminClient.php by phpmd

        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

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

            public function disableMail($domain = false, $user = false)
        Severity: Minor
        Found in src/VirtualServersClient.php by phpmd

        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

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

            public function disableSpam($domain = false, $user = false)
        Severity: Minor
        Found in src/VirtualServersClient.php by phpmd

        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

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

            public function enableUnix($domain = false, $user = false)
        Severity: Minor
        Found in src/VirtualServersClient.php by phpmd

        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