Showing 1,420 of 1,425 total issues
Method update_quiz
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function update_quiz( $quiz_data, $lesson ) {
$res = array_merge(
$quiz_data,
array(
Method get_enrollment_order
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_enrollment_order( $product_id ) {
// If a lesson id was passed in, cascade up to the course for order retrieval.
if ( 'lesson' === get_post_type( $product_id ) ) {
$lesson = new LLMS_Lesson( $product_id );
Method duplicate
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function duplicate( $post_id ) {
// Make sure we have a post id and it returns a post.
if ( ! isset( $post_id ) ) {
return false;
Method add_post_actions
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_post_actions( $actions, $post ) {
if ( ! $post || "llms_{$this->engagement_type}" !== $post->post_type ) {
return $actions;
}
Method llms_get_author
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_get_author( $args = array() ) {
$args = wp_parse_args(
$args,
array(
Method get_test_settings
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_test_settings( $type ) {
if ( 'email' !== $type ) {
return array();
}
Method llms_template_my_favorites_loop
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_template_my_favorites_loop( $student = null, $favorites = null ) {
$student = llms_get_student( $student );
if ( ! $student ) {
return;
Similar blocks of code found in 2 locations. Consider refactoring. Open
case 'audio_embed':
defaults.classes.push( 'llms-editable-audio' );
defaults.placeholder = 'https://';
defaults.tip = LLMS.l10n.translate( 'Use SoundCloud or Spotify audio URLS.' );
defaults.input_type = 'url';
- 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 65.
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
case 'video_embed':
defaults.classes.push( 'llms-editable-video' );
defaults.placeholder = 'https://';
defaults.tip = LLMS.l10n.translate( 'Use YouTube, Vimeo, or Wistia video URLS.' );
defaults.input_type = 'url';
- 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 65.
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
Method get_text
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_text( $text_type, $variables = array() ) {
$engagement_template_id = $variables['engagement_template_id'] ?? 0;
switch ( $text_type ) {
Function coupon_apply
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.coupon_apply = function ( $btn ) {
var self = this,
$code = $( '#llms_coupon_code' ),
code = $code.val(),
Function bind_mce_fixes
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.bind_mce_fixes = function() {
// We need `wp.data` to proceed.
if ( undefined === wp.data || [ null, undefined ].includes( wp.data.select( 'core/edit-post' ) ) ) {
return;
Function Edit
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Edit = ( props ) => {
const { attributes, setAttributes } = props;
const blockProps = useBlockProps();
const memoizedServerSideRender = useMemo( () => {
Function make_editable
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function make_editable( $field ) {
var $label = $field.find( 'label' ).clone(),
name = $field.attr( 'data-llms-editable' ),
type = $field.attr( 'data-llms-editable-type' ),
Method get_text
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_text( $text_type, $variables = array() ) {
$engagement_template_id = $variables['engagement_template_id'] ?? 0;
switch ( $text_type ) {
Method handle_link_actions
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle_link_actions() {
$action = llms_filter_input( INPUT_GET, 'action' );
// Bail early if request doesn't concern us.
Method redemption_section_html
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function redemption_section_html() {
global $post;
$pid = $post->ID;
Method register_meta_boxes
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function register_meta_boxes() {
add_meta_box(
'llms_dashboard_quick_links',
__( 'Quick Links', 'lifterlms' ),
Method get_results
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_results( $args = array() ) {
$args = $this->clean_args( $args );
if ( is_numeric( $args['student'] ) ) {
Method set_columns
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function set_columns() {
return array(
'id' => array(
'exportable' => true,
'title' => __( 'ID', 'lifterlms' ),