Showing 1,420 of 1,425 total issues
Method editable_roles
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function editable_roles( $all_roles ) {
/**
* Prevent issues when other plugins call get_editable_roles() before `init`.
*
Method llms_is_post_restricted_by_sitewide_membership
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_is_post_restricted_by_sitewide_membership( $post_id, $user_id = null ) {
$membership_id = absint( get_option( 'lifterlms_membership_required', '' ) );
// site is restricted to a membership.
Method sql_where
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function sql_where() {
global $wpdb;
$where = 'WHERE 1';
Method lifterlms_template_achievements_loop
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function lifterlms_template_achievements_loop( $student = null, $limit = false, $columns = null ) {
// Get the current student if none supplied.
if ( ! $student ) {
$student = llms_get_student();
Method llms_get_endpoint_url
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
// Map endpoint to options.
$vars = llms()->query->get_query_vars();
$endpoint = $vars[ $endpoint ] ?? $endpoint;
Method lifterlms_template_my_memberships_loop
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function lifterlms_template_my_memberships_loop( $student = null ) {
$student = llms_get_student( $student );
if ( ! $student ) {
return;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( 'remove' !== $btn.attr( 'data-action' ) ) {
$btn.text( LLMS.l10n.translate( 'Cancel' ) );
$btn.attr( 'data-action', 'remove' );
$new_row.find( 'input' ).removeAttr( 'disabled' );
- 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 57.
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
if ( 'remove' !== $btn.attr( 'data-action' ) ) {
$btn.text( LLMS.l10n.translate( 'Cancel' ) );
$btn.attr( 'data-action', 'remove' );
$new_row.find( 'input' ).removeAttr( 'disabled' );
- 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 57.
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 filter_nav_items
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function filter_nav_items( $items ) {
$urls = array(
'#llms-signout',
'#llms-signin',
- 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_current_strength
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
get_current_strength: function( format ) {
format = format || 'int';
var pass = this.$pass.val(),
conf = this.$conf && this.$conf.length ? this.$conf.val() : '',
- 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_results
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_results( $args = array() ) {
$this->title = __( 'Manage Existing Enrollments', 'lifterlms' );
if ( ! $args ) {
- 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 save
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function save( $post_id ) {
if ( ! llms_verify_nonce( 'lifterlms_meta_nonce', 'lifterlms_save_data' ) ) {
return;
}
- 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 send_file
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function send_file( $file_name, $media_id ) {
$server_software = ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( $_SERVER['SERVER_SOFTWARE'] ) : '' );
if (
( array_key_exists( 'MOD_X_SENDFILE_ENABLED', $_SERVER ) && '1' === $_SERVER['MOD_X_SENDFILE_ENABLED'] ) ||
- 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_products
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_products( $post_type = 'any' ) {
global $wpdb;
$table = $this->get_product_to_voucher_table_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
Function hide_notices
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function hide_notices() {
if ( ( isset( $_GET['llms-hide-notice'] ) || isset( $_GET['llms-remind-notice'] ) ) && isset( $_GET['_llms_notice_nonce'] ) ) {
if ( ! llms_verify_nonce( '_llms_notice_nonce', 'llms_hide_notices_nonce', 'GET' ) ) {
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'lifterlms' ) );
}
- 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_data
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function get_data( $key, $data ) {
$course = llms_get_post( $data );
switch ( $key ) {
- 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_html
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function get_table_html() {
$integrations = llms()->integrations()->get_integrations();
ob_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
Function output_instructors_assistant_fields
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function output_instructors_assistant_fields( $user ) {
if ( is_numeric( $user ) || is_a( $user, 'WP_User' ) ) {
$instructor = llms_get_instructor( $user );
$selected = $instructor->get( 'parent_instructors' );
- 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_results
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_results( $args = array() ) {
$this->title = __( 'Students', 'lifterlms' );
if ( ! $args ) {
- 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_notification_settings
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function get_notification_settings( $controller ) {
$settings = array();
// Setup vars.
- 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"