CORE-POS/IS4C

View on GitHub

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

fannie/classlib2.0/data/models/trans/SpecialOrderEditsModel.php on lines 1..49

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

Further Reading

File MemEquityTransferTool.php has 278 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*******************************************************************************

    Copyright 2010,2013 Whole Foods Co-op, Duluth, MN

Severity: Minor
Found in fannie/mem/correction_pages/MemEquityTransferTool.php - About 2 hrs to fix

    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";
    Severity: Critical
    Found in pos/is4c-nf/gui-modules/QuantityEntryPage.php - About 2 hrs to fix

      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
      Severity: Minor
      Found in pos/is4c-nf/lib/TransRecord.php - About 2 hrs to fix

        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') {
        Severity: Critical
        Found in pos/is4c-nf/lib/DisplayLib.php - About 2 hrs to fix

          ObfWeeklyReport has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ObfWeeklyReport extends FannieReportPage
          {
              public function preprocess()
              {
                  if (!headers_sent()) {
          Severity: Minor
          Found in fannie/modules/plugins2.0/OpenBookFinancing/ObfWeeklyReport.php - About 2 hrs to fix

            OriginEditor has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class OriginEditor extends FannieRESTfulPage 
            {
                protected $header = 'Product Origins';
                protected $title = 'Product Origins';
            
            
            Severity: Minor
            Found in fannie/item/origins/OriginEditor.php - About 2 hrs to fix

              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')
                Severity: Minor
                Found in fannie/purchasing/js/manual.js - About 2 hrs to fix

                  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) {
                  Severity: Major
                  Found in fannie/admin/Tenders/edit.js - About 2 hrs to fix

                    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;
                    Severity: Major
                    Found in fannie/modules/plugins2.0/WfcClassRegistry/WfcClassRegistry.js - About 2 hrs to fix

                      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,
                      Severity: Major
                      Found in fannie/reports/SalesToday/stChart.js - About 2 hrs to fix

                        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);
                        
                        
                        Severity: Major
                        Found in pos/is4c-nf/plugins/QuickKeys/QKDisplay.php - About 2 hrs to fix

                          Method body_content has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function body_content()
                              {
                                  $local = array();
                                  $other = array();
                                  $dbc = Database::tDataConnect();
                          Severity: Major
                          Found in pos/is4c-nf/plugins/Paycards/gui/PaycardTransListPage.php - About 2 hrs to fix

                            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;
                                    }
                            Severity: Major
                            Found in pos/is4c-nf/plugins/Paycards/BasicCCModule.php - About 2 hrs to fix

                              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');
                              Severity: Major
                              Found in fannie/reports/Correlated/CorrelatedMovementReport.php - About 2 hrs to fix

                                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'));
                                
                                
                                Severity: Major
                                Found in fannie/reports/PriceDiscrepancies/PriceDiscrepancies.php - About 2 hrs to fix

                                  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;
                                  Severity: Major
                                  Found in fannie/reports/VendorSales/VendorSalesReport.php - About 2 hrs to fix

                                    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"));
                                    Severity: Major
                                    Found in fannie/admin/labels/pdf_layouts/WFC_AnythingOnATag.php - About 2 hrs to fix

                                      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();
                                      Severity: Major
                                      Found in fannie/admin/labels/pdf_layouts/WFC_Dark_Simple_24UP.php - About 2 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language