mambax7/smartfaq

View on GitHub

Showing 374 of 649 total issues

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

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

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

function b_faqs_new_edit($options)
{
    global $xoopsDB, $xoopsModule, $xoopsUser;
    //    require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php';

Severity: Minor
Found in blocks/faqs_new.php - About 1 hr to fix

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

        public function insert(XoopsObject $object, $force = false)
        {
            if ('xoopsmodules\smartfaq\answer' !== \mb_strtolower(\get_class($object))) {
                return false;
            }
    Severity: Minor
    Found in class/AnswerHandler.php - About 1 hr to fix

      Method getLinkedUnameFromId has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function getLinkedUnameFromId($userid = 0, $name = 0, $users = [])
          {
              if (!\is_numeric($userid)) {
                  return $userid;
              }
      Severity: Minor
      Found in class/Utility.php - About 1 hr to fix

        Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct($id = null)
            {
                $this->db = XoopsDatabaseFactory::getDatabaseConnection();
                $this->initVar('faqid', \XOBJ_DTYPE_INT, -1, false);
                $this->initVar('categoryid', \XOBJ_DTYPE_INT, 0, false);
        Severity: Minor
        Found in class/Faq.php - About 1 hr to fix

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

          function loadTableFromArrayWithReplace($table, $data, $search, $replace)
          {
              /** @var \XoopsMySQLDatabase $db */
              $db = \XoopsDatabaseFactory::getDatabaseConnection();
          
          
          Severity: Minor
          Found in testdata/index.php - About 1 hr to fix

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

            function b_faqs_recent_questions_edit($options)
            {
                //    require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php';
            
                $form = Smartfaq\Utility::createCategorySelect($options[0]);
            Severity: Minor
            Found in blocks/faqs_recent_questions.php - About 1 hr to fix

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

              function xoops_module_install_smartfaq(\XoopsModule $module)
              {
                  require \dirname(__DIR__, 3) . '/mainfile.php';
              
                  $moduleDirName = \basename(\dirname(__DIR__));
              Severity: Minor
              Found in include/oninstall.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 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

                    Function parseShadowExtras has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function parseShadowExtras(pf, i, ar) {
                        var k = i, v;
                        if (k < ar.length) {
                            if (ar[k] == SHADOW) {
                                eval(pf + 'shadow=(' + pf + 'shadow==0)?1:0');
                    Severity: Minor
                    Found in assets/js/overlib/mini/overlib_shadow_mini.js - About 1 hr to fix

                      Function parseShadowExtras has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function parseShadowExtras(pf, i, ar) {
                          var k = i, v;
                      
                          if (k < ar.length) {
                              if (ar[k] == SHADOW) {
                      Severity: Minor
                      Found in assets/js/overlib/overlib_shadow.js - About 1 hr to fix

                        Method getServerStats has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function getServerStats()
                            {
                                //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
                                $moduleDirName      = \basename(\dirname(__DIR__, 2));
                                $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
                        Severity: Minor
                        Found in class/Common/ServerStats.php - About 1 hr to fix

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

                              public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups)
                          Severity: Major
                          Found in class/Common/Blocksadmin.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

                              Method b_faqs_new_show has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function b_faqs_new_show($options)
                              {
                                  //    require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php';
                              
                                  $block = [];
                              Severity: Minor
                              Found in blocks/faqs_new.php - About 1 hr to fix

                                Method b_faqs_recent_questions_show has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function b_faqs_recent_questions_show($options)
                                {
                                    //    require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/functions.php';
                                
                                    $block = [];
                                Severity: Minor
                                Found in blocks/faqs_recent_questions.php - About 1 hr to fix

                                  Method answer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function answer()
                                      {
                                          $answerHandler = new Smartfaq\AnswerHandler($this->db);
                                          switch ($this->status()) {
                                              case Constants::SF_STATUS_SUBMITTED:
                                  Severity: Minor
                                  Found in class/Faq.php - About 1 hr to fix

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

                                    function parseExclusiveExtras(pf, i, ar) {
                                        var k = i, v;
                                        olOverrideIsSet = false;
                                        if (k < ar.length) {
                                            if (ar[k] == EXCLUSIVEOVERRIDE) {
                                    Severity: Minor
                                    Found in assets/js/overlib/mini/overlib_exclusive_mini.js - 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language