Showing 8,683 of 8,684 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2015 Whole Foods Co-op
- 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 135.
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
File MemEquityTransferTool.php
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2010,2013 Whole Foods Co-op, Duluth, MN
Consider simplifying this complex logical expression. Open
if ($mode == self::MODE_VERBATIM && !is_numeric($qtty)) {
$this->msg = _('invalid quantity<br />enter number');
return true;
} elseif ($mode == self::MODE_PRECISE && strpos($qtty, ".") == 2) {
$this->boxColor="errorColoredArea";
TransRecord
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class TransRecord
{
/*------------------------------------------------------------------------------
additem.php is the bread and butter of IT CORE. addItem inserts the information
Consider simplifying this complex logical expression. Open
if ($row['discounttype'] == 3 && $row['trans_status'] == 'V') {
return $row['ItemQtty'] . ' /' . $row['unitPrice'];
} elseif ($row['voided'] == 5) {
return 'Discount';
} elseif ($row['trans_status'] == 'M') {
ObfWeeklyReport
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class ObfWeeklyReport extends FannieReportPage
{
public function preprocess()
{
if (!headers_sent()) {
OriginEditor
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class OriginEditor extends FannieRESTfulPage
{
protected $header = 'Product Origins';
protected $title = 'Product Origins';
Class DateTimeUtils
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
internal static class DateTimeUtils
{
internal static readonly long InitialJavaScriptDateTicks = 621355968000000000;
private const int DaysPer100Years = 36524;
File manual.js
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
function skuField(row, vendor_id)
{
var sku = $('<input type="text" name="sku[]" required />')
.addClass('form-control')
.addClass('item-sku')
Function tenderEditor
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
var tenderEditor = (function($) {
var mod = {};
var ajax_url = 'TenderEditor.php';
var _popover = function(data, elem, orig) {
Function getNumSeats
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getNumSeats()
{
var upc = $('#curUpc').val();
var notified = $('#notified').val();
var n = 0;
Function lineChart
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
mod.lineChart = function(elemID, labels, points, dayName) {
var ctx = document.getElementById(elemID).getContext('2d');
var line = new Chart(ctx, {
type: 'line',
responsive: false,
Method drawKeys
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function drawKeys($filter='')
{
$launcher = new QuickKeyLauncher($this->session);
$my_keys = $launcher->getKeys(CoreLocal::get('qkNumber'), $filter);
Method body_content
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function body_content()
{
$local = array();
$other = array();
$dbc = Database::tDataConnect();
Method curlSend
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function curlSend($data=False,$type='POST',$xml=False, $extraOpts=array(), $autoHandle=true)
{
if($data && $type == 'GET') {
$this->GATEWAY .= $data;
}
Method form_content
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function form_content()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
$this->addScript('correlated.js');
Method body_content
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function body_content()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
Method fetch_report_data
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetch_report_data()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
$date1 = $this->form->date1;
Method WFC_AnythingOnATag
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function WFC_AnythingOnATag($data,$offset=0){
$pdf=new WFC_AnythingOnATag_PDF('P','mm','Letter'); //start new instance of PDF
$pdf->Open(); //open new PDF Document
$pdf->setTagDate(date("m/d/Y"));
Method WFC_Dark_Simple_24UP
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function WFC_Dark_Simple_24UP ($data,$offset=0)
{
$dbc = FannieDB::get(FannieConfig::config('OP_DB'));
$pdf = new WFC_Dark_Simple_24UP_PDF('L','mm','Letter');
$pdf->AddPage();