CORE-POS/IS4C

View on GitHub

Showing 8,683 of 8,684 total issues

Function body_content has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    public function body_content()
    {
        $dbc = $this->connection;
        $dbc->selectDB($this->config->get('OP_DB'));
        $transDB = $this->config->get('TRANS_DB') . $dbc->sep();
Severity: Minor
Found in fannie/reports/SalesToday/SalesTodayReport2.php - About 5 hrs to fix

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 getTime has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTime($string)
    {
        $regex = '/(\d{1,2}\s{0,2}(?:am|pm|(?::\d\d)){0,1}\s{0,2}(?:am|pm){0,1})(?:\s{0,2}(?:-|to|till|until)\s{0,2}(\d{1,2}\s{0,2}(?:am|pm|(?::\d\d)){0,1}\s{0,2}(?:am|pm){0,1}))?/i';
        $ret = false;
        if (preg_match($regex, $string, $matches)) {
Severity: Minor
Found in fannie/modules/plugins2.0/CalendarPlugin/CalendarFeed.php - About 5 hrs to fix

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 sort has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    public function sort(array $rowset)
    {
        $tax = false;
        $discount = false;
        $total = false;
Severity: Minor
Found in fannie/modules/plugins2.0/EReceipt/EReceiptSort.php - About 5 hrs to fix

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 post_printFY_handler has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    function post_printFY_handler()
    {
        global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
        $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
        if (!class_exists('FPDF')) {
Severity: Minor
Found in fannie/modules/plugins2.0/GiveUsMoneyPlugin/GumIssueDividendPage.php - About 5 hrs to fix

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 process has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    public function process($filename)
    {
        $fp = fopen($filename, 'r');
        $currentOrder = array('id' => false, 'total' => 0, 'tax' => 0, 'card_no' => 11, 'memType'=>0, 'tdate' => '');
        $trans_id = 1;
Severity: Minor
Found in fannie/modules/plugins2.0/Mercato/MercatoIntake.php - About 5 hrs to fix

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 pushTable has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    static public function pushTable($table,$db='op',$truncate=self::TRUNCATE_DESTINATION,$includeOffline=false)
    {
        $config = \FannieConfig::factory();
        $op_db = $config->get('OP_DB');
        $trans_db = $config->get('TRANS_DB');
Severity: Minor
Found in fannie/classlib2.0/data/SyncLanes.php - About 5 hrs to fix

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 CreateDynamic has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring.
Open

        private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, JsonProperty member, string id)
        {
            IDynamicMetaObjectProvider newObject;

            if (!contract.IsInstantiable)

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

File PrehLib.php has 405 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Copyright 2001, 2004 Wedge Community Co-op

Severity: Minor
Found in pos/is4c-nf/lib/PrehLib.php - About 5 hrs to fix

    File FpdfEditorPage.php has 405 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /*******************************************************************************
    
        Copyright 2015 Whole Foods Co-op
    
    
    Severity: Minor
    Found in fannie/admin/labels/FpdfEditorPage.php - About 5 hrs to fix

      File WFC_Hybrid_Single.php has 405 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      if (!class_exists('FpdfWithBarcode')) {
          include(dirname(__FILE__) . '/../FpdfWithBarcode.php');
      }
      if (!class_exists('FpdfLib')) {
      Severity: Minor
      Found in fannie/admin/labels/pdf_layouts/WFC_Hybrid_Single.php - About 5 hrs to fix

        Method get_id_view has 143 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function get_id_view()
            {
                $id = trim($this->id);
                if (!preg_match('/^\d+-\d+$/', $id)) {
                    return '<div class="alert alert-danger">Order Number should be two numbers separated by a dash</div>
        Severity: Major
        Found in fannie/modules/plugins2.0/Pickup/PickupOrders.php - About 5 hrs to fix

          Method get_id_pdf_handler has 143 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get_id_pdf_handler()
              {
                  if (!class_exists('FPDF')) {
                      include(__DIR__ . '/../../../src/fpdf/fpdf.php');
                      define('FPDF_FONTPATH','font/');
          Severity: Major
          Found in fannie/modules/plugins2.0/GiveUsMoneyPlugin/GumLoanPayoffPage.php - About 5 hrs to fix

            Method get_view has 143 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function get_view()
                {
                    $storeID = Store::getIdByIp();
                    $storeID=1;
                    $catP = $this->connection->prepare("SELECT deliCategoryID, name, salesCode FROM DeliCategories WHERE storeID=? ORDER BY seq, name");
            Severity: Major
            Found in fannie/modules/plugins2.0/DeliInventory/DIPage.php - About 5 hrs to fix

              Method get_orderID_customer_handler has 143 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function get_orderID_customer_handler()
                  {
                      $dbc = $this->connection;
                      $dbc->selectDB($this->config->get('OP_DB'));
                      $TRANS = $this->config->get('TRANS_DB') . $dbc->sep();
              Severity: Major
              Found in fannie/ordering/OrderReviewPage.php - About 5 hrs to fix

                Method getCustomerNonForm has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getCustomerNonForm($orderID)
                {
                    global $FANNIE_OP_DB, $TRANS, $FANNIE_TRANS_DB;
                    $dbc = FannieDB::get($FANNIE_OP_DB);
                
                
                Severity: Major
                Found in fannie/ordering/ajax-calls.php - About 5 hrs to fix

                  Method get_id_view has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function get_id_view()
                      {
                          $dbc = FannieDB::get($this->config->get('OP_DB'));
                          $ret = '<div id="myform" style="background-color: white;">
                              <form method="post">
                  Severity: Major
                  Found in fannie/item/vendors/VendorAliasesPage.php - About 5 hrs to fix

                    File EditItemsFromSearch.php has 405 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    /*******************************************************************************
                    
                        Copyright 2013 Whole Foods Community Co-op
                    
                    
                    Severity: Minor
                    Found in fannie/item/EditItemsFromSearch.php - About 5 hrs to fix

                      Method form_content has 142 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function form_content()
                          {
                              $storepicker = FormLib::storePicker();
                              $store = FormLib::get('store');
                              $datepicker = FormLib::date_range_picker();
                      Severity: Major
                      Found in fannie/reports/EquitySales/EquitySalesReport.php - About 5 hrs to fix

                        Method post_u_view has 142 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function post_u_view()
                            {
                                global $FANNIE_OP_DB, $FANNIE_URL, $FANNIE_ARCHIVE_DB;
                                $dbc = FannieDB::get($FANNIE_OP_DB);
                                $this->addScript($FANNIE_URL.'src/javascript/tablesorter/jquery.tablesorter.js');
                        Severity: Major
                        Found in fannie/item/MarginToolFromSearch.php - About 5 hrs to fix

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  foreach($hbKeys as $hbKey) {
                                      $hbTarget = "$hbPrefix" . ++$hbNumber;
                                      if (isset($hbLongMessage["$hbKey"]) && $hbLongMessage["$hbKey"] != "") {
                                          $anyMore = $hbMore;
                                          $onClick = " onclick=\"$('#{$hbTarget}').toggle();return false;\" ";
                          fannie/modules/plugins2.0/CoopCred/programs/CoopCredConfigEditor.php on lines 319..341

                          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 197.

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language