mambax7/smartfaq

View on GitHub
class/FaqHandler.php

Summary

Maintainability
F
1 wk
Test Coverage

File FaqHandler.php has 738 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace XoopsModules\Smartfaq;

/**
Severity: Major
Found in class/FaqHandler.php - About 1 day to fix

    Function getFaqsFromSearch has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getFaqsFromSearch($queryarray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
        {
            global $xoopsUser;
    
            $ret              = [];
    Severity: Minor
    Found in class/FaqHandler.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 getContextualFaqs has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getContextualFaqs($limit = 0)
        {
            $ret = false;
    
            $otherCriteria = new \CriteriaCompo();
    Severity: Minor
    Found in class/FaqHandler.php - About 3 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 getFaqsFromSearch has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFaqsFromSearch($queryarray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
        {
            global $xoopsUser;
    
            $ret              = [];
    Severity: Major
    Found in class/FaqHandler.php - About 3 hrs to fix

      Method insert has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function insert(\XoopsObject $object, $force = false)
          {
              if ('xoopsmodules\smartfaq\faq' !== \mb_strtolower(\get_class($object))) {
                  return false;
              }
      Severity: Major
      Found in class/FaqHandler.php - About 3 hrs to fix

        Method getObjectsAdminSide has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getObjectsAdminSide(\CriteriaElement $criteria = null, $id_as_key = false, $notNullFields = '')
            {
                $ret   = [];
                $limit = $start = 0;
                $sql   = 'SELECT
        Severity: Major
        Found in class/FaqHandler.php - About 2 hrs to fix

          FaqHandler has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class FaqHandler extends \XoopsObjectHandler
          {
              protected $helper;
          
              /**
          Severity: Minor
          Found in class/FaqHandler.php - About 2 hrs to fix

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

                public function getContextualFaqs($limit = 0)
                {
                    $ret = false;
            
                    $otherCriteria = new \CriteriaCompo();
            Severity: Major
            Found in class/FaqHandler.php - About 2 hrs to fix

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

                  public function getObjectsAdminSide(\CriteriaElement $criteria = null, $id_as_key = false, $notNullFields = '')
                  {
                      $ret   = [];
                      $limit = $start = 0;
                      $sql   = 'SELECT
              Severity: Minor
              Found in class/FaqHandler.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 getFaqs has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getFaqs(
                      $limit = 0,
                      $start = 0,
                      $status = '',
                      $categoryid = -1,
              Severity: Minor
              Found in class/FaqHandler.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 getObjects has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getObjects(\CriteriaElement $criteria = null, $id_as_key = false, $notNullFields = '')
                  {
                      $ret   = [];
                      $limit = $start = 0;
                      $sql   = 'SELECT * FROM ' . $this->db->prefix('smartfaq_faq');
              Severity: Minor
              Found in class/FaqHandler.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 getFaqs has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getFaqs(
                      $limit = 0,
                      $start = 0,
                      $status = '',
                      $categoryid = -1,
              Severity: Major
              Found in class/FaqHandler.php - About 2 hrs to fix

                Method getFaqsCount has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getFaqsCount($categoryid = -1, $status = '', $notNullFields = '')
                    {
                        global $xoopsUser;
                
                        //  if ( ($categoryid = -1) && (empty($status) || ($status == -1)) ) {
                Severity: Minor
                Found in class/FaqHandler.php - About 1 hr to fix

                  Method getObjects has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getObjects(\CriteriaElement $criteria = null, $id_as_key = false, $notNullFields = '')
                      {
                          $ret   = [];
                          $limit = $start = 0;
                          $sql   = 'SELECT * FROM ' . $this->db->prefix('smartfaq_faq');
                  Severity: Minor
                  Found in class/FaqHandler.php - About 1 hr to fix

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

                        public function getFaqsCount($categoryid = -1, $status = '', $notNullFields = '')
                        {
                            global $xoopsUser;
                    
                            //  if ( ($categoryid = -1) && (empty($status) || ($status == -1)) ) {
                    Severity: Minor
                    Found in class/FaqHandler.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 getLastPublishedByCat has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getLastPublishedByCat($status = [Constants::SF_STATUS_PUBLISHED, Constants::SF_STATUS_NEW_ANSWER])
                        {
                            $ret       = [];
                            $faqclause = '';
                            if (!Smartfaq\Utility::userIsAdmin()) {
                    Severity: Minor
                    Found in class/FaqHandler.php - About 1 hr to fix

                      Method getFaqsAdminSide has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getFaqsAdminSide(
                              $limit = 0,
                              $start = 0,
                              $status = '',
                              $categoryid = -1,
                      Severity: Minor
                      Found in class/FaqHandler.php - About 1 hr to fix

                        Method getFaqs has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                $limit = 0,
                                $start = 0,
                                $status = '',
                                $categoryid = -1,
                                $sort = 'datesub',
                        Severity: Major
                        Found in class/FaqHandler.php - About 1 hr to fix

                          Function insert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function insert(\XoopsObject $object, $force = false)
                              {
                                  if ('xoopsmodules\smartfaq\faq' !== \mb_strtolower(\get_class($object))) {
                                      return false;
                                  }
                          Severity: Minor
                          Found in class/FaqHandler.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 getCountsByCat has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function getCountsByCat($cat_id, $status)
                              {
                                  global $xoopsUser;
                                  $ret = [];
                                  $sql = 'SELECT categoryid, COUNT(*) AS count FROM ' . $this->db->prefix('smartfaq_faq');
                          Severity: Minor
                          Found in class/FaqHandler.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 getCount has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function getCount($criteria = null, $notNullFields = '')
                              {
                                  $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('smartfaq_faq');
                                  if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
                                      $whereClause = $criteria->renderWhere();
                          Severity: Minor
                          Found in class/FaqHandler.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 getCountsByCat has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getCountsByCat($cat_id, $status)
                              {
                                  global $xoopsUser;
                                  $ret = [];
                                  $sql = 'SELECT categoryid, COUNT(*) AS count FROM ' . $this->db->prefix('smartfaq_faq');
                          Severity: Minor
                          Found in class/FaqHandler.php - About 1 hr to fix

                            Method getFaqsAdminSide has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    $limit = 0,
                                    $start = 0,
                                    $status = '',
                                    $categoryid = -1,
                                    $sort = 'datesub',
                            Severity: Major
                            Found in class/FaqHandler.php - About 1 hr to fix

                              Function getFaqsAdminSide has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function getFaqsAdminSide(
                                      $limit = 0,
                                      $start = 0,
                                      $status = '',
                                      $categoryid = -1,
                              Severity: Minor
                              Found in class/FaqHandler.php - About 55 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

                              Method getAllPublished has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      $limit = 0,
                                      $start = 0,
                                      $categoryid = -1,
                                      $sort = 'datesub',
                                      $order = 'DESC',
                              Severity: Minor
                              Found in class/FaqHandler.php - About 45 mins to fix

                                Method getFaqsFromSearch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public function getFaqsFromSearch($queryarray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
                                Severity: Minor
                                Found in class/FaqHandler.php - About 35 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return $ret;
                                  Severity: Major
                                  Found in class/FaqHandler.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return true;
                                    Severity: Major
                                    Found in class/FaqHandler.php - About 30 mins to fix

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

                                          public function NotNullFieldClause($notNullFields = '', $withAnd = false)
                                          {
                                              $ret = '';
                                              if ($withAnd) {
                                                  $ret .= ' AND ';
                                      Severity: Minor
                                      Found in class/FaqHandler.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

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

                                              if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
                                                  $whereClause = $criteria->renderWhere();
                                      
                                                  if ('WHERE ()' !== $whereClause) {
                                                      $sql .= ' ' . $criteria->renderWhere();
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 5 hrs to fix
                                      class/FaqHandler.php on lines 252..270

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

                                      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

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

                                              if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
                                                  $whereClause = $criteria->renderWhere();
                                      
                                                  if ('WHERE ()' !== $whereClause) {
                                                      $sql .= ' ' . $criteria->renderWhere();
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 5 hrs to fix
                                      class/FaqHandler.php on lines 333..351

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

                                      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

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

                                              if (!$userIsAdmin) {
                                                  /** @var Smartfaq\PermissionHandler $smartPermHandler */
                                                  $smartPermHandler = Smartfaq\Helper::getInstance()->getHandler('Permission');
                                      
                                                  $categoriesGranted = $smartPermHandler->getPermissions('category');
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 4 hrs to fix
                                      class/FaqHandler.php on lines 563..577

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

                                      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

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

                                              if (!$userIsAdmin) {
                                                  /** @var Smartfaq\PermissionHandler $smartPermHandler */
                                                  $smartPermHandler = Smartfaq\Helper::getInstance()->getHandler('Permission');
                                      
                                                  $categoriesGranted = $smartPermHandler->getPermissions('category');
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 4 hrs to fix
                                      class/FaqHandler.php on lines 441..455

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

                                      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

                                          public function updateAll($fieldname, $fieldvalue, $criteria = null)
                                          {
                                              $set_clause = \is_numeric($fieldvalue) ? $fieldname . ' = ' . $fieldvalue : $fieldname . ' = ' . $this->db->quoteString($fieldvalue);
                                              $sql        = 'UPDATE ' . $this->db->prefix('smartfaq_faq') . ' SET ' . $set_clause;
                                              if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
                                      Severity: Major
                                      Found in class/FaqHandler.php and 2 other locations - About 2 hrs to fix
                                      class/AnswerHandler.php on lines 371..384
                                      class/CategoryHandler.php on lines 466..478

                                      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

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

                                          public function __construct(\XoopsDatabase $db = null, \XoopsModules\Smartfaq\Helper $helper = null)
                                          {
                                              /** @var \XoopsModules\Smartfaq\Helper $this ->helper */
                                              if (null === $helper) {
                                                  $this->helper = \XoopsModules\Smartfaq\Helper::getInstance();
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 2 hrs to fix
                                      class/CategoryHandler.php on lines 28..42

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

                                      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

                                          public function get($id)
                                          {
                                              if ((int)$id > 0) {
                                                  $sql = 'SELECT * FROM ' . $this->db->prefix('smartfaq_faq') . ' WHERE faqid=' . $id;
                                                  if (!$result = $this->db->query($sql)) {
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 2 hrs to fix
                                      class/AnswerHandler.php on lines 69..87

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

                                      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

                                              if (!empty($status) && \is_array($status)) {
                                                  $criteriaStatus = new \CriteriaCompo();
                                                  foreach ($status as $v) {
                                                      $criteriaStatus->add(new \Criteria('status', $v), 'OR');
                                                  }
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 1 hr to fix
                                      class/FaqHandler.php on lines 661..669

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

                                      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

                                              if (!empty($status) && \is_array($status)) {
                                                  $criteriaStatus = new \CriteriaCompo();
                                                  foreach ($status as $v) {
                                                      $criteriaStatus->add(new \Criteria('faq.status', $v), 'OR');
                                                  }
                                      Severity: Major
                                      Found in class/FaqHandler.php and 1 other location - About 1 hr to fix
                                      class/FaqHandler.php on lines 587..595

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

                                      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

                                          public function deleteAll($criteria = null)
                                          {
                                              $sql = 'DELETE FROM ' . $this->db->prefix('smartfaq_faq');
                                              if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
                                                  $sql .= ' ' . $criteria->renderWhere();
                                      Severity: Minor
                                      Found in class/FaqHandler.php and 1 other location - About 40 mins to fix
                                      class/CategoryHandler.php on lines 442..455

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

                                      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