Showing 1,389 of 1,394 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
readmeContents.split( '\n' ).forEach( ( line ) => {
if ( line === startToken ) {
newReadme.push( line );
newReadme.push( docsToken );
addLine = false;
- 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 102.
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
LLMS_Abstract_Notification_Controller
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class LLMS_Abstract_Notification_Controller extends LLMS_Abstract_Options_Data implements LLMS_Interface_Notification_Controller {
/**
* Trigger Identifier
*
Method parse_args
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parse_args() {
// Sanitize post & user ids.
foreach ( array( 'post_id', 'user_id' ) as $key ) {
File model.llms.course.php
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* LifterLMS Course Model
*
* @package LifterLMS/Models/Classes
Method get_settings
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_settings() {
/**
* Filter the course settings.
*
Method get_settings
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_settings() {
return apply_filters(
'lifterlms_membership_settings',
array(
Method select2_query_posts
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function select2_query_posts() {
global $wpdb;
// Grab the search term if it exists.
File llms-analytics.js
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
;/**
* LifterLMS Admin Reporting Widgets & Charts
*
* @since 3.0.0
* @since 3.17.2 Unknown.
Function save
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function save( $post_id ) {
if ( ! llms_verify_nonce( 'lifterlms_meta_nonce', 'lifterlms_save_data' ) ) {
return -1;
}
- 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 update_completion_status
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function update_completion_status( $status, $object_id, $object_type, $trigger = 'unspecified' ) {
$student_id = $this->get_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 llms_setup_pending_order
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function llms_setup_pending_order( $data = array() ) {
/**
* Filters the order data before setting up the pending order.
*
- 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 llms_update_3160_update_question_data
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_update_3160_update_question_data() {
if ( 'complete' !== get_transient( 'llms_update_3160_ensure_no_lesson_dupe_rels' ) ) {
return true;
}
Method llms_update_3160_attempt_migration
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_update_3160_attempt_migration() {
global $wpdb;
$query = $wpdb->get_results( "SELECT user_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'llms_quiz_data' LIMIT 100;" ); // db call ok; no-cache ok.
File class.llms.template.loader.php
has 299 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Template loader
*
* @package LifterLMS/Classes
LLMS_Course
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class LLMS_Course extends LLMS_Post_Model implements LLMS_Interface_Post_Instructors {
use LLMS_Trait_Audio_Video_Embed;
use LLMS_Trait_Sales_Page;
Function Edit
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Edit = ( props ) => {
const { attributes, setAttributes } = props;
const blockProps = useBlockProps();
const isLlmsPostType = useLlmsPostType();
const courseOptions = usePostOptions();
Method lifterlms_template_student_dashboard_my_grades
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
function lifterlms_template_student_dashboard_my_grades() {
$student = llms_get_student();
if ( ! $student ) {
return;
File class-llms-block-templates.php
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* LLMS_Block_Templates class file
*
* @package LifterLMS/Classes
Similar blocks of code found in 2 locations. Consider refactoring. Open
<PanelRow>
<NumberControl
label={ __( 'Per Page', 'lifterlms' ) }
value={ attributes.posts_per_page }
min={ -1 }
- 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 98.
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
<PanelRow>
<NumberControl
label={ __( 'Per Page', 'lifterlms' ) }
value={ attributes.posts_per_page }
min={ -1 }
- 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 98.
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