mambax7/alumni-26x

View on GitHub
class/plugin/search.php

Summary

Maintainability
A
3 hrs
Test Coverage

Method search has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function search($queryArray, $andor, $limit, $offset, $userid)
    {
        $xoops           = Xoops::getInstance();
        $helper          = Xoops::getModuleHelper('alumni');
        $module_id       = $helper->getModule()->getVar('mid');
Severity: Minor
Found in class/plugin/search.php - About 1 hr to fix

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

        public function search($queryArray, $andor, $limit, $offset, $userid)
        {
            $xoops           = Xoops::getInstance();
            $helper          = Xoops::getModuleHelper('alumni');
            $module_id       = $helper->getModule()->getVar('mid');
    Severity: Minor
    Found in class/plugin/search.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 search has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function search($queryArray, $andor, $limit, $offset, $userid)
    Severity: Minor
    Found in class/plugin/search.php - About 35 mins to fix

      The method search uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $qb->setParameter(':uid', (int)$userid, \PDO::PARAM_INT);
                  $qb->andWhere($eb->eq('usid', ':uid'));
              }
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

      The method search uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      $qb->andWhere(call_user_func_array([$eb, 'orX'], $queryParts));
                  }
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

      Avoid using static access to class 'Xoops' in method 'search'.
      Open

              $xoops           = Xoops::getInstance();
      Severity: Minor
      Found in class/plugin/search.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 'search'.
      Open

              $myts   = MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/plugin/search.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 '\Xoops\Core\Request' in method 'search'.
      Open

              $by_cat = Request::getInt('by_cat', 0);
      Severity: Minor
      Found in class/plugin/search.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 'Xoops' in method 'search'.
      Open

              $helper          = Xoops::getModuleHelper('alumni');
      Severity: Minor
      Found in class/plugin/search.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 unused local variables such as '$listing_Handler'.
      Open

              $listing_Handler = $helper->getHandler('listing');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      UnusedLocalVariable

      Since: 0.2

      Detects when a local variable is declared and/or assigned, but not used.

      Example

      class Foo {
          public function doSomething()
          {
              $i = 5; // Unused
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

      Avoid unused local variables such as '$myts'.
      Open

              $myts   = MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      UnusedLocalVariable

      Since: 0.2

      Detects when a local variable is declared and/or assigned, but not used.

      Example

      class Foo {
          public function doSomething()
          {
              $i = 5; // Unused
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

      Each class must be in a namespace of at least one level (a top-level vendor name)
      Open

      class AlumniSearchPlugin extends PluginAbstract implements SearchPluginInterface
      Severity: Minor
      Found in class/plugin/search.php by phpcodesniffer

      Avoid variables with short names like $eb. Configured minimum length is 3.
      Open

              $eb = $qb->expr();
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $qb. Configured minimum length is 3.
      Open

              $qb = \Xoops::getInstance()->db()->createXoopsQueryBuilder();
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Line exceeds 120 characters; contains 168 characters
      Open

              $qb->select('DISTINCT *')->fromPrefix('alumni_listing')->where($eb->eq('valid', '1'))->orderBy('lname', 'DESC')->setFirstResult($offset)->setMaxResults($limit);
      Severity: Minor
      Found in class/plugin/search.php by phpcodesniffer

      Line exceeds 120 characters; contains 180 characters
      Open

                      $queryParts[] = $eb->orX($eb->like('name', $query), $eb->like('mname', $query), $eb->like('lname', $query), $eb->like('school', $query), $eb->like('year', $query));
      Severity: Minor
      Found in class/plugin/search.php by phpcodesniffer

      Line exceeds 120 characters; contains 152 characters
      Open

                      'title' => $myrow['name'] . ' ' . $myrow['mname'] . ' ' . $myrow['lname'] . '   ---   ' . $myrow['school'] . ' ---   ' . $myrow['year'],
      Severity: Minor
      Found in class/plugin/search.php by phpcodesniffer

      The variable $alumni_ids is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $all_ids is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $listing_Handler is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $module_id is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $by_cat is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $alumni_ids is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $all_ids is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $module_id is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $by_cat is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $by_cat is not named in camelCase.
      Open

          public function search($queryArray, $andor, $limit, $offset, $userid)
          {
              $xoops           = Xoops::getInstance();
              $helper          = Xoops::getModuleHelper('alumni');
              $module_id       = $helper->getModule()->getVar('mid');
      Severity: Minor
      Found in class/plugin/search.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status