CORE-POS/IS4C

View on GitHub
fannie/batches/UNFI/load-classes/AlbertsUploadPage.php

Summary

Maintainability
C
1 day
Test Coverage
C
75%

Method process_file has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function process_file($linedata, $indexes)
    {
        $dbc = $this->connection;
        $dbc->selectDB($this->config->get('OP_DB'));
        $VENDOR_ID = $this->getVendorID();
Severity: Major
Found in fannie/batches/UNFI/load-classes/AlbertsUploadPage.php - About 2 hrs to fix

    Function process_file has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        function process_file($linedata, $indexes)
        {
            $dbc = $this->connection;
            $dbc->selectDB($this->config->get('OP_DB'));
            $VENDOR_ID = $this->getVendorID();
    Severity: Minor
    Found in fannie/batches/UNFI/load-classes/AlbertsUploadPage.php - About 1 hr 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 parseSize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function parseSize($str, $scale)
        {
            if (strstr(strtolower($str), 'bin')) {
                if (!$scale && preg_match('/(\d+)\s*-(\d+)\s*ct/', strtolower($str), $matches)) {
                    $case = ($matches[1] + $matches[2]) / 2;
    Severity: Minor
    Found in fannie/batches/UNFI/load-classes/AlbertsUploadPage.php - About 45 mins 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

    Avoid too many return statements within this method.
    Open

                return array(trim($case), 'ea');
    Severity: Major
    Found in fannie/batches/UNFI/load-classes/AlbertsUploadPage.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return array(1, $str);
      Severity: Major
      Found in fannie/batches/UNFI/load-classes/AlbertsUploadPage.php - About 30 mins to fix

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

            private function cleanUPC($upc)
            {
                if (strlen($upc) == 5 && substr($upc, 0, 1) == '9' && $upc !== '99999') {
                    return BarcodeLib::padUPC(substr($upc, 1));
                }
        Severity: Major
        Found in fannie/batches/UNFI/load-classes/AlbertsUploadPage.php and 4 other locations - About 4 hrs to fix
        fannie/modules/plugins2.0/USFoodsInvoiceGrabber/USFTask.php on lines 272..286
        fannie/purchasing/importers/AlbertsInvoiceImport.php on lines 101..115
        fannie/purchasing/importers/RdwInvoiceImport.php on lines 134..148
        fannie/purchasing/importers/UsFoodsInvoiceImport.php on lines 220..234

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

        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

        Similar blocks of code found in 7 locations. Consider refactoring.
        Open

            protected $preview_opts = array(
                'upc' => array(
                    'display_name' => 'UPC *',
                    'default' => 7,
                    'required' => true
        Severity: Major
        Found in fannie/batches/UNFI/load-classes/AlbertsUploadPage.php and 6 other locations - About 2 hrs to fix
        fannie/batches/UNFI/load-classes/CpwProduceUploadPage.php on lines 17..43
        fannie/batches/UNFI/load-classes/CpwUploadPage.php on lines 37..63
        fannie/batches/UNFI/load-classes/RdwUploadPage.php on lines 38..64
        fannie/batches/xlsbatch/XlsBatchPage.php on lines 40..66
        fannie/modules/plugins2.0/WfcGazetteBilling/WfcGazetteBillingPage.php on lines 13..39
        fannie/purchasing/importers/CpwInvoiceImport.php on lines 99..125

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

        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

        There are no issues that match your filters.

        Category
        Status