Showing 1,420 of 1,425 total issues
Method get_transaction_total
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_transaction_total( $type = 'amount' ) {
// Check the cache.
static $cache = array();
if ( isset( $cache[ $this->get( 'id' ) ] )
Method get_engagements
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_engagements( $trigger_type, $related_post_id = '' ) {
global $wpdb;
$related_select = '';
Method get_creation_args
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_creation_args( $args = null ) {
// Allow nothing to be passed in.
if ( empty( $args ) ) {
$args = array();
Method pre_get_posts
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function pre_get_posts( $query ) {
static $done = false;
$modify_tax_query = false;
Method get_pages
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_pages() {
/**
* Filters the essential starter pages.
*
* These are the pages that are going to be created when installing LifterLMS.
Method register_post_statuses
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function register_post_statuses() {
$order_statuses = self::get_order_statuses();
$txn_statuses = apply_filters(
Method query_quiz_questions
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query_quiz_questions() {
// Grab the search term if it exists.
$term = array_key_exists( 'term', $_REQUEST ) ? llms_filter_input_sanitize_string( INPUT_POST, 'term' ) : '';
$page = array_key_exists( 'page', $_REQUEST ) ? llms_filter_input( INPUT_POST, 'page', FILTER_SANITIZE_NUMBER_INT ) : 0;
Method get_fields_for_certificates
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_fields_for_certificates() {
return array(
'size' => array(
'description' => __( 'Certificate size.', 'lifterlms' ),
Function process_object_updates
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function process_object_updates( data, type, parent, main_data ) {
if ( ! data[ type ] ) {
return data;
}
Method admin_footer
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function admin_footer( $text ) {
global $current_screen;
// Show footer on our custom post types in admin, but not on the block editor.
Method get_sort
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_sort() {
$sort = array();
switch ( $this->get_orderby() ) {
Method get_data
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_data( $key, $student ) {
$value = '';
switch ( $key ) {
Method scrub_field
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function scrub_field( $val, $type ) {
if ( is_string( $val ) && 'html' !== $type ) {
$val = wp_strip_all_tags( $val );
}
Method toArray
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray() {
$arr = array(
'id' => $this->get( 'id' ),
);
Method lifterlms_course_continue_button
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function lifterlms_course_continue_button( $post_id = null, $student = null, $progress = null ) {
if ( ! $post_id ) {
$post_id = get_the_ID();
if ( ! $post_id ) {
Method get_progress
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_progress( $object_id, $type = 'course', $use_cache = true ) {
$ret = 0;
$cache_key = sprintf( '%1$s_%2$d_progress', $type, $object_id );
$cached = $use_cache ? $this->get( $cache_key ) : '';
Method get_privacy_message
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_privacy_message() {
$content = '
<div class="wp-suggested-text">' .
'<p class="privacy-policy-tutorial">' .
__( 'This sample language includes the basics around what personal data your learning platform may be collecting, storing and sharing, as well as who may have access to that data. Depending on what settings are enabled and which additional add-ons are used, the specific information shared by your site will vary. We recommend consulting with a lawyer when deciding what information to disclose on your privacy policy.', 'lifterlms' ) .
Method register_fields_for_certificate_templates
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function register_fields_for_certificate_templates() {
register_rest_field(
'llms_certificate',
'certificate_title',
Identical blocks of code found in 2 locations. Consider refactoring. Open
var modelBeingSorted = this.collection.get( ui.item.attr( 'data-model-cid' ) ),
modelViewContainerEl = this._getContainerEl(),
newIndex = modelViewContainerEl.children().index( ui.item );
- 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 67.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
var modelBeingSorted = this.collection.get( ui.item.attr( 'data-model-cid' ) ),
modelViewContainerEl = this._getContainerEl(),
newIndex = modelViewContainerEl.children().index( ui.item );
- 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 67.
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