Showing 7,504 of 7,504 total issues
Method saveAttachment
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function saveAttachment($name, $offset, $length, $image_mime=null) {
try {
// do not extract at all
if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
Method wp_admin_bar_wp_menu
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_admin_bar_wp_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu( array(
'id' => 'wp-logo',
'title' => '<span class="ab-icon"></span>',
'href' => self_admin_url( 'about.php' ),
Method update_callback
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update_callback( $widget_args = 1 ) {
global $wp_registered_widgets;
if ( is_numeric($widget_args) )
$widget_args = array( 'number' => $widget_args );
Method wp_convert_widget_settings
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_convert_widget_settings($base_name, $option_name, $settings) {
// This test may need expanding.
$single = $changed = false;
if ( empty($settings) ) {
$single = true;
Method dynamic_sidebar
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dynamic_sidebar($index = 1) {
global $wp_registered_sidebars, $wp_registered_widgets;
if ( is_int($index) ) {
$index = "sidebar-$index";
Method find
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
{
if ($this->is_feed($this->file))
{
return $this->file;
Method get_description
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_description()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
Method unknown
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function unknown()
{
$ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
|| strtolower(substr($this->file->body, $ws, 5)) === '<html'
Method query
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function query($query) {
if ( ! $this->ready )
return false;
// filter the query, if filters are available
Method append
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function append($el, $text) {
if (!$el) {
return;
}
if ( $this->current_namespace )
Method get_description
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_description()
{
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
Method get_description
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_description()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
Method find
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
{
if ($this->is_feed($this->file))
{
return $this->file;
Method get_description
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_description($description_only = false)
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
Method get_adjacent_post
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) {
global $post, $wpdb;
if ( empty($post) || !is_single() || is_attachment() )
return null;
Method wpmu_activate_signup
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wpmu_activate_signup($key) {
global $wpdb;
$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
Method offsetGet
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function offsetGet( $offset ) {
switch ( $offset ) {
case 'Name' :
case 'Title' :
// See note above about using translated data. get() is not ideal.
Function buildGame
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildGame(aShots: string): any {
const upperShots = aShots.toUpperCase();
const game = { frames: [], score: 0, fouls: 0 };
const normalizedShots = [];
Method Connect
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Connect($host,$port=0,$tval=30) {
# set the error val to null so there is no confusion
$this->error = null;
# make sure we are __not__ connected
Identical blocks of code found in 2 locations. Consider refactoring. Open
function convertVersionString(versionString){
var r = versionString.split('.');
return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
}
- 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