steeffeen/FancyManiaLinks

View on GitHub
FML/Controls/Control.php

Summary

Maintainability
D
2 days
Test Coverage
A
100%

Control has 68 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Control implements Identifiable, Renderable, ScriptFeatureable
{

    /*
     * Constants
Severity: Major
Found in FML/Controls/Control.php - About 1 day to fix

    File Control.php has 420 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace FML\Controls;
    
    use FML\Script\Features\ActionTrigger;
    Severity: Minor
    Found in FML/Controls/Control.php - About 6 hrs to fix

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

      abstract class Control implements Identifiable, Renderable, ScriptFeatureable
      {
      
          /*
           * Constants
      Severity: Minor
      Found in FML/Controls/Control.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 Control has 29 public methods. Consider refactoring Control to keep number of public methods under 10.
      Open

      abstract class Control implements Identifiable, Renderable, ScriptFeatureable
      {
      
          /*
           * Constants
      Severity: Minor
      Found in FML/Controls/Control.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

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

      abstract class Control implements Identifiable, Renderable, ScriptFeatureable
      {
      
          /*
           * Constants
      Severity: Minor
      Found in FML/Controls/Control.php by phpmd

      Function render has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function render(\DOMDocument $domDocument)
          {
              $domElement = $domDocument->createElement($this->getTagName());
              if ($this->controlId) {
                  $domElement->setAttribute("id", $this->controlId);
      Severity: Minor
      Found in FML/Controls/Control.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 render has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function render(\DOMDocument $domDocument)
          {
              $domElement = $domDocument->createElement($this->getTagName());
              if ($this->controlId) {
                  $domElement->setAttribute("id", $this->controlId);
      Severity: Minor
      Found in FML/Controls/Control.php - About 1 hr to fix

        The class Control has 16 fields. Consider redesigning Control to keep the number of fields under 15.
        Open

        abstract class Control implements Identifiable, Renderable, ScriptFeatureable
        {
        
            /*
             * Constants
        Severity: Minor
        Found in FML/Controls/Control.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

        The class Control has 68 public methods and attributes. Consider reducing the number of public items to less than 45.
        Open

        abstract class Control implements Identifiable, Renderable, ScriptFeatureable
        {
        
            /*
             * Constants
        Severity: Minor
        Found in FML/Controls/Control.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 render() has an NPath complexity of 36864. The configured NPath complexity threshold is 200.
        Open

            public function render(\DOMDocument $domDocument)
            {
                $domElement = $domDocument->createElement($this->getTagName());
                if ($this->controlId) {
                    $domElement->setAttribute("id", $this->controlId);
        Severity: Minor
        Found in FML/Controls/Control.php by phpmd

        NPathComplexity

        Since: 0.1

        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

        Example

        class Foo {
            function bar() {
                // lots of complicated code
            }
        }

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

        The method render() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
        Open

            public function render(\DOMDocument $domDocument)
            {
                $domElement = $domDocument->createElement($this->getTagName());
                if ($this->controlId) {
                    $domElement->setAttribute("id", $this->controlId);
        Severity: Minor
        Found in FML/Controls/Control.php by phpmd

        CyclomaticComplexity

        Since: 0.1

        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

        Example

        // Cyclomatic Complexity = 11
        class Foo {
        1   public function example() {
        2       if ($a == $b) {
        3           if ($a1 == $b1) {
                        fiddle();
        4           } elseif ($a2 == $b2) {
                        fiddle();
                    } else {
                        fiddle();
                    }
        5       } elseif ($c == $d) {
        6           while ($c == $d) {
                        fiddle();
                    }
        7        } elseif ($e == $f) {
        8           for ($n = 0; $n < $h; $n++) {
                        fiddle();
                    }
                } else {
                    switch ($z) {
        9               case 1:
                            fiddle();
                            break;
        10              case 2:
                            fiddle();
                            break;
        11              case 3:
                            fiddle();
                            break;
                        default:
                            fiddle();
                            break;
                    }
                }
            }
        }

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

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

            public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false)
        Severity: Minor
        Found in FML/Controls/Control.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 '1001', column '28').
        Open

                $domDocument = new \DOMDocument("1.0", "utf-8");
        Severity: Minor
        Found in FML/Controls/Control.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 addToggleFeature has a boolean flag argument $onlyHide, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false)
        Severity: Minor
        Found in FML/Controls/Control.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 addToggleFeature has a boolean flag argument $onlyShow, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false)
        Severity: Minor
        Found in FML/Controls/Control.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 addTooltipLabelFeature has a boolean flag argument $stayOnClick, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function addTooltipLabelFeature(Label $tooltipLabel, $text, $stayOnClick = false, $invert = false)
        Severity: Minor
        Found in FML/Controls/Control.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 addTooltipFeature has a boolean flag argument $invert, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function addTooltipFeature(Control $tooltipControl, $stayOnClick = false, $invert = false)
        Severity: Minor
        Found in FML/Controls/Control.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 addTooltipLabelFeature has a boolean flag argument $invert, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function addTooltipLabelFeature(Label $tooltipLabel, $text, $stayOnClick = false, $invert = false)
        Severity: Minor
        Found in FML/Controls/Control.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

        Avoid using static access to class '\FML\UniqueID' in method 'checkId'.
        Open

                return UniqueID::check($this);
        Severity: Minor
        Found in FML/Controls/Control.php by phpmd

        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 excessively long variable names like $defaultHorizontalAlign. Keep variable name length under 20.
        Open

            static protected $defaultHorizontalAlign = self::CENTER;
        Severity: Minor
        Found in FML/Controls/Control.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 $defaultHorizontalAlignment. Keep variable name length under 20.
        Open

            public static function setDefaultHorizontalAlign($defaultHorizontalAlignment)
        Severity: Minor
        Found in FML/Controls/Control.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 $defaultVerticalAlignment. Keep variable name length under 20.
        Open

            public static function setDefaultVerticalAlign($defaultVerticalAlignment)
        Severity: Minor
        Found in FML/Controls/Control.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 closing brace for the class must go on the next line after the body
        Open

        }
        Severity: Minor
        Found in FML/Controls/Control.php by phpcodesniffer

        The 'getVisible()' method which returns a boolean should be named 'is...()' or 'has...()'
        Open

            public function getVisible()
            {
                return $this->visible;
            }
        Severity: Minor
        Found in FML/Controls/Control.php by phpmd

        BooleanGetMethodName

        Since: 0.2

        Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

        Example

        class Foo {
            /**
             * @return boolean
             */
            public function getFoo() {} // bad
            /**
             * @return bool
             */
            public function isFoo(); // ok
            /**
             * @return boolean
             */
            public function getFoo($bar); // ok, unless checkParameterizedMethods=true
        }

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

        Line exceeds 120 characters; contains 137 characters
        Open

            public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false)
        Severity: Minor
        Found in FML/Controls/Control.php by phpcodesniffer

        There are no issues that match your filters.

        Category
        Status