Method the_posts_filter
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function the_posts_filter( $posts, $wp_query ) {
$file_config = $this->get_config();
if ( false !== $file_config && $wp_query->is_main_query() && ! is_admin() ) {
$default_post = [
'post_author' => 1,
- Create a ticketCreate a ticket
Method add_config
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
- Create a ticketCreate a ticket
The method add_config has a boolean flag argument $prevent_slash, which is a certain sign of a Single Responsibility Principle violation. Open
public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Avoid assigning values to variables in if clauses and the like (line '106', column '18'). Open
public function template_include_filter( $template ) {
// Check if we're dealing stuff care about.
if ( false !== $file_config = $this->get_config() ) {
return $file_config['template'];
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 unused parameters such as '$requested_url'. Open
public function redirect_canonical_filter( $redirect_url, $requested_url ) {
- Read upRead up
- Create a ticketCreate a ticket
- 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
The parameter $requested_url is not named in camelCase. Open
public function redirect_canonical_filter( $redirect_url, $requested_url ) {
// Check if we're dealing stuff we care about and optionally prevent addtion of trailing slash.
if ( false !== $this->get_config() && $this->get_config()['prevent_slash'] ) {
return false;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The property $_files is not named in camelCase. Open
class File_Handler implements Plugin_Interface
{
/**
* List of files that this plugin will handle.
*
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The class File_Handler is not named in CamelCase. Open
class File_Handler implements Plugin_Interface
{
/**
* List of files that this plugin will handle.
*
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The parameter $wp_query is not named in camelCase. Open
public function the_posts_filter( $posts, $wp_query ) {
$file_config = $this->get_config();
if ( false !== $file_config && $wp_query->is_main_query() && ! is_admin() ) {
$default_post = [
'post_author' => 1,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $redirect_url is not named in camelCase. Open
public function redirect_canonical_filter( $redirect_url, $requested_url ) {
// Check if we're dealing stuff we care about and optionally prevent addtion of trailing slash.
if ( false !== $this->get_config() && $this->get_config()['prevent_slash'] ) {
return false;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $prevent_slash is not named in camelCase. Open
public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
$this->_files[] = [
'file' => $file,
'rewrite' => $rewrite,
'template' => $template,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The method get_config is not named in camelCase. Open
public function get_config() {
$file_key = get_query_var( 'mu_file_handler', false );
if ( false !== $file_key && array_key_exists( $file_key, $this->_files ) ) {
return $this->_files[ $file_key ];
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 redirect_canonical_filter is not named in camelCase. Open
public function redirect_canonical_filter( $redirect_url, $requested_url ) {
// Check if we're dealing stuff we care about and optionally prevent addtion of trailing slash.
if ( false !== $this->get_config() && $this->get_config()['prevent_slash'] ) {
return false;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 template_include_filter is not named in camelCase. Open
public function template_include_filter( $template ) {
// Check if we're dealing stuff care about.
if ( false !== $file_config = $this->get_config() ) {
return $file_config['template'];
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 add_config is not named in camelCase. Open
public function add_config( $file, $rewrite, $template, $prevent_slash = true, $post = [] ) {
$this->_files[] = [
'file' => $file,
'rewrite' => $rewrite,
'template' => $template,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 the_posts_filter is not named in camelCase. Open
public function the_posts_filter( $posts, $wp_query ) {
$file_config = $this->get_config();
if ( false !== $file_config && $wp_query->is_main_query() && ! is_admin() ) {
$default_post = [
'post_author' => 1,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 init_action is not named in camelCase. Open
public function init_action() {
/**
* Fires on WordPress init, other themes and plugins to use this to handle their files.
*
* @param File_Handler $this File_Handler instance.
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}