Showing 8,683 of 8,684 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('.super'+superID).each(function(){
pArray.push($(this).find('.newprice').val());
uArray.push($(this).find('.itemupc').val());
});
- 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 84.
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 run
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
$dbc = FannieDB::get($this->config->get('OP_DB'));
$place = $dbc->prepare("UPDATE PurchaseOrder SET placed=1, placedDate=? WHERE orderID=?");
$map = new AutoOrderMapModel($dbc);
Method post_createBatch_handler
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function post_createBatch_handler()
{
global $FANNIE_OP_DB;
$dbc = FannieDB::get($FANNIE_OP_DB);
try {
Method form_content
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function form_content()
{
ob_start();
?>
<form method="get" class="form-horizontal">
Method fetch_report_data
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetch_report_data()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
$date1 = $this->form->date1;
Method receiptHeader
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function receiptHeader($date,$trans)
{
$totime = strtotime($date);
list($emp_no, $reg_no, $trans_no) = explode('-', $trans, 3);
$store = FormLib::get('store', false);
Method WFC_New
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function WFC_New($data,$offset=0){
$pdf=new WFC_New_PDF('P','mm','Letter'); //start new instance of PDF
$pdf->Open(); //open new PDF Document
$pdf->setTagDate(date("m/d/Y"));
Method formTableHeader
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function formTableHeader()
{
if (FannieConfig::config('COOP_ID') == 'WFC_Duluth') {
$ret = SignsLib::visualSignSelectHTML();
$this->addOnloadCommand(SignsLib::visualSignSelectJS());
Method generateMirrorMeatTag
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateMirrorMeatTag($x, $y, $guide, $width, $height, $pdf, $row, $dbc)
{
$upc = isset($row['upc']) ? $row['upc'] : '';
$desc = isset($row['description']) ? $row['description'] : '';
$brand = isset($row['brand']) ? $row['brand'] : '';
Method getTenderTable
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getTenderTable()
{
$this->connection->selectDB($this->config->get('OP_DB'));
$model = new TendersModel($this->connection);
Method generateMirrorNewMeatTag
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateMirrorNewMeatTag($x, $y, $guide, $width, $height, $pdf, $row, $dbc)
{
$upc = isset($row['upc']) ? $row['upc'] : '';
$desc = isset($row['description']) ? $row['description'] : '';
$brand = isset($row['brand']) ? $row['brand'] : '';
Method fetch_report_data
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetch_report_data()
{
$items = explode("\n", $this->form->items);
$ts1 = strtotime('last tuesday');
// -13 => previous wednesday and then back another full week
Method post_handler
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function post_handler()
{
try {
$date = $this->form->date;
$orig = $this->form->trans;
Method get_date_trans_store_handler
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_date_trans_store_handler()
{
global $FANNIE_OP_DB;
$dbc = FannieDB::get($FANNIE_OP_DB);
$dlog = DTransactionsModel::selectDlog($this->date);
Method post
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function post($json)
{
$dbc = $this->dbc;
$ret = array('error' => false);
$dbc->selectDB($this->config->get('OP_DB'));
Method run
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
$aplfile = $this->download($this->URL);
if ($aplfile === false) {
$this->cronMsg('MN APL file is empty or damaged', FannieLogger::ALERT);
Method post_id_shares_type_handler
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function post_id_shares_type_handler()
{
global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB, $FANNIE_URL;
$bridge = GumLib::getSetting('posLayer');
Method drawPDF
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function drawPDF()
{
$pdf = $this->createPDF();
$dbc = FannieDB::get(FannieConfig::config('OP_DB'));
$basicP = $dbc->prepare("SELECT
Method send
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function send($incident, $address)
{
if (!OutgoingEmail::available()) {
// can't send
return false;
Method basicPreview
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function basicPreview()
{
$ret = '<h3>Select columns</h3>';
/* show any errors */
if ($this->error_details != 'n/a' && $this->error_details != '') {