DB
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class DB extends Service {
use Hook_Service_Trait, Container_Service_Trait, Translations_Service_Trait;
/**
* WordPress database abstraction object.
The class DB has an overall complexity of 60 which is very high. The configured complexity threshold is 50. Open
class DB extends Service {
use Hook_Service_Trait, Container_Service_Trait, Translations_Service_Trait;
/**
* WordPress database abstraction object.
- Exclude checks
Function uninstall
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function uninstall() {
if ( is_multisite() ) {
$network_ids = $this->options()->get_networks_with_option( 'db_version' );
foreach ( $network_ids as $network_id ) {
$versions = $this->options()->get_for_all_sites( 'db_version', $network_id );
- Read upRead up
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 generic_query_helper
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function generic_query_helper( $method_name, $query, $args = array() ) {
$query = $this->replace_table_placeholders( $query );
if ( ! empty( $args ) ) {
$query = $this->wpdb->prepare( $query, $args ); // phpcs:ignore
- Read upRead up
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 create_format_from_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function create_format_from_data( $data ) {
$format = array();
foreach ( $data as $value ) {
if ( is_integer( $value ) ) {
$format[] = '%d';
- Read upRead up
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 add_table
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function add_table( $table, $schema = array() ) {
if ( isset( $this->wpdb->$table ) || isset( $this->tables[ $table ] ) ) {
return new WP_Error( 'table_already_exist', sprintf( $this->get_translation( 'table_already_exist' ), $table ) );
}
- Read upRead up
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 get_table
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_table( $table, $mode = 'raw' ) {
if ( ! $this->table_exists( $table ) ) {
return null;
}
- Read upRead up
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
Missing class import via use statement (line '561', column '26'). Open
$prepared_data = new \stdClass();
- Read upRead up
- Exclude checks
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 unused parameters such as '$args'. Open
public function query( $query, $args = array() ) {
- Read upRead up
- Exclude checks
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 '$args'. Open
public function get_var( $query, $args = array() ) {
- Read upRead up
- Exclude checks
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 '$args'. Open
public function get_col( $query, $args = array() ) {
- Read upRead up
- Exclude checks
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 '$args'. Open
public function get_row( $query, $args = array() ) {
- Read upRead up
- Exclude checks
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 '$args'. Open
public function get_results( $query, $args = array() ) {
- Read upRead up
- Exclude checks
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 classes with short names like DB. Configured minimum length is 3. Open
class DB extends Service {
use Hook_Service_Trait, Container_Service_Trait, Translations_Service_Trait;
/**
* WordPress database abstraction object.
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}