steeffeen/FancyManiaLinks

View on GitHub
FML/Script/Features/Paging.php

Summary

Maintainability
C
1 day
Test Coverage
F
44%

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

class Paging extends ScriptFeature
{

    /*
     * Constants
Severity: Minor
Found in FML/Script/Features/Paging.php by phpmd

Paging has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class Paging extends ScriptFeature
{

    /*
     * Constants
Severity: Minor
Found in FML/Script/Features/Paging.php - About 3 hrs to fix

    Method prepare has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function prepare(Script $script)
        {
            if (empty($this->pages)) {
                return $this;
            }
    Severity: Major
    Found in FML/Script/Features/Paging.php - About 2 hrs to fix

      File Paging.php has 278 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

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

        Avoid using static access to class '\FML\Script\Builder' in method 'prepare'.
        Open

                $pagingId    = Builder::escapeText($maxPage->getControl()
                                                           ->getId());
        Severity: Minor
        Found in FML/Script/Features/Paging.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 using static access to class '\FML\Script\Builder' in method 'prepare'.
        Open

                $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
        Severity: Minor
        Found in FML/Script/Features/Paging.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 using static access to class '\FML\Script\Builder' in method 'prepare'.
        Open

                $nextChunkAction              = Builder::escapeText($this->nextChunkAction);
        Severity: Minor
        Found in FML/Script/Features/Paging.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 using static access to class '\FML\Script\Builder' in method 'prepare'.
        Open

                    $pageLabelId = Builder::escapeText($this->label->getId());
        Severity: Minor
        Found in FML/Script/Features/Paging.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

        The method addButtonControl uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        $browseAction = $buttonCount / -2 - 1;
                    }
        Severity: Minor
        Found in FML/Script/Features/Paging.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

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

        Avoid using static access to class '\FML\Script\Builder' in method 'getPagesArrayText'.
        Open

                    return Builder::getArray(array(0 => ''), true);
        Severity: Minor
        Found in FML/Script/Features/Paging.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 using static access to class '\FML\Script\Builder' in method 'prepare'.
        Open

                $previousChunkAction          = Builder::escapeText($this->previousChunkAction);
        Severity: Minor
        Found in FML/Script/Features/Paging.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 using static access to class '\FML\Script\Builder' in method 'getPagesArrayText'.
        Open

                return Builder::getArray($pages, true);
        Severity: Minor
        Found in FML/Script/Features/Paging.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 using static access to class '\FML\Script\Builder' in method 'getPageButtonsArrayText'.
        Open

                return Builder::getArray($pageButtons, true);
        Severity: Minor
        Found in FML/Script/Features/Paging.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 using static access to class '\FML\Script\Builder' in method 'getPageButtonsArrayText'.
        Open

                    return Builder::getArray(array('' => 0), true);
        Severity: Minor
        Found in FML/Script/Features/Paging.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 $chunkActionAppendsPageNumber. Keep variable name length under 20.
        Open

            protected $chunkActionAppendsPageNumber = null;
        Severity: Minor
        Found in FML/Script/Features/Paging.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 $chunkActionAppendsPageNumber. Keep variable name length under 20.
        Open

                $chunkActionAppendsPageNumber = Builder::getBoolean($this->chunkActionAppendsPageNumber);
        Severity: Minor
        Found in FML/Script/Features/Paging.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

        }

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

            public function getChunkActionAppendsPageNumber()
            {
                return $this->chunkActionAppendsPageNumber;
            }
        Severity: Minor
        Found in FML/Script/Features/Paging.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 188 characters
        Open

        {$updatePageFunction}({$pagingId}, {$pageLabelId}, 0, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});";

        Line exceeds 120 characters; contains 201 characters
        Open

            {$updatePageFunction}({$pagingId}, {$pageLabelId}, BrowseAction, {$minPageNumber}, {$maxPageNumber}, {$pagesArrayText}, {$previousChunkAction}, {$nextChunkAction}, {$chunkActionAppendsPageNumber});

        Line exceeds 120 characters; contains 244 characters
        Open

        Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAction, Integer _MinPageNumber, Integer _MaxPageNumber, Text[Integer] _Pages, Text _PreviousChunkAction, Text _NextChunkAction, Boolean _ChunkActionAppendPageNumber) {

        There are no issues that match your filters.

        Category
        Status