ImpressCMS/impresscms

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

Summary

Maintainability
D
2 days
Test Coverage

Function queryFromFile has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
Open

    public function queryFromFile($sql_file_path) {
        $tables = array();

        if (!file_exists($sql_file_path)) {
            return false;
Severity: Minor
Found in htdocs/install/class/dbmanager.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 queryFromFile has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function queryFromFile($sql_file_path) {
        $tables = array();

        if (!file_exists($sql_file_path)) {
            return false;
Severity: Major
Found in htdocs/install/class/dbmanager.php - About 2 hrs to fix

    Function report has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function report() {
            $commands = array( 'create', 'insert', 'alter', 'drop' );
            $content = '<ul class="log">';
            foreach ( $commands as $cmd) {
                if (!@empty( $this->s_tables[$cmd] )) {
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

    Function insert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function insert($table, $query) {
            $this->db->connect();
            $table = $this->db->prefix($table);
            $query = 'INSERT INTO '.$table.' '.$query;
            if (!$this->db->queryF($query)) {
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php - About 45 mins 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 method queryFromFile() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

    Remove error control operator '@' on line 148.
    Open

        public function report() {
            $commands = array( 'create', 'insert', 'alter', 'drop' );
            $content = '<ul class="log">';
            foreach ( $commands as $cmd) {
                if (!@empty( $this->s_tables[$cmd] )) {
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 157.
    Open

        public function report() {
            $commands = array( 'create', 'insert', 'alter', 'drop' );
            $content = '<ul class="log">';
            foreach ( $commands as $cmd) {
                if (!@empty( $this->s_tables[$cmd] )) {
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Avoid using static access to class 'icms_core_Logger' in method '__construct'.
    Open

            $this->db->setLogger(icms_core_Logger::instance());
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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 insert uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $this->f_tables['insert'][$table]++;
                }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

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

            } else {
                if (!isset($this->s_tables['insert'][$table])) {
                    $this->s_tables['insert'][$table] = $this->db->getAffectedRows();
                } else {
                    $this->s_tables['insert'][$table] += $this->db->getAffectedRows();
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

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

                            } else {
                                $this->s_tables['insert'][$table] += $this->db->getAffectedRows();
                            }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

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

                        } else {
                            if (! isset($this->f_tables['insert'][$table])) {
                                $this->f_tables['insert'][$table] = 1;
                            } else {
                                $this->f_tables['insert'][$table]++;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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 'icms_db_legacy_mysql_Utility' in method 'queryFromFile'.
    Open

            icms_db_legacy_mysql_Utility::splitSqlFile($pieces, $sql_query);
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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 insert uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $this->s_tables['insert'][$table] += $this->db->getAffectedRows();
                }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

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

                        } else {
                            if (! isset($this->s_tables['alter'][$table])) {
                                $this->f_tables['alter'][$table] = 1;
                            }
                        }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

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

                        } else {
                            if (! isset($this->f_tables['create'][$table])) {
                                $this->f_tables['create'][$table] = 1;
                            }
                        }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

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

                        } else {
                            if (! isset($this->s_tables['drop'][$table])) {
                                $this->f_tables['drop'][$table] = 1;
                            }
                        }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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 'icms_db_legacy_Factory' in method '__construct'.
    Open

            $this->db = icms_db_legacy_Factory::getDatabase();
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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 queryFromFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                            } else {
                                $this->f_tables['insert'][$table]++;
                            }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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 'icms_db_legacy_mysql_Utility' in method 'queryFromFile'.
    Open

                $prefixed_query = icms_db_legacy_mysql_Utility::prefixQuery($piece, $this->db->prefix());
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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 unused local variables such as '$tables'.
    Open

            $tables = array();
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

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

    Variable $pieces is undeclared (Did you mean $piece)
    Open

            foreach ($pieces as $piece) {
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phan

    Call to method instance from undeclared class \icms_core_Logger
    Open

            $this->db->setLogger(icms_core_Logger::instance());
    Severity: Critical
    Found in htdocs/install/class/dbmanager.php by phan

    Call to method getDatabase from undeclared class \icms_db_legacy_Factory
    Open

            $this->db = icms_db_legacy_Factory::getDatabase();
    Severity: Critical
    Found in htdocs/install/class/dbmanager.php by phan

    Call to method splitSqlFile from undeclared class \icms_db_legacy_mysql_Utility
    Open

            icms_db_legacy_mysql_Utility::splitSqlFile($pieces, $sql_query);
    Severity: Critical
    Found in htdocs/install/class/dbmanager.php by phan

    Call to method prefixQuery from undeclared class \icms_db_legacy_mysql_Utility
    Open

                $prefixed_query = icms_db_legacy_mysql_Utility::prefixQuery($piece, $this->db->prefix());
    Severity: Critical
    Found in htdocs/install/class/dbmanager.php by phan

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

            foreach ( $commands as $cmd) {
                if (!@empty( $this->f_tables[$cmd] )) {
                    foreach ( $this->f_tables[$cmd] as $key => $val) {
                        $content .= '<li class="failure">';
                        $content .= ($cmd!='insert') ? sprintf( $this->failureStrings[$cmd], $key ) : sprintf( $this->failureStrings[$cmd], $val, $key );
    Severity: Major
    Found in htdocs/install/class/dbmanager.php and 1 other location - About 1 hr to fix
    htdocs/install/class/dbmanager.php on lines 147..155

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

    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

            foreach ( $commands as $cmd) {
                if (!@empty( $this->s_tables[$cmd] )) {
                    foreach ( $this->s_tables[$cmd] as $key => $val) {
                        $content .= '<li class="success">';
                        $content .= ($cmd!='insert') ? sprintf( $this->successStrings[$cmd], $key ) : sprintf( $this->successStrings[$cmd], $val, $key );
    Severity: Major
    Found in htdocs/install/class/dbmanager.php and 1 other location - About 1 hr to fix
    htdocs/install/class/dbmanager.php on lines 156..164

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

    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

                    } elseif ($prefixed_query[1] == 'ALTER TABLE') {
                        if ($this->db->query($prefixed_query[0]) != false) {
                            if (! isset($this->s_tables['alter'][$table])) {
                                $this->s_tables['alter'][$table] = 1;
                            }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php and 1 other location - About 1 hr to fix
    htdocs/install/class/dbmanager.php on lines 79..124

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

    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

                    if ($prefixed_query[1] === 'CREATE TABLE') {
                        if ($this->db->query($prefixed_query[0]) != false) {
                            if (! isset($this->s_tables['create'][$table])) {
                                $this->s_tables['create'][$table] = 1;
                            }
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php and 1 other location - About 1 hr to fix
    htdocs/install/class/dbmanager.php on lines 104..114

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

    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

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

    class db_manager {

    The property $f_tables is not named in camelCase.
    Open

    class db_manager {
    
        public $s_tables = array();
        public $f_tables = array();
        public $db;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

    The class db_manager is not named in CamelCase.
    Open

    class db_manager {
    
        public $s_tables = array();
        public $f_tables = array();
        public $db;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

        public $db;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

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

    The property $s_tables is not named in camelCase.
    Open

    class db_manager {
    
        public $s_tables = array();
        public $f_tables = array();
        public $db;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.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

    The parameter $sql_file_path is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'create'    => TABLE_CREATED,

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'alter'        => TABLE_NOT_ALTERED,

    Space found after opening bracket of FOREACH loop
    Open

            foreach ( $commands as $cmd) {

    Space found after opening bracket of FOREACH loop
    Open

                    foreach ( $this->s_tables[$cmd] as $key => $val) {

    Space found after opening bracket of FOREACH loop
    Open

            foreach ( $commands as $cmd) {

    Space found after opening bracket of FOREACH loop
    Open

                    foreach ( $this->f_tables[$cmd] as $key => $val) {

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'insert'    => ROWS_FAILED,

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'drop'        => TABLE_NOT_DROPPED,

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'insert'    => ROWS_INSERTED,

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'create'    => TABLE_NOT_CREATED,

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'alter'        => TABLE_ALTERED,

    Tabs must be used to indent lines; spaces are not allowed
    Open

            'drop'        => TABLE_DROPPED,

    Expected 0 spaces before closing bracket; 1 found
    Open

                if (!@empty( $this->s_tables[$cmd] )) {

    Expected 0 spaces before closing bracket; 1 found
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->successStrings[$cmd], $key ) : sprintf( $this->successStrings[$cmd], $val, $key );

    Expected 0 spaces after opening bracket; 1 found
    Open

            foreach ( $commands as $cmd) {

    Expected 0 spaces before closing bracket; 1 found
    Open

                if (!@empty( $this->f_tables[$cmd] )) {

    Space after opening parenthesis of function call prohibited
    Open

                if (!@empty( $this->s_tables[$cmd] )) {

    Space after opening parenthesis of function call prohibited
    Open

                if (!@empty( $this->f_tables[$cmd] )) {

    Expected 0 spaces before closing bracket; 1 found
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->failureStrings[$cmd], $key ) : sprintf( $this->failureStrings[$cmd], $val, $key );

    Expected 0 spaces after opening bracket; 1 found
    Open

                    foreach ( $this->s_tables[$cmd] as $key => $val) {

    Space after opening parenthesis of function call prohibited
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->failureStrings[$cmd], $key ) : sprintf( $this->failureStrings[$cmd], $val, $key );

    Expected 0 spaces before closing bracket; 1 found
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->failureStrings[$cmd], $key ) : sprintf( $this->failureStrings[$cmd], $val, $key );

    Space after opening parenthesis of function call prohibited
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->successStrings[$cmd], $key ) : sprintf( $this->successStrings[$cmd], $val, $key );

    Expected 1 space after closing brace; newline found
    Open

                    }

    Expected 0 spaces after opening bracket; 1 found
    Open

            foreach ( $commands as $cmd) {

    Expected 0 spaces before closing bracket; 1 found
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->successStrings[$cmd], $key ) : sprintf( $this->successStrings[$cmd], $val, $key );

    Class name "db_manager" is not in camel caps format
    Open

    class db_manager {

    Expected 0 spaces after opening bracket; 1 found
    Open

                    foreach ( $this->f_tables[$cmd] as $key => $val) {

    Space after opening parenthesis of function call prohibited
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->successStrings[$cmd], $key ) : sprintf( $this->successStrings[$cmd], $val, $key );

    Space after opening parenthesis of function call prohibited
    Open

                        $content .= ($cmd!='insert') ? sprintf( $this->failureStrings[$cmd], $key ) : sprintf( $this->failureStrings[$cmd], $val, $key );

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $sql_file_path is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $sql_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $sql_file_path is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $sql_file_path is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $sql_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefixed_query is not named in camelCase.
    Open

        public function queryFromFile($sql_file_path) {
            $tables = array();
    
            if (!file_exists($sql_file_path)) {
                return false;
    Severity: Minor
    Found in htdocs/install/class/dbmanager.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    Unexpected spaces found.
    Open

            'alter'        => TABLE_ALTERED,

    Unexpected spaces found.
    Open

            'create'    => TABLE_CREATED,

    Unexpected spaces found.
    Open

            'insert'    => ROWS_FAILED,

    Unexpected spaces found.
    Open

            'insert'    => ROWS_INSERTED,

    Unexpected spaces found.
    Open

            'alter'        => TABLE_NOT_ALTERED,

    Unexpected spaces found.
    Open

            'drop'        => TABLE_NOT_DROPPED,

    Unexpected spaces found.
    Open

            'drop'        => TABLE_DROPPED,

    Unexpected spaces found.
    Open

            'create'    => TABLE_NOT_CREATED,

    There are no issues that match your filters.

    Category
    Status