mambax7/adslight

View on GitHub
include/search.inc.php

Summary

Maintainability
A
3 hrs
Test Coverage

adslight_search accesses the super-global variable $_SERVER.
Open

function adslight_search(
    $queryarray,
    $andor,
    $limit,
    $offset,
Severity: Minor
Found in include/search.inc.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method adslight_search has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function adslight_search(
    $queryarray,
    $andor,
    $limit,
    $offset,
Severity: Minor
Found in include/search.inc.php - About 1 hr to fix

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

    function adslight_search(
        $queryarray,
        $andor,
        $limit,
        $offset,
    Severity: Minor
    Found in include/search.inc.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 adslight_search has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        $queryarray,
        $andor,
        $limit,
        $offset,
        $userid
    Severity: Minor
    Found in include/search.inc.php - About 35 mins to fix

      Avoid using static access to class '\XoopsModules\Adslight\Utility' in method 'adslight_search'.
      Open

              $ret[$i]['type']  = Utility::getNameType($myrow['type']);
      Severity: Minor
      Found in include/search.inc.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\XoopsModules\Adslight\Helper' in method 'adslight_search'.
      Open

          $helper = Helper::getInstance();
      Severity: Minor
      Found in include/search.inc.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\MyTextSanitizer' in method 'adslight_search'.
      Open

              $myts    = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in include/search.inc.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid assigning values to variables in if clauses and the like (line '57', column '34').
      Open

      function adslight_search(
          $queryarray,
          $andor,
          $limit,
          $offset,
      Severity: Minor
      Found in include/search.inc.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      There must be one USE keyword per declaration
      Open

      use XoopsModules\Adslight\{
      Severity: Minor
      Found in include/search.inc.php by phpcodesniffer

      Line exceeds 120 characters; contains 347 characters
      Open

              $sql .= " AND ((title LIKE '%{$queryarray[0]}%' OR type LIKE '%{$queryarray[0]}%' OR desctext LIKE '%{$queryarray[0]}%' OR tel LIKE '%{$queryarray[0]}%' OR price LIKE '%{$queryarray[0]}%' OR typeprice LIKE '%{$queryarray[0]}%' OR submitter LIKE '%{$queryarray[0]}%' OR town LIKE '%{$queryarray[0]}%' OR country LIKE '%{$queryarray[0]}%')";
      Severity: Minor
      Found in include/search.inc.php by phpcodesniffer

      Line exceeds 120 characters; contains 140 characters
      Open

              $sql     = 'SELECT url FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$myrow['lid']} ORDER BY date_created LIMIT 1 ";
      Severity: Minor
      Found in include/search.inc.php by phpcodesniffer

      Line exceeds 120 characters; contains 223 characters
      Open

          $sql = 'SELECT lid,title,type,desctext,tel,price,typeprice,date_created,submitter,usid,town,country FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='Yes' AND status!='1' AND date_created<=" . time() . ' ';
      Severity: Minor
      Found in include/search.inc.php by phpcodesniffer

      Line exceeds 120 characters; contains 354 characters
      Open

                  $sql .= "(title LIKE '%{$queryarray[$i]}%' OR type LIKE '%{$queryarray[$i]}%' OR desctext LIKE '%{$queryarray[$i]}%' OR tel LIKE '%{$queryarray[$i]}%' OR price LIKE '%{$queryarray[$i]}%' OR typeprice LIKE '%{$queryarray[$i]}%' OR submitter LIKE '%{$queryarray[$i]}%' OR town LIKE '%{$queryarray[$i]}%' OR country LIKE '%{$queryarray[$i]}%')";
      Severity: Minor
      Found in include/search.inc.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status