Showing 59 of 59 total issues
Method acf
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function acf($page = null, $name = null, $format = true)
{
if (!function_exists('acf_format_value')) {
throw new UnsatisfiedDependencyException('Advanced Custom Fields must be installed to use field');
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function template($slug, $action)
{
$action = $this->formatAction($action);
$route = (new TemplateRoute($action['method'], $slug, $action))
- Read upRead up
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 104.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function page($slug, $action)
{
$action = $this->formatAction($action);
$route = (new PageRoute($action['method'], $slug, $action))
- Read upRead up
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 104.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function acf
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function acf($page = null, $name = null, $format = true)
{
if (!function_exists('acf_format_value')) {
throw new UnsatisfiedDependencyException('Advanced Custom Fields must be installed to use field');
}
- 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 __call
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function __call($name, $arguments)
{
$name = Str::snake($name);
$name = str_replace('has', 'have', $name);
- 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
Method addPage
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function addPage($pageTitle, $menuTitle, $capability, $slug, $action, $iconUrl = '', $position = null)
Function _do_query
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function _do_query($query)
{
if (defined('SAVEQUERIES') && SAVEQUERIES) {
$this->timer_start();
}
- 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
Method addSubpage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function addSubpage($parent, $pageTitle, $menuTitle, $capabilities, $slug, $action)
Function get
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function get($page = null, $name = null)
{
if (is_object($page) && (is_subclass_of($page, Post::class) || $page instanceof Post)) {
$page = $page->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
The class Post has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13. Open
class Post extends Model
{
use Rememberable;
public $timestamps = false;
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Method wp_mail
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
Method name "WordpressDatabase::_do_query" is not in camel caps format Open
private function _do_query($query)
- Exclude checks
Method name "WordpressDatabase::db_connect" is not in camel caps format Open
public function db_connect($allowBail = true)
- Exclude checks
Function wp_mail
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
{
list($to, $subject, $headers, $attachments) = array_values(
Action::filter('wp_mail', [$to, $subject, $message, $headers, $attachments])
);
- 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
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function add($key, $value, $group = 'default', $expiration = 0)
{
if (wp_suspend_cache_addition()) {
return false;
}
- 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
Method name "WordpressDatabase::has_cap" is not in camel caps format Open
public function has_cap($capability)
- Exclude checks
Method name "WordpressDatabase::check_connection" is not in camel caps format Open
public function check_connection($allowBail = true)
- Exclude checks
Method name "WordpressDatabase::_real_escape" is not in camel caps format Open
public function _real_escape($string)
- Exclude checks
Method name "WordpressDatabase::set_sql_mode" is not in camel caps format Open
public function set_sql_mode($modes = [])
- Exclude checks
Method name "WordpressDatabase::db_version" is not in camel caps format Open
public function db_version()
- Exclude checks