Showing 191 of 191 total issues
File class-llms-rest-posts-controller.php
has 936 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* REST LLMS Posts Controller Class
*
* @package LifterLMS_REST/Abstracts
File class-llms-rest-courses-controller.php
has 801 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* REST Courses Controller
*
* @package LifterLMS_REST/Classes/Controllers
Method get_item_schema_base
has 345 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_item_schema_base() {
$schema = (array) parent::get_item_schema_base();
$course_properties = array(
File class-llms-rest-enrollments-controller.php
has 624 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* REST Enrollments Controller.
*
* @package LLMS_REST
Function update_additional_object_fields
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
protected function update_additional_object_fields( $course, $request, $schema, $prepared_item, $creating = true ) {
$error = new WP_Error();
// Course catalog visibility.
- 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 get_item_schema_base
has 184 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_item_schema_base() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => $this->post_type,
File class-llms-rest-controller.php
has 456 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Base REST Controller
*
* @package LifterLMS_REST/Abstracts
Method get_item_schema_base
has 163 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_item_schema_base() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => $this->resource_name,
LLMS_REST_Posts_Controller
has 47 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class LLMS_REST_Posts_Controller extends LLMS_REST_Controller {
/**
* Post type.
*
Method get_fields
has 156 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_fields() {
require_once 'tables/class-llms-rest-table-api-keys.php';
$add_key = '1' === llms_filter_input( INPUT_GET, 'add-key', FILTER_SANITIZE_NUMBER_INT );
File class-llms-rest-lessons-controller.php
has 420 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* REST Lessons Controller
*
* @package LifterLMS_REST/Classes/Controllers
Method get_item_schema_base
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_item_schema_base() {
$schema = (array) parent::get_item_schema_base();
$schema['properties']['auto_enroll'] = array(
File class-llms-rest-users-controller.php
has 417 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Base users controller class
*
* @package LifterLMS_REST/Abstracts
Method get_item_schema_base
has 147 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_item_schema_base() {
$schema = (array) parent::get_item_schema_base();
$lesson_properties = array(
File class-llms-rest-memberships-controller.php
has 402 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* REST Memberships Controller
*
* @package LifterLMS_REST/Classes/Controllers
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function prepare_collection_query_args( $request ) {
$query_args = parent::prepare_collection_query_args( $request );
if ( is_wp_error( $query_args ) ) {
return $query_args;
- 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 196.
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
protected function prepare_collection_query_args( $request ) {
$query_args = parent::prepare_collection_query_args( $request );
if ( is_wp_error( $query_args ) ) {
return $query_args;
- 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 196.
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 update_additional_object_fields
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
protected function update_additional_object_fields( $membership, $request, $schema, $prepared_item, $creating = true ) {
$error = new WP_Error();
// Auto enroll.
if ( ! empty( $schema['properties']['auto_enroll'] ) && isset( $request['auto_enroll'] ) ) {
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function get_name_cell( $webhook ) {
$html = esc_html( $webhook->get( 'name' ) );
$edit_link = esc_url( $webhook->get_edit_link() );
$html = '<a href="' . $edit_link . '">' . $html . '</a>';
- 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 182.
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
protected function get_description_cell( $api_key ) {
$html = esc_html( $api_key->get( 'description' ) );
$edit_link = esc_url( $api_key->get_edit_link() );
$html = '<a href="' . $edit_link . '">' . $html . '</a>';
- 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 182.
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