qcubed/framework

View on GitHub
includes/database/QSqlServerDatabase.class.php

Summary

Maintainability
F
1 wk
Test Coverage

Connect accesses the super-global variable $_SERVER.
Open

        public function Connect() {
      // Set several ini settings
      ini_set ( 'mssql.textlimit' , '65536' );
            ini_set ( 'mssql.textsize' , '65536' );
            ini_set ( 'mssql.charset' , 'utf-8' );

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Connect accesses the super-global variable $_SERVER.
Open

        public function Connect() {
      // Set several ini settings
      ini_set ( 'mssql.textlimit' , '65536' );
            ini_set ( 'mssql.textsize' , '65536' );
            ini_set ( 'mssql.charset' , 'utf-8' );

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

File QSqlServerDatabase.class.php has 550 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
    /**
     * Database Adapter for Microsoft SQL Server
     * Utilizes the Microsoft SQL Server extension php_mssql.dll (win) or the freetds extension (*nix)
     * 
Severity: Major
Found in includes/database/QSqlServerDatabase.class.php - About 1 day to fix

    Function SqlVariable has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                // Are we SqlVariabling a BOOLEAN value?
                if (is_bool($mixData)) {
                    // Yes
                    if ($blnIncludeEquality) {
    Severity: Minor
    Found in includes/database/QSqlServerDatabase.class.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

    Function __construct has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

            public function __construct($mixFieldData, $objDb = null) {
                $objDatabaseRow = null;
                try {
                    $objDatabaseRow = QType::Cast($mixFieldData, 'QSqlServerDatabaseRow');
                } catch (QInvalidCastException $objExc) {
    Severity: Minor
    Found in includes/database/QSqlServerDatabase.class.php - About 6 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 __construct has 144 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function __construct($mixFieldData, $objDb = null) {
                $objDatabaseRow = null;
                try {
                    $objDatabaseRow = QType::Cast($mixFieldData, 'QSqlServerDatabaseRow');
                } catch (QInvalidCastException $objExc) {
    Severity: Major
    Found in includes/database/QSqlServerDatabase.class.php - About 5 hrs to fix

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

          class QSqlServerDatabase extends QDatabaseBase {
              const Adapter = 'Microsoft SQL Server Database Adapter';
      
              protected $objMsSql;
      
      

      Method GetForeignKeysForTable has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function GetForeignKeysForTable($strTableName) {
                  $objForeignKeyArray = array();
                  
                  // Use Query to pull the FKs
                  $strQuery = sprintf('
      Severity: Major
      Found in includes/database/QSqlServerDatabase.class.php - About 2 hrs to fix

        Method SqlVariable has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                    // Are we SqlVariabling a BOOLEAN value?
                    if (is_bool($mixData)) {
                        // Yes
                        if ($blnIncludeEquality) {
        Severity: Minor
        Found in includes/database/QSqlServerDatabase.class.php - About 1 hr to fix

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

                  public function SqlLimitVariablePrefix($strLimitInfo) {
                      // Setup limit suffix (if applicable) via a TOP clause 
                      // Add QCUBED_OFFSET tag if applicable
          
                      if (strlen($strLimitInfo)) {
          Severity: Minor
          Found in includes/database/QSqlServerDatabase.class.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 GetForeignKeysForTable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function GetForeignKeysForTable($strTableName) {
                      $objForeignKeyArray = array();
                      
                      // Use Query to pull the FKs
                      $strQuery = sprintf('
          Severity: Minor
          Found in includes/database/QSqlServerDatabase.class.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

          Method Connect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function Connect() {
                // Set several ini settings
                ini_set ( 'mssql.textlimit' , '65536' );
                      ini_set ( 'mssql.textsize' , '65536' );
                      ini_set ( 'mssql.charset' , 'utf-8' );
          Severity: Minor
          Found in includes/database/QSqlServerDatabase.class.php - About 1 hr to fix

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

                    protected function ExecuteQuery($strQuery) {
                        // First, check for QCUBED_OFFSET<#> for LIMIT INFO Offseting
                        if ( ($intPosition = strpos($strQuery, 'QCUBED_OFFSET<')) !== false) {
                            $intEndPosition = strpos($strQuery, '>', $intPosition);
                            if ($intEndPosition === false)
            Severity: Minor
            Found in includes/database/QSqlServerDatabase.class.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

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

                    public function Connect() {
                  // Set several ini settings
                  ini_set ( 'mssql.textlimit' , '65536' );
                        ini_set ( 'mssql.textsize' , '65536' );
                        ini_set ( 'mssql.charset' , 'utf-8' );
            Severity: Minor
            Found in includes/database/QSqlServerDatabase.class.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

            Avoid too many return statements within this method.
            Open

                                return QType::Cast($strColumnValue, QType::Float);
            Severity: Major
            Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return $strToReturn . sprintf("'%s'", $mixData->qFormat(QDateTime::FormatIso));
              Severity: Major
              Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $strToReturn . 'NULL';
                Severity: Major
                Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                              return '= 0';
                  Severity: Major
                  Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $strToReturn . sprintf('%s', $mixData);
                    Severity: Major
                    Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                              return '0';
                      Severity: Major
                      Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                    return '!= 0';
                        Severity: Major
                        Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                  return 'NULL';
                          Severity: Major
                          Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return QType::Cast($strColumnValue, QType::Integer);
                            Severity: Major
                            Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return $strColumnValue;
                              Severity: Major
                              Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                        return '1';
                                Severity: Major
                                Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return $strToReturn . sprintf("'%s'", str_replace("'", "''", $mixData));
                                  Severity: Major
                                  Found in includes/database/QSqlServerDatabase.class.php - About 30 mins to fix

                                    The method __construct() has an NPath complexity of 35714. The configured NPath complexity threshold is 200.
                                    Open

                                            public function __construct($mixFieldData, $objDb = null) {
                                                $objDatabaseRow = null;
                                                try {
                                                    $objDatabaseRow = QType::Cast($mixFieldData, 'QSqlServerDatabaseRow');
                                                } catch (QInvalidCastException $objExc) {

                                    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 SqlVariable() has an NPath complexity of 600. The configured NPath complexity threshold is 200.
                                    Open

                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                                                // Are we SqlVariabling a BOOLEAN value?
                                                if (is_bool($mixData)) {
                                                    // Yes
                                                    if ($blnIncludeEquality) {

                                    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 __construct() has 170 lines of code. Current threshold is set to 100. Avoid really long methods.
                                    Open

                                            public function __construct($mixFieldData, $objDb = null) {
                                                $objDatabaseRow = null;
                                                try {
                                                    $objDatabaseRow = QType::Cast($mixFieldData, 'QSqlServerDatabaseRow');
                                                } catch (QInvalidCastException $objExc) {

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

                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                                                // Are we SqlVariabling a BOOLEAN value?
                                                if (is_bool($mixData)) {
                                                    // Yes
                                                    if ($blnIncludeEquality) {

                                    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 __construct() has a Cyclomatic Complexity of 44. The configured cyclomatic complexity threshold is 10.
                                    Open

                                            public function __construct($mixFieldData, $objDb = null) {
                                                $objDatabaseRow = null;
                                                try {
                                                    $objDatabaseRow = QType::Cast($mixFieldData, 'QSqlServerDatabaseRow');
                                                } catch (QInvalidCastException $objExc) {

                                    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 GetColumn() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                    Open

                                            public function GetColumn($strColumnName, $strColumnType = null) {
                                                if (!isset($this->strColumnArray[$strColumnName])) {
                                                    return null;
                                                }
                                                $strColumnValue = $this->strColumnArray[$strColumnName];

                                    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

                                    Missing class import via use statement (line '199', column '25').
                                    Open

                                                    $objException = new QSqlServerDatabaseException('Unable to connect to Database: ' . mssql_get_last_message(), -1, null);

                                    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

                                    Missing class import via use statement (line '452', column '26').
                                    Open

                                                    $objForeignKey = new QDatabaseForeignKey(

                                    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

                                    Missing class import via use statement (line '503', column '16').
                                    Open

                                                    return new QSqlServerDatabaseField($objField, $this->objDb);

                                    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

                                    Missing class import via use statement (line '126', column '16').
                                    Open

                                                        throw new Exception('Invalid Semicolon in LIMIT Info');

                                    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

                                    Missing class import via use statement (line '576', column '17').
                                    Open

                                                        return new QDateTime($strColumnValue);

                                    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

                                    Missing class import via use statement (line '205', column '25').
                                    Open

                                                    $objException = new QSqlServerDatabaseException('Unable to connect to Database: ' . mssql_get_last_message(), -1, null);

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

                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = 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

                                    Missing class import via use statement (line '157', column '16').
                                    Open

                                                        throw new Exception('Invalid Semicolon in ORDER BY Info');

                                    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

                                    Missing class import via use statement (line '376', column '21').
                                    Open

                                                    $objIndex = new QDatabaseIndex($strKeyName, $blnPrimaryKey, $blnUnique, $strColumnNameArray);

                                    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

                                    Missing class import via use statement (line '280', column '15').
                                    Open

                                                    throw new QSqlServerDatabaseException(mssql_get_last_message(), 0, $strNonQuery);

                                    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

                                    Missing class import via use statement (line '128', column '16').
                                    Open

                                                        throw new Exception('Invalid Backtick in LIMIT Info');

                                    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

                                    Missing class import via use statement (line '236', column '16').
                                    Open

                                                        throw new QSqlServerDatabaseException('Invalid QCUBED_OFFSET', 0, $strQuery);

                                    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

                                    Missing class import via use statement (line '254', column '15').
                                    Open

                                                    throw new QSqlServerDatabaseException(mssql_get_last_message(), 0, $strQuery);

                                    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

                                    Missing class import via use statement (line '332', column '32').
                                    Open

                                                    array_push($objFields, new QSqlServerDatabaseField($objRow, $this));

                                    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

                                    Missing class import via use statement (line '526', column '16').
                                    Open

                                                    return new QSqlServerDatabaseRow($strColumnArray);

                                    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

                                    Missing class import via use statement (line '159', column '16').
                                    Open

                                                        throw new Exception('Invalid Backtick in ORDER BY Info');

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

                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = 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

                                    Missing class import via use statement (line '258', column '38').
                                    Open

                                                $objSqlServerDatabaseResult = new QSqlServerDatabaseResult($objResult, $this);

                                    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

                                    Missing class import via use statement (line '769', column '17').
                                    Open

                                                            throw new QSqlServerDatabaseException('Unsupported Field Type: ' . $strTypeName, 0, null);

                                    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

                                    Missing class import via use statement (line '142', column '16').
                                    Open

                                                        throw new QSqlServerDatabaseException('Invalid Limit Info: ' . $strLimitInfo, 0, null);

                                    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

                                    Missing class import via use statement (line '428', column '28').
                                    Open

                                                            $objForeignKey = new QDatabaseForeignKey(

                                    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

                                    Avoid using static access to class 'QType' in method 'ExecuteQuery'.
                                    Open

                                                    $intOffset = QType::Cast(substr($strQuery,
                                                        $intPosition + 13 /* len of QCUBED_OFFSET< */,
                                                        $intEndPosition - $intPosition - 13), QType::Integer);

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

                                                } else {
                                                    // Passed in fielddata is a mssql_fetch_field field result
                                                    $this->strName = $mixFieldData->name;
                                                    $this->strOriginalName = $mixFieldData->name;
                                                    $this->strTable = $mixFieldData->column_source;

                                    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 assigning values to variables in if clauses and the like (line '502', column '8').
                                    Open

                                            public function FetchField() {
                                                if ($objField = mssql_fetch_field($this->objMsSqlResult))
                                                    return new QSqlServerDatabaseField($objField, $this->objDb);
                                            }

                                    IfStatementAssignment

                                    Since: 2.7.0

                                    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                                    Example

                                    class Foo
                                    {
                                        public function bar($flag)
                                        {
                                            if ($foo = 'bar') { // possible typo
                                                // ...
                                            }
                                            if ($baz = 0) { // always false
                                                // ...
                                            }
                                        }
                                    }

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

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

                                                    } else {
                                                        throw new QSqlServerDatabaseException('Invalid Limit Info: ' . $strLimitInfo, 0, null);
                                                    }

                                    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 'QType' in method 'GetColumn'.
                                    Open

                                                        return QType::Cast($strColumnValue, QType::Integer);

                                    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 'QType' in method 'GetColumn'.
                                    Open

                                                        return QType::Cast($strColumnValue, QType::Float);

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

                                                        } else {
                                                            // Check against NULL, True then False
                                                            if (is_null($mixData))
                                                                return 'IS NULL';
                                                            else if ($mixData)

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

                                                    } else {
                                                        if (is_null($mixData))
                                                            $strToReturn = 'IS ';
                                                        else
                                                            $strToReturn = '= ';

                                    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 'QType' in method 'GetColumn'.
                                    Open

                                                        return QType::Cast($strColumnValue, QType::String);

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

                                                    } else {
                                                        // Check against NULL, True then False
                                                        if (is_null($mixData))
                                                            return 'NULL';
                                                        else if ($mixData)

                                    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 assigning values to variables in if clauses and the like (line '233', column '10').
                                    Open

                                            protected function ExecuteQuery($strQuery) {
                                                // First, check for QCUBED_OFFSET<#> for LIMIT INFO Offseting
                                                if ( ($intPosition = strpos($strQuery, 'QCUBED_OFFSET<')) !== false) {
                                                    $intEndPosition = strpos($strQuery, '>', $intPosition);
                                                    if ($intEndPosition === false)

                                    IfStatementAssignment

                                    Since: 2.7.0

                                    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                                    Example

                                    class Foo
                                    {
                                        public function bar($flag)
                                        {
                                            if ($foo = 'bar') { // possible typo
                                                // ...
                                            }
                                            if ($baz = 0) { // always false
                                                // ...
                                            }
                                        }
                                    }

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

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

                                                    $objDatabaseRow = QType::Cast($mixFieldData, 'QSqlServerDatabaseRow');

                                    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 empty try-catch blocks in __construct.
                                    Open

                                                } catch (QInvalidCastException $objExc) {
                                                }

                                    EmptyCatchBlock

                                    Since: 2.7.0

                                    Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

                                    Example

                                    class Foo {
                                    
                                      public function bar()
                                      {
                                          try {
                                              // ...
                                          } catch (Exception $e) {} // empty catch block
                                      }
                                    }

                                    Source https://phpmd.org/rules/design.html#emptycatchblock

                                    Avoid unused parameters such as '$strColumnName'.
                                    Open

                                            public function InsertId($strTableName = null, $strColumnName = null) {

                                    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 '$strLimitInfo'.
                                    Open

                                            public function SqlLimitVariableSuffix($strLimitInfo) {

                                    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 '$strTableName'.
                                    Open

                                            public function InsertId($strTableName = null, $strColumnName = null) {

                                    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

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

                                            public function GetForeignKeysForTable($strTableName) {
                                                $objForeignKeyArray = array();
                                                
                                                // Use Query to pull the FKs
                                                $strQuery = sprintf('
                                    Severity: Major
                                    Found in includes/database/QSqlServerDatabase.class.php and 1 other location - About 1 day to fix
                                    includes/database/QSqlServer2005Database.class.php on lines 458..521

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

                                    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

                                        class QSqlServerDatabaseRow extends QDatabaseRowBase {
                                            protected $strColumnArray;
                                    
                                            public function __construct($strColumnArray) {
                                                $this->strColumnArray = $strColumnArray;
                                    Severity: Major
                                    Found in includes/database/QSqlServerDatabase.class.php and 1 other location - About 1 day to fix
                                    includes/database/QSqlServer2005Database.class.php on lines 614..674

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

                                    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

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

                                            public function SqlLimitVariablePrefix($strLimitInfo) {
                                                // Setup limit suffix (if applicable) via a TOP clause 
                                                // Add QCUBED_OFFSET tag if applicable
                                    
                                                if (strlen($strLimitInfo)) {
                                    Severity: Major
                                    Found in includes/database/QSqlServerDatabase.class.php and 1 other location - About 6 hrs to fix
                                    includes/database/QSqlServer2005Database.class.php on lines 175..202

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

                                    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

                                            public function GetIndexesForTable($strTableName) {
                                                $objIndexArray = array();
                                    
                                                // Use sp_helpindex to pull the indexes
                                                $objResult = $this->Query(sprintf('exec sp_helpindex %s', $this->SqlVariable($strTableName)));
                                    Severity: Major
                                    Found in includes/database/QSqlServerDatabase.class.php and 1 other location - About 5 hrs to fix
                                    includes/database/QSqlServer2005Database.class.php on lines 439..456

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

                                    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

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

                                                if ( ($intPosition = strpos($strQuery, 'QCUBED_OFFSET<')) !== false) {
                                                    $intEndPosition = strpos($strQuery, '>', $intPosition);
                                                    if ($intEndPosition === false)
                                                        throw new QSqlServerDatabaseException('Invalid QCUBED_OFFSET', 0, $strQuery);
                                                    $intOffset = QType::Cast(substr($strQuery,
                                    Severity: Major
                                    Found in includes/database/QSqlServerDatabase.class.php and 1 other location - About 4 hrs to fix
                                    includes/database/QSqlServer2005Database.class.php on lines 286..295

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

                                    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 8 locations. Consider refactoring.
                                    Open

                                            public function SqlSortByVariable($strSortByInfo) {
                                                // Setup sorting information (if applicable) via a ORDER BY clause
                                                if (strlen($strSortByInfo)) {
                                                    if (strpos($strSortByInfo, ';') !== false)
                                                        throw new Exception('Invalid Semicolon in ORDER BY Info');
                                    Severity: Major
                                    Found in includes/database/QSqlServerDatabase.class.php and 7 other locations - About 45 mins to fix
                                    includes/database/QInformixPdoDatabase.class.php on lines 220..232
                                    includes/database/QMySqliDatabase.class.php on lines 28..39
                                    includes/database/QMySqliDatabase.class.php on lines 41..53
                                    includes/database/QOracleDatabase.class.php on lines 60..72
                                    includes/database/QPostgreSqlDatabase.class.php on lines 151..163
                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 188..200
                                    includes/database/QSqlServer2005Database.class.php on lines 208..220

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

                                    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 5 locations. Consider refactoring.
                                    Open

                                            public function GetFieldsForTable($strTableName) {
                                                $strTableName = $this->SqlVariable($strTableName);
                                    
                                                $strQuery = sprintf('
                                                    SELECT
                                    Severity: Major
                                    Found in includes/database/QSqlServerDatabase.class.php and 4 other locations - About 45 mins to fix
                                    includes/database/QInformixPdoDatabase.class.php on lines 269..309
                                    includes/database/QPostgreSqlDatabase.class.php on lines 274..308
                                    includes/database/QPostgreSqlPdoDatabase.class.php on lines 210..240
                                    includes/database/QSqlServer2005Database.class.php on lines 364..390

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

                                    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

                                    Avoid excessively long variable names like $objSqlServerDatabaseField. Keep variable name length under 20.
                                    Open

                                                while ($objSqlServerDatabaseField = $this->FetchField())

                                    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 $strEscapeIdentifierEnd. Keep variable name length under 20.
                                    Open

                                            protected $strEscapeIdentifierEnd = ']';

                                    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 $objSqlServerDatabaseResult. Keep variable name length under 20.
                                    Open

                                                $objSqlServerDatabaseResult = new QSqlServerDatabaseResult($objResult, $this);

                                    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 $objIndexPropertyResult. Keep variable name length under 20.
                                    Open

                                                            $objIndexPropertyResult = $objDb->Query($strQuery);

                                    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 $strReferenceTableName. Keep variable name length under 20.
                                    Open

                                                                $strReferenceTableName,

                                    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 $strReferenceColumnNameArray. Keep variable name length under 20.
                                    Open

                                                                $strReferenceColumnNameArray);

                                    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 $strEscapeIdentifierBegin. Keep variable name length under 20.
                                    Open

                                            protected $strEscapeIdentifierBegin = '[';

                                    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

                                    Constant Adapter should be defined in uppercase
                                    Open

                                            const Adapter = 'Microsoft SQL Server Database Adapter';

                                    ConstantNamingConventions

                                    Since: 0.2

                                    Class/Interface constant names should always be defined in uppercase.

                                    Example

                                    class Foo {
                                        const MY_NUM = 0; // ok
                                        const myTest = ""; // fail
                                    }

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

                                    The method ExecuteTransactionCommit is not named in camelCase.
                                    Open

                                            protected function ExecuteTransactionCommit() {
                                                $this->NonQuery('COMMIT;');
                                            }

                                    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 FetchRow is not named in camelCase.
                                    Open

                                            public function FetchRow() {
                                                return mssql_fetch_row($this->objMsSqlResult);
                                            }

                                    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 CountFields is not named in camelCase.
                                    Open

                                            public function CountFields() {
                                                return mssql_num_fields($this->objMsSqlResult);
                                            }

                                    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 GetIndexesForTable is not named in camelCase.
                                    Open

                                            public function GetIndexesForTable($strTableName) {
                                                $objIndexArray = array();
                                    
                                                // Use sp_helpindex to pull the indexes
                                                $objResult = $this->Query(sprintf('exec sp_helpindex %s', $this->SqlVariable($strTableName)));

                                    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 SqlSortByVariable is not named in camelCase.
                                    Open

                                            public function SqlSortByVariable($strSortByInfo) {
                                                // Setup sorting information (if applicable) via a ORDER BY clause
                                                if (strlen($strSortByInfo)) {
                                                    if (strpos($strSortByInfo, ';') !== false)
                                                        throw new Exception('Invalid Semicolon in ORDER BY Info');

                                    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 ExecuteQuery is not named in camelCase.
                                    Open

                                            protected function ExecuteQuery($strQuery) {
                                                // First, check for QCUBED_OFFSET<#> for LIMIT INFO Offseting
                                                if ( ($intPosition = strpos($strQuery, 'QCUBED_OFFSET<')) !== false) {
                                                    $intEndPosition = strpos($strQuery, '>', $intPosition);
                                                    if ($intEndPosition === false)

                                    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 ExecuteNonQuery is not named in camelCase.
                                    Open

                                            protected function ExecuteNonQuery($strNonQuery) {
                                                // Perform the Query
                                    
                                                // Because the MSSQL extension throws warnings, we want to make our mssql_query
                                                // call around no error handler

                                    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 GetNextRow is not named in camelCase.
                                    Open

                                            public function GetNextRow() {
                                                $strColumnArray = $this->FetchArray();
                                                
                                                if ($strColumnArray)
                                                    return new QSqlServerDatabaseRow($strColumnArray);

                                    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 GetColumnNameArray is not named in camelCase.
                                    Open

                                            public function GetColumnNameArray() {
                                                return $this->strColumnArray;
                                            }

                                    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 Connect is not named in camelCase.
                                    Open

                                            public function Connect() {
                                          // Set several ini settings
                                          ini_set ( 'mssql.textlimit' , '65536' );
                                                ini_set ( 'mssql.textsize' , '65536' );
                                                ini_set ( 'mssql.charset' , 'utf-8' );

                                    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 Close is not named in camelCase.
                                    Open

                                            public function Close() {
                                                mssql_free_result($this->objMsSqlResult);
                                            }

                                    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 Close is not named in camelCase.
                                    Open

                                            public function Close() {
                                                mssql_close($this->objMsSql);
                                    
                                                // Update Connected Flag
                                                $this->blnConnectedFlag = false;

                                    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 GetFieldsForTable is not named in camelCase.
                                    Open

                                            public function GetFieldsForTable($strTableName) {
                                                $strTableName = $this->SqlVariable($strTableName);
                                    
                                                $strQuery = sprintf('
                                                    SELECT

                                    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 ExecuteTransactionBegin is not named in camelCase.
                                    Open

                                            protected function ExecuteTransactionBegin() {
                                                $this->NonQuery('BEGIN TRANSACTION;');
                                            }

                                    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 GetTableForId is not named in camelCase.
                                    Open

                                            public function GetTableForId($intTableId) {
                                                $intTableId = $this->SqlVariable($intTableId);
                                                $strQuery = sprintf('
                                                    SELECT
                                                        name

                                    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 FetchFields is not named in camelCase.
                                    Open

                                            public function FetchFields() {
                                                $objArrayToReturn = array();
                                                while ($objSqlServerDatabaseField = $this->FetchField())
                                                    array_push($objArrayToReturn, $objSqlServerDatabaseField);
                                                return $objArrayToReturn;

                                    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 FetchField is not named in camelCase.
                                    Open

                                            public function FetchField() {
                                                if ($objField = mssql_fetch_field($this->objMsSqlResult))
                                                    return new QSqlServerDatabaseField($objField, $this->objDb);
                                            }

                                    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 CountRows is not named in camelCase.
                                    Open

                                            public function CountRows() {
                                                return mssql_num_rows($this->objMsSqlResult);
                                            }

                                    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 GetColumn is not named in camelCase.
                                    Open

                                            public function GetColumn($strColumnName, $strColumnType = null) {
                                                if (!isset($this->strColumnArray[$strColumnName])) {
                                                    return null;
                                                }
                                                $strColumnValue = $this->strColumnArray[$strColumnName];

                                    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 GetRows is not named in camelCase.
                                    Open

                                            public function GetRows() {
                                                $objDbRowArray = array();
                                                while ($objDbRow = $this->GetNextRow())
                                                    array_push($objDbRowArray, $objDbRow);
                                                return $objDbRowArray;

                                    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 ColumnExists is not named in camelCase.
                                    Open

                                            public function ColumnExists($strColumnName) {
                                                return array_key_exists($strColumnName, $this->strColumnArray);
                                            }

                                    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 SqlVariable is not named in camelCase.
                                    Open

                                            public function SqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false) {
                                                // Are we SqlVariabling a BOOLEAN value?
                                                if (is_bool($mixData)) {
                                                    // Yes
                                                    if ($blnIncludeEquality) {

                                    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 SqlLimitVariablePrefix is not named in camelCase.
                                    Open

                                            public function SqlLimitVariablePrefix($strLimitInfo) {
                                                // Setup limit suffix (if applicable) via a TOP clause 
                                                // Add QCUBED_OFFSET tag if applicable
                                    
                                                if (strlen($strLimitInfo)) {

                                    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 GetForeignKeysForTable is not named in camelCase.
                                    Open

                                            public function GetForeignKeysForTable($strTableName) {
                                                $objForeignKeyArray = array();
                                                
                                                // Use Query to pull the FKs
                                                $strQuery = sprintf('

                                    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 FetchArray is not named in camelCase.
                                    Open

                                            public function FetchArray() {
                                                return mssql_fetch_array($this->objMsSqlResult);
                                            }

                                    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 SqlLimitVariableSuffix is not named in camelCase.
                                    Open

                                            public function SqlLimitVariableSuffix($strLimitInfo) {
                                                return null;
                                            }

                                    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 GetTables is not named in camelCase.
                                    Open

                                            public function GetTables() {
                                    //            $objResult = $this->Query("SELECT name FROM sysobjects WHERE xtype='U' ORDER BY name ASC");
                                                $objResult = $this->Query("SELECT name FROM sysobjects WHERE (OBJECTPROPERTY(id, N'IsTable') = 1) AND " .
                                                    "(name NOT LIKE N'#%') AND (OBJECTPROPERTY(id, N'IsMSShipped') = 0) AND (OBJECTPROPERTY(id, N'IsSystemTable') = 0) " .
                                                    "ORDER BY name ASC");

                                    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 InsertId is not named in camelCase.
                                    Open

                                            public function InsertId($strTableName = null, $strColumnName = null) {
                                                $strQuery = 'SELECT SCOPE_IDENTITY();';
                                                $objResult = $this->Query($strQuery);
                                                $objRow = $objResult->FetchRow();
                                                return $objRow[0];

                                    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 ExecuteTransactionRollBack is not named in camelCase.
                                    Open

                                            protected function ExecuteTransactionRollBack() {
                                                $this->NonQuery('ROLLBACK;');
                                            }

                                    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