detain/db_abstraction

View on GitHub
src/Adodb/Db.php

Summary

Maintainability
A
1 hr
Test Coverage

Method connect has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function connect($database = '', $host = '', $user = '', $password = '', $driver = 'mysql')
Severity: Minor
Found in src/Adodb/Db.php - About 35 mins to fix

    Function query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function query($queryString, $line = '', $file = '')
        {
            /* No empty queries, please, since PHP4 chokes on them. */
            /* The empty query string is passed on from the constructor,
            * when calling the class without a query, e.g. in situations
    Severity: Minor
    Found in src/Adodb/Db.php - About 35 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

    Function connect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function connect($database = '', $host = '', $user = '', $password = '', $driver = 'mysql')
        {
            /* Handle defaults */
            if ('' == $database) {
                $database = $this->database;
    Severity: Minor
    Found in src/Adodb/Db.php - About 25 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

    Avoid using undefined variables such as '$success' which will lead to PHP notices.
    Open

            $this->log("ADOdb Query $queryString (S:$success) - ".count($this->Rows).' Rows', __LINE__, __FILE__);
    Severity: Minor
    Found in src/Adodb/Db.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

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

        public function affectedRows()
        {
            return @$this->linkId->Affected_Rows();
            //            return @$this->queryId->rowCount();
        }
    Severity: Minor
    Found in src/Adodb/Db.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 unused local variables such as '$success'.
    Open

            $this->log("ADOdb Query $queryString (S:$success) - ".count($this->Rows).' Rows', __LINE__, __FILE__);
    Severity: Minor
    Found in src/Adodb/Db.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

    Avoid classes with short names like Db. Configured minimum length is 3.
    Open

    class Db extends Generic implements Db_Interface
    {
        public $driver = 'mysql';
        public $Rows = [];
        public $type = 'adodb';
    Severity: Minor
    Found in src/Adodb/Db.php by phpmd

    ShortClassName

    Since: 2.9

    Detects when classes or interfaces have a very short name.

    Example

    class Fo {
    
    }
    
    interface Fo {
    
    }

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

    The method real_escape is not named in camelCase.
    Open

        public function real_escape($string = '')
        {
            return escapeshellarg($string);
        }
    Severity: Minor
    Found in src/Adodb/Db.php by phpmd

    CamelCaseMethodName

    Since: 0.2

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

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method num_rows is not named in camelCase.
    Open

        public function num_rows()
        {
            return $this->queryId->NumRows();
        }
    Severity: Minor
    Found in src/Adodb/Db.php by phpmd

    CamelCaseMethodName

    Since: 0.2

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

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method num_fields is not named in camelCase.
    Open

        public function num_fields()
        {
            return $this->queryId->NumCols();
        }
    Severity: Minor
    Found in src/Adodb/Db.php by phpmd

    CamelCaseMethodName

    Since: 0.2

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

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method next_record is not named in camelCase.
    Open

        public function next_record($resultType = MYSQL_ASSOC)
        {
            if (!$this->queryId) {
                $this->halt('next_record called with no query pending.');
                return 0;
    Severity: Minor
    Found in src/Adodb/Db.php by phpmd

    CamelCaseMethodName

    Since: 0.2

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

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status