HaaseIT/HCSF

View on GitHub

Showing 151 of 151 total issues

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

<?php

/*
    HCSF - A multilingual CMS and Shopsystem
    Copyright (C) 2014  Marcus Haase - mail@marcus.haase.name
Severity: Major
Found in src/Controller/Admin/ClearImageCache.php and 1 other location - About 2 hrs to fix
src/Controller/Admin/ClearTemplateCache.php on lines 1..38

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

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

Function buildCustomerForm has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function buildCustomerForm($sLang, $sPurpose = 'none', $aErr = [], $aUserData = false)
    {
        $sDefaultCountry = $this->getCustomerFormDefaultValue('cust_country', 'country', $aUserData);

        // Purposes: shoppingcart, userhome, shopadmin, editprofile, register
Severity: Minor
Found in src/Customer/Helper.php - About 2 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 addAdditionalCostsToItems has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addAdditionalCostsToItems($aSumme, $iVATfull, $iVATreduced)
    {
        $fGesamtnetto = $aSumme['sumvoll'] + $aSumme['sumerm'];
        $fSteuervoll = $aSumme['sumvoll'] * $iVATfull / 100;
        $fSteuererm = $aSumme['sumerm'] * $iVATreduced / 100;
Severity: Major
Found in src/Shop/Helper.php - About 2 hrs to fix

    Method validateCustomerForm has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function validateCustomerForm($sLang, $aErr = [], $bEdit = false)
        {
            if (empty(filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL))) {
                $aErr['email'] = true;
            }
    Severity: Major
    Found in src/Customer/Helper.php - About 2 hrs to fix

      Method updateGroup has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function updateGroup()
          {
              $purifier = false;
              if ($this->config->getShop('itemgrouptext_enable_purifier')) {
                  $purifier = $this->helper->getPurifier('itemgroup');
      Severity: Major
      Found in src/Controller/Admin/Shop/Itemgroupadmin.php - About 2 hrs to fix

        Function preparePage has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function preparePage()
            {
                $this->P = new \HaaseIT\HCSF\CorePage($this->serviceManager);
                $this->P->cb_pagetype = 'content';
        
        
        Severity: Minor
        Found in src/Controller/Customer/Register.php - About 2 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 loadNavigation has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function loadNavigation(ServiceManager $serviceManager)
            {
                if (is_file(PATH_BASEDIR.'config/navigation.yml')) {
                    $navstruct = Yaml::parse(file_get_contents(PATH_BASEDIR.'config/navigation.yml'));
                } else {
        Severity: Minor
        Found in src/HelperConfig.php - About 2 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 init has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function init()
            {
                $this->serviceManager = new ServiceManager();
        
                if (!CLI) {
        Severity: Major
        Found in src/HCSF.php - About 2 hrs to fix

          Method updateItem has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function updateItem()
              {
                  $purifier = false;
                  if ($this->config->getShop('itemtext_enable_purifier')) {
                      $purifier = $this->helper->getPurifier('item');
          Severity: Major
          Found in src/Controller/Admin/Shop/Itemadmin.php - About 2 hrs to fix

            Function removeDataWhere has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function removeDataWhere($field, $needle, $fieldtoremove)
                {
                    foreach ($this->items as $key => $item) {
                        if (!empty($item['itm_data']->$field)) {
                            if ($needle) {
            Severity: Minor
            Found in src/Controller/CLI/Itemdata.php - About 2 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 queryItemWhereClause has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function queryItemWhereClause($mItemIndex = '', $mItemno = '')
                {
                    $sql = ' WHERE ';
                    $getsearchtext = filter_input(INPUT_GET, 'searchtext', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
                    if (!empty($mItemno)) {
            Severity: Minor
            Found in src/Shop/Items.php - About 2 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 getLanguage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getLanguage()
                {
                    $langavailable = $this->core['lang_available'];
                    if (
                        $this->core['lang_detection_method'] === 'domain'
            Severity: Minor
            Found in src/HelperConfig.php - About 2 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 getLogin has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getLogin()
                {
                    $bTryEmail = false;
                    if ('cust_no' !== 'cust_email') {
                        $bTryEmail = true;
            Severity: Minor
            Found in src/Controller/Customer/Login.php - About 2 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 handleEditPage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function handleEditPage()
                {
                    $requestpagekey = filter_input(INPUT_GET, 'page_key', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
                    if ($requestpagekey !== null && $Ptoedit = new UserPage($this->serviceManager, $requestpagekey, true)) {
                        if (filter_input(INPUT_POST, 'action_a') === 'true') {
            Severity: Minor
            Found in src/Controller/Admin/Pageadmin.php - About 2 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 preparePage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function preparePage()
                {
                    $this->P = new \HaaseIT\HCSF\CorePage($this->serviceManager);
                    $this->P->cb_pagetype = 'content';
            
            
            Severity: Minor
            Found in src/Controller/Shop/Myorders.php - About 2 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 handleEditPage has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function handleEditPage()
                {
                    $requestpagekey = filter_input(INPUT_GET, 'page_key', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
                    if ($requestpagekey !== null && $Ptoedit = new UserPage($this->serviceManager, $requestpagekey, true)) {
                        if (filter_input(INPUT_POST, 'action_a') === 'true') {
            Severity: Major
            Found in src/Controller/Admin/Pageadmin.php - About 2 hrs to fix

              Function showMyOrders has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function showMyOrders($COList)
                  {
                      $return = '';
                      $sql = 'SELECT * FROM orders WHERE o_custno = :custno ORDER BY o_ordertimestamp DESC';
              
              
              Severity: Minor
              Found in src/Controller/Shop/Myorders.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 handleItemPage has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function handleItemPage(ServiceManager $serviceManager, \HaaseIT\HCSF\Page $P, array $aP)
                  {
                      $mItemIndex = '';
                      if (isset($P->cb_pageconfig->itemindex)) {
                          $mItemIndex = $P->cb_pageconfig->itemindex;
              Severity: Minor
              Found in src/Shop/Helper.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

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

                  private function getItemgroups($iGID = '') // this function should be outsourced, a duplicate is used in admin itemgroups!
                  {
                      $querybuilder = $this->dbal->createQueryBuilder();
                      $querybuilder
                          ->select('*')
              Severity: Major
              Found in src/Controller/Admin/Shop/Itemadmin.php and 1 other location - About 1 hr to fix
              src/Controller/Admin/Shop/Itemgroupadmin.php on lines 280..300

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

              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 2 locations. Consider refactoring.
              Open

                  private function getItemgroups($iGID = '')
                  {
                      $querybuilder = $this->dbal->createQueryBuilder();
                      $querybuilder
                          ->select('*')
              Severity: Major
              Found in src/Controller/Admin/Shop/Itemgroupadmin.php and 1 other location - About 1 hr to fix
              src/Controller/Admin/Shop/Itemadmin.php on lines 434..454

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

              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