mambax7/pedigree

View on GitHub
include/functions.php

Summary

Maintainability
F
1 wk
Test Coverage

File functions.php has 551 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
Severity: Major
Found in include/functions.php - About 1 day to fix

    Function createList has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    function createList($result, $prefix, $link, $element)
    {
        global $xoopsTpl;
        $animal = new Pedigree\Animal();
        //test to find out how many user fields there are...
    Severity: Minor
    Found in include/functions.php - About 4 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 pups has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    function pups($oid, $gender)
    {
        global $numofcolumns, $numMatch, $pages, $columns, $dogs;
        $content = '';
        if (0 == $gender) {
    Severity: Minor
    Found in include/functions.php - About 4 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 bas has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    function bas($oid, $pa, $ma)
    {
        global $numofcolumns1, $nummatch1, $pages1, $columns1, $dogs1;
        if ('0' == $pa && '0' == $ma) {
            $sqlQuery = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE father = ' . $pa . ' AND mother = ' . $ma . ' AND id != ' . $oid . " AND father != '0' AND mother !='0' ORDER BY pname";
    Severity: Minor
    Found in include/functions.php - About 4 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 pups has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function pups($oid, $gender)
    {
        global $numofcolumns, $numMatch, $pages, $columns, $dogs;
        $content = '';
        if (0 == $gender) {
    Severity: Major
    Found in include/functions.php - About 3 hrs to fix

      Method createList has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createList($result, $prefix, $link, $element)
      {
          global $xoopsTpl;
          $animal = new Pedigree\Animal();
          //test to find out how many user fields there are...
      Severity: Major
      Found in include/functions.php - About 3 hrs to fix

        Method bas has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function bas($oid, $pa, $ma)
        {
            global $numofcolumns1, $nummatch1, $pages1, $columns1, $dogs1;
            if ('0' == $pa && '0' == $ma) {
                $sqlQuery = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE father = ' . $pa . ' AND mother = ' . $ma . ' AND id != ' . $oid . " AND father != '0' AND mother !='0' ORDER BY pname";
        Severity: Major
        Found in include/functions.php - About 2 hrs to fix

          Method createThumbs has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createThumbs($filename)
          {
              /*
                  require_once __DIR__ . '/phpthumb/phpthumb.class.php';
                  $thumbnail_widths = array(150, 400);
          Severity: Minor
          Found in include/functions.php - About 1 hr to fix

            Function createThumbs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function createThumbs($filename)
            {
                /*
                    require_once __DIR__ . '/phpthumb/phpthumb.class.php';
                    $thumbnail_widths = array(150, 400);
            Severity: Minor
            Found in include/functions.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

            Method lettersChoice has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function lettersChoice()
            {
                $helper = Helper::getInstance();
                $helper->loadLanguage('main');
                xoops_load('XoopsLocal');
            Severity: Minor
            Found in include/functions.php - About 1 hr to fix

              Function lettersChoice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function lettersChoice()
              {
                  $helper = Helper::getInstance();
                  $helper->loadLanguage('main');
                  xoops_load('XoopsLocal');
              Severity: Minor
              Found in include/functions.php - About 25 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

              Function breederof has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function breederof($oid, $breeder)
              {
                  $content = '';
              
                  if (0 == $breeder) {
              Severity: Minor
              Found in include/functions.php - About 25 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

              Function uploadPicture has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function uploadPicture($num)
              {
                  $max_imgsize       = $GLOBALS['xoopsModuleConfig']['maxfilesize']; //1024000;
                  $max_imgwidth      = $GLOBALS['xoopsModuleConfig']['maximgwidth']; //1500;
                  $max_imgheight     = $GLOBALS['xoopsModuleConfig']['maximgheight']; //1000;
              Severity: Minor
              Found in include/functions.php - About 25 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

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

                      for ($i = 1; $i < $numofcolumns; ++$i) {
                          $x = $columns[$i]['columnnumber'];
                          if (is_array($columns[$i]['lookupval'])) {
                              foreach ($columns[$i]['lookupval'] as $key => $keyValue) {
                                  if ($keyValue['id'] == $rowResult['user' . $x]) {
              Severity: Major
              Found in include/functions.php and 1 other location - About 5 hrs to fix
              include/functions.php on lines 365..382

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

              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

                      for ($i = 1; $i < $numofcolumns1; ++$i) {
                          $x = $columns1[$i]['columnnumber'];
                          if (is_array($columns1[$i]['lookupval'])) {
                              foreach ($columns1[$i]['lookupval'] as $key => $keyValue) {
                                  if ($keyValue['id'] == $rowResult['user' . $x]) {
              Severity: Major
              Found in include/functions.php and 1 other location - About 5 hrs to fix
              include/functions.php on lines 279..296

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

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

                  if (0 == $gender) {
                      $sqlQuery = 'SELECT d.id AS d_id, d.pname AS d_pname, d.roft AS d_roft, d.* FROM '
                                  . $GLOBALS['xoopsDB']->prefix('pedigree_registry')
                                  . ' d LEFT JOIN '
                                  . $GLOBALS['xoopsDB']->prefix('pedigree_registry')
              Severity: Major
              Found in include/functions.php and 2 other locations - About 3 hrs to fix
              0old/pedigreeUtilities0.php on lines 224..244
              class/Utility.php on lines 295..315

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

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

                  foreach ($fields as $i => $iValue) {
                      $userField   = new Pedigree\Field($fields[$i], $animal->getConfig());
                      $fieldType   = $userField->getSetting('fieldtype');
                      $fieldObject = new $fieldType($userField, $animal);
                      //create empty string
              Severity: Major
              Found in include/functions.php and 8 other locations - About 3 hrs to fix
              class/Utility.php on lines 324..344
              class/Utility.php on lines 411..431
              include/functions.php on lines 247..267
              add_dog.php on lines 290..310
              add_dog.php on lines 473..493
              add_litter.php on lines 285..305
              add_litter.php on lines 454..474
              virtual.php on lines 151..171

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

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

                  foreach ($fields as $i => $iValue) {
                      $userField   = new Pedigree\Field($fields[$i], $animal->getConfig());
                      $fieldType   = $userField->getSetting('fieldtype');
                      $fieldObject = new $fieldType($userField, $animal);
                      //create empty string
              Severity: Major
              Found in include/functions.php and 8 other locations - About 3 hrs to fix
              class/Utility.php on lines 324..344
              class/Utility.php on lines 411..431
              include/functions.php on lines 332..352
              add_dog.php on lines 290..310
              add_dog.php on lines 473..493
              add_litter.php on lines 285..305
              add_litter.php on lines 454..474
              virtual.php on lines 151..171

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

              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

                  foreach ($fields as $i => $iValue) {
                      $userField   = new Pedigree\Field($fields[$i], $animal->getConfig());
                      $fieldType   = $userField->getSetting('fieldtype');
                      $fieldObject = new $fieldType($userField, $animal);
                      if ($userField->isActive() && $userField->inList()) {
              Severity: Major
              Found in include/functions.php and 1 other location - About 3 hrs to fix
              0old/pedigreeUtilities0.php on lines 494..512

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

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

                  if ('0' == $pa && '0' == $ma) {
                      $sqlQuery = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE father = ' . $pa . ' AND mother = ' . $ma . ' AND id != ' . $oid . " AND father != '0' AND mother !='0' ORDER BY pname";
                  } else {
                      $sqlQuery = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE father = ' . $pa . ' AND mother = ' . $ma . ' AND id != ' . $oid . ' ORDER BY pname';
                  }
              Severity: Major
              Found in include/functions.php and 2 other locations - About 1 hr to fix
              0old/pedigreeUtilities0.php on lines 325..329
              class/Utility.php on lines 398..402

              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

              function animal_meta_keywords($content)
              {
                  global $xoopsTpl, $xoTheme;
                  $myts    = \MyTextSanitizer::getInstance();
                  $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
              Severity: Major
              Found in include/functions.php and 1 other location - About 1 hr to fix
              include/functions.php on lines 649..659

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

              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

              function animal_meta_description($content)
              {
                  global $xoopsTpl, $xoTheme;
                  $myts    = \MyTextSanitizer::getInstance();
                  $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
              Severity: Major
              Found in include/functions.php and 1 other location - About 1 hr to fix
              include/functions.php on lines 633..643

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

              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