ImpressCMS/impresscms

View on GitHub
htdocs/install/class/textsanitizer.php

Summary

Maintainability
A
3 hrs
Test Coverage

TextSanitizer has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class TextSanitizer {

    /*
     * Constructor of this class
     * Gets allowed html tags from admin config settings
Severity: Minor
Found in htdocs/install/class/textsanitizer.php - About 3 hrs to fix

    The class TextSanitizer has 27 public methods. Consider refactoring TextSanitizer to keep number of public methods under 10.
    Open

    class TextSanitizer {
    
        /*
         * Constructor of this class
         * Gets allowed html tags from admin config settings

    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 TextSanitizer has 27 non-getter- and setter-methods. Consider refactoring TextSanitizer to keep number of methods under 25.
    Open

    class TextSanitizer {
    
        /*
         * Constructor of this class
         * Gets allowed html tags from admin config settings

    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

    Missing class import via use statement (line '55', column '20').
    Open

                $instance = new TextSanitizer();

    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 previewText has a boolean flag argument $html, which is a certain sign of a Single Responsibility Principle violation.
    Open

        function &previewText($text, $html = false) {

    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 displayText has a boolean flag argument $html, which is a certain sign of a Single Responsibility Principle violation.
    Open

        function &displayText($text, $html = false) {

    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 addSlashes has a boolean flag argument $force, which is a certain sign of a Single Responsibility Principle violation.
    Open

        function addSlashes($text, $force = false) {

    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 sanitizeForDisplay uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $text = $this->makeClickable($text);
            }

    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

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

            } else {
                $text = $this->makeClickable($text);
            }

    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 unused parameters such as '$smiley'.
    Open

        function makeTboxData4Preview($text, $smiley = 0) {

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid unused parameters such as '$smiley'.
    Open

        function makeTboxData4Show($text, $smiley = 0) {

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid unused parameters such as '$force'.
    Open

        function addSlashes($text, $force = false) {

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Call to undeclared method \TextSanitizer::xoopsCodeDecode
    Open

                $text = $this->xoopsCodeDecode($text);
    Severity: Critical
    Found in htdocs/install/class/textsanitizer.php by phan

    Call to undeclared method \TextSanitizer::displayTarea
    Open

            return $this->displayTarea($text, $html, $smiley, $xcode);
    Severity: Critical
    Found in htdocs/install/class/textsanitizer.php by phan

    Call to undeclared method \TextSanitizer::xoopsCodeDecode
    Open

                $text = $this->xoopsCodeDecode($text);
    Severity: Critical
    Found in htdocs/install/class/textsanitizer.php by phan

    Call to undeclared method \TextSanitizer::smiley
    Open

                $text = $this->smiley($text);
    Severity: Critical
    Found in htdocs/install/class/textsanitizer.php by phan

    Call to undeclared method \TextSanitizer::previewTarea
    Open

            return $this->previewTarea($text, $html, $smiley, $xcode);
    Severity: Critical
    Found in htdocs/install/class/textsanitizer.php by phan

    Call to undeclared method \TextSanitizer::smiley
    Open

                $text = $this->smiley($text);
    Severity: Critical
    Found in htdocs/install/class/textsanitizer.php by phan

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class TextSanitizer {

    Visibility must be declared on method "__construct"
    Open

        function __construct() {}

    Visibility must be declared on method "makeTareaData4Edit"
    Open

        function makeTareaData4Edit($text) {

    Visibility must be declared on method "oopsStripSlashesGPC"
    Open

        function &oopsStripSlashesGPC($text) {

    Visibility must be declared on method "sanitizeForPreview"
    Open

        function sanitizeForPreview($text, $allowhtml = 0, $smiley = 1, $bbcode = 1) {

    Visibility must be declared on method "makeTboxData4Preview"
    Open

        function makeTboxData4Preview($text, $smiley = 0) {

    Visibility must be declared on method "makeTboxData4PreviewInForm"
    Open

        function makeTboxData4PreviewInForm($text) {

    Visibility must be declared on method "stripSlashesGPC"
    Open

        function stripSlashesGPC($text) {

    Visibility must be declared on method "sanitizeForDisplay"
    Open

        function sanitizeForDisplay($text, $allowhtml = 0, $smiley = 1, $bbcode = 1) {

    Visibility must be declared on method "makeTareaData4InsideQuotes"
    Open

        function makeTareaData4InsideQuotes($text) {

    Visibility must be declared on method "oopsNl2Br"
    Open

        function &oopsNl2Br($text) {

    Visibility must be declared on method "makeTboxData4Save"
    Open

        function makeTboxData4Save($text) {

    Visibility must be declared on method "makeTboxData4Show"
    Open

        function makeTboxData4Show($text, $smiley = 0) {

    Visibility must be declared on method "makeTareaData4Show"
    Open

        function &makeTareaData4Show(&$text, $html = 1, $smiley = 1, $xcode = 1) {

    Visibility must be declared on method "makeTareaData4PreviewInForm"
    Open

        function makeTareaData4PreviewInForm($text) {

    Visibility must be declared on method "oopsHtmlSpecialChars"
    Open

        function &oopsHtmlSpecialChars($text) {

    Visibility must be declared on method "makeClickable"
    Open

        function &makeClickable(&$text) {

    Visibility must be declared on method "htmlSpecialChars"
    Open

        function htmlSpecialChars($text) {

    Visibility must be declared on method "getInstance"
    Open

        function &getInstance() {

    Visibility must be declared on method "makeTareaData4Save"
    Open

        function makeTareaData4Save($text) {

    Visibility must be declared on method "oopsStripSlashesRT"
    Open

        function &oopsStripSlashesRT($text) {

    Visibility must be declared on method "nl2Br"
    Open

        function &nl2Br($text) {

    Visibility must be declared on method "oopsAddSlashes"
    Open

        function &oopsAddSlashes($text) {

    Visibility must be declared on method "undoHtmlSpecialChars"
    Open

        function undoHtmlSpecialChars(&$text) {

    Visibility must be declared on method "addSlashes"
    Open

        function addSlashes($text, $force = false) {

    Visibility must be declared on method "displayText"
    Open

        function &displayText($text, $html = false) {

    Visibility must be declared on method "previewText"
    Open

        function &previewText($text, $html = false) {

    Visibility must be declared on method "makeTareaData4Preview"
    Open

        function &makeTareaData4Preview(&$text, $html = 1, $smiley = 1, $xcode = 1) {

    Visibility must be declared on method "makeTboxData4Edit"
    Open

        function makeTboxData4Edit($text) {

    Closing brace must be on a line by itself
    Open

        function __construct() {}

    There are no issues that match your filters.

    Category
    Status