File comment.php
has 916 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Manages WordPress comments
*
* @package WordPress
Function check_comment
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
global $wpdb;
if ( 1 == get_option('comment_moderation') )
return false; // If moderation is set to manual
- 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 pingback
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function pingback($content, $post_ID) {
global $wp_version;
include_once(ABSPATH . WPINC . '/class-IXR.php');
// original code by Mort (http://mort.mine.nu:8080)
- 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_comment
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function &get_comment(&$comment, $output = OBJECT) {
global $wpdb;
$null = null;
if ( empty($comment) ) {
- 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 check_comment
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
global $wpdb;
if ( 1 == get_option('comment_moderation') )
return false; // If moderation is set to manual
Method get_comments
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_comments( $args = '' ) {
global $wpdb;
$defaults = array('status' => '', 'orderby' => 'comment_date_gmt', 'order' => 'DESC', 'number' => '', 'offset' => '', 'post_id' => 0);
Function wp_allow_comment
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function wp_allow_comment($commentdata) {
global $wpdb;
extract($commentdata, EXTR_SKIP);
// Simple duplicate check
- 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_comments
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function get_comments( $args = '' ) {
global $wpdb;
$defaults = array('status' => '', 'orderby' => 'comment_date_gmt', 'order' => 'DESC', 'number' => '', 'offset' => '', 'post_id' => 0);
- 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 get_comment_count
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_comment_count( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_id;
Method wp_set_comment_status
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
global $wpdb;
$status = '0';
switch ( $comment_status ) {
Function wp_count_comments
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function wp_count_comments( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_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 get_page_of_comment
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function get_page_of_comment( $comment_ID, $args = array() ) {
global $wpdb;
if ( !$comment = get_comment( $comment_ID ) )
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
Method discover_pingback_server_uri
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function discover_pingback_server_uri($url, $deprecated = 2048) {
$pingback_str_dquote = 'rel="pingback"';
$pingback_str_squote = 'rel=\'pingback\'';
Method pingback
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function pingback($content, $post_ID) {
global $wp_version;
include_once(ABSPATH . WPINC . '/class-IXR.php');
// original code by Mort (http://mort.mine.nu:8080)
Method get_comment
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function &get_comment(&$comment, $output = OBJECT) {
global $wpdb;
$null = null;
if ( empty($comment) ) {
Function get_comment_pages_count
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
global $wp_query;
if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
return $wp_query->max_num_comment_pages;
- 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 discover_pingback_server_uri
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function discover_pingback_server_uri($url, $deprecated = 2048) {
$pingback_str_dquote = 'rel="pingback"';
$pingback_str_squote = 'rel=\'pingback\'';
- 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 get_page_of_comment
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_page_of_comment( $comment_ID, $args = array() ) {
global $wpdb;
if ( !$comment = get_comment( $comment_ID ) )
return;
Method wp_allow_comment
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_allow_comment($commentdata) {
global $wpdb;
extract($commentdata, EXTR_SKIP);
// Simple duplicate check
Method wp_count_comments
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_count_comments( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_id;
Method wp_delete_comment
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_delete_comment($comment_id) {
global $wpdb;
if (!$comment = get_comment($comment_id))
return false;
Function wp_set_comment_status
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
global $wpdb;
$status = '0';
switch ( $comment_status ) {
- 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 do_trackbacks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function do_trackbacks($post_id) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) );
$to_ping = get_to_ping($post_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
Method do_trackbacks
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function do_trackbacks($post_id) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) );
$to_ping = get_to_ping($post_id);
Method wp_insert_comment
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_insert_comment($commentdata) {
global $wpdb;
extract(stripslashes_deep($commentdata), EXTR_SKIP);
if ( ! isset($comment_author_IP) )
Function wp_insert_comment
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function wp_insert_comment($commentdata) {
global $wpdb;
extract(stripslashes_deep($commentdata), EXTR_SKIP);
if ( ! isset($comment_author_IP) )
- 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 wp_new_comment
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function wp_new_comment( $commentdata ) {
$commentdata = apply_filters('preprocess_comment', $commentdata);
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
if ( isset($commentdata['user_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
Method check_comment
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
Function wp_blacklist_check
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
$mod_keys = trim( get_option('blacklist_keys') );
if ( '' == $mod_keys )
- 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 wp_blacklist_check
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
Function wp_update_comment
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function wp_update_comment($commentarr) {
global $wpdb;
// First, get all of the original fields
$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
- 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
Consider simplifying this complex logical expression. Open
if (
preg_match($pattern, $author)
|| preg_match($pattern, $email)
|| preg_match($pattern, $url)
|| preg_match($pattern, $comment)
Function wp_get_comment_status
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function wp_get_comment_status($comment_id) {
$comment = get_comment($comment_id);
if ( !$comment )
return false;
- 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 wp_delete_comment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function wp_delete_comment($comment_id) {
global $wpdb;
if (!$comment = get_comment($comment_id))
return false;
- 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_comment_count
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function get_comment_count( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_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 check_comment_flood_db
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function check_comment_flood_db( $ip, $email, $date ) {
global $wpdb;
if ( current_user_can( 'manage_options' ) )
return; // don't throttle admins
$hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 );
- 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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
if ( preg_match($pattern, $comment) ) return false;
Avoid too many return
statements within this method. Open
if ( preg_match($pattern, $user_agent) ) return false;
Avoid too many return
statements within this method. Open
if ( preg_match($pattern, $user_ip) ) return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
if ( preg_match($pattern, $url) ) return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return 'trash';
Avoid too many return
statements within this method. Open
return $open;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $pingback_server_url;
Avoid too many return
statements within this method. Open
return ceil( ( $oldercoms + 1 ) / $args['per_page'] );
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return 'spam';
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $_comment;
Function separate_comments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function &separate_comments(&$comments) {
$comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());
$count = count($comments);
for ( $i = 0; $i < $count; $i++ ) {
$type = $comments[$i]->comment_type;
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
$comment_author_email = stripslashes($comment_author_email);
$comment_author_email = esc_attr($comment_author_email);
$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
- 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 92.
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 ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
$comment_author = stripslashes($comment_author);
$comment_author = esc_attr($comment_author);
$_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
- 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 92.
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