Showing 1,420 of 1,425 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
it.each( testData )( '%s', ( name, slug, expected, isPublic ) => {
mockedApiReturn = getMockApiReturn( isPublic );
mockedSlug = slug;
expect( isProjectPrivate() ).toBe( expected );
} );
- 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 61.
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_fields
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_fields() {
$post_type = get_post_type_object( $this->post->post_type );
$restrictions = get_post_meta( $this->post->ID, $this->prefix . 'restricted_levels', true );
Method __construct
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct() {
// Achievements.
new LLMS_Meta_Box_Achievement();
new LLMS_Meta_Box_Achievement_Sync();
Method student_information
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function student_information() {
$post_type = get_post_type( $this->post->ID );
$student_id = $this->current_student_id();
$student = $student_id ? llms_get_student( $student_id ) : $student_id;
Method output
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function output() {
global $post;
parent::output();
Method llms_merge_code_button
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_merge_code_button( $target = 'content', $echo = true, $codes = array() ) {
$screen = get_current_screen();
if ( ! $codes && $screen && isset( $screen->post_type ) ) {
Method get_author_id
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_author_id( $raw ) {
$author_id = 0;
// If raw is missing an ID and Email, use current user id.
Method record_transaction
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function record_transaction( $data = array() ) {
extract(
array_merge(
array(
Method get_description
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_description( $context = 'course' ) {
$key = $this->get( 'meta_key' );
$student = $this->get_student();
Method set
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set( $key, $val ) {
// Don't set the ID.
if ( 'id' === $key ) {
return $this;
Method add_profile_nav_items
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_profile_nav_items() {
$profile_endpoints = $this->get_profile_endpoints();
if ( empty( $profile_endpoints ) ) {
Method create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function create( $content ) {
global $wpdb;
$new_user_achievement = apply_filters(
'lifterlms_new_achievement',
Method check_voucher_duplicate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function check_voucher_duplicate() {
$post_id = ! empty( $_REQUEST['postId'] ) ? absint( llms_filter_input( INPUT_POST, 'postId', FILTER_SANITIZE_NUMBER_INT ) ) : 0;
$codes = ! empty( $_REQUEST['codes'] ) ? llms_filter_input_sanitize_string( INPUT_POST, 'codes', array( FILTER_REQUIRE_ARRAY ) ) : array();
Method create_pending_order
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_pending_order() {
$verify = $this->verify_request( '_llms_checkout_nonce', self::ACTION_CREATE_PENDING_ORDER );
if ( ! $verify ) {
return $verify;
Method register_meta
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function register_meta() {
$props = array(
'_llms_form_location' => array(
'description' => __( 'Determines the front-end location where the form is displayed.', 'lifterlms' ),
Method get_date_range_by_filter
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_date_range_by_filter( $filter ) {
$today = current_time( 'Y-m-d' );
$current_month = date( 'm', strtotime( $today ) );
$current_year = date( 'Y', strtotime( $today ) );
Method create_files
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create_files() {
$upload_dir = wp_upload_dir();
$files = array(
array(
'base' => LLMS_LOG_DIR,
Method llms_current_user_can
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function llms_current_user_can( $cap, $obj_id = null ) {
$caps = LLMS_Roles::get_all_core_caps();
$grant = false;
Similar blocks of code found in 2 locations. Consider refactoring. Open
case 'memberships_expired':
$status = explode( '_', $key );
$status = array_pop( $status );
$memberships = $student->get_memberships(
array(
- 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 106.
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 'courses_expired':
$status = explode( '_', $key );
$status = array_pop( $status );
$courses = $student->get_courses(
array(
- 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 106.
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