APO-Epsilon/apo-website

View on GitHub
exec_permissions.php

Summary

Maintainability
C
1 day
Test Coverage

list_exec_by_page accesses the super-global variable $_SERVER.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

show_exec accesses the super-global variable $_GET.
Open

function show_exec() {
    if(isset($_GET['page_id'])) {
        list_exec_by_page();
    } else if(isset($_GET['position_id'])) {
        list_page_by_exec();
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_GET.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_SERVER.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_SERVER.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_GET.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_GET.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_GET.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_SERVER.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_SERVER.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_SERVER.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_GET.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

show_exec accesses the super-global variable $_GET.
Open

function show_exec() {
    if(isset($_GET['page_id'])) {
        list_exec_by_page();
    } else if(isset($_GET['position_id'])) {
        list_page_by_exec();
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_GET.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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

list_positions accesses the super-global variable $_SERVER.
Open

function list_positions() {
    include('mysql_access.php');
    $sql = "SELECT position, position_id FROM positions ORDER BY position_order ASC;";
    $result = $db->query($sql);
    echo "<div class=\"medium-6 small-12 columns\">";
Severity: Minor
Found in exec_permissions.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

list_pages accesses the super-global variable $_SERVER.
Open

function list_pages() {
    include('mysql_access.php');
    $sql = "SELECT page, entry_id FROM exec_permissions_pages ORDER BY page ASC;";
    $result = $db->query($sql);
    echo "<div class=\"medium-6 small-12 columns\">";
Severity: Minor
Found in exec_permissions.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

list_exec_by_page accesses the super-global variable $_GET.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.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

list_page_by_exec accesses the super-global variable $_GET.
Open

function list_page_by_exec() {
    if(isset($_GET['remove'])) {
        remove_permission($_GET['remove'], $_GET['position_id']);
    } elseif(isset($_GET['add'])) {
        add_permission($_GET['add'], $_GET['position_id']);
Severity: Minor
Found in exec_permissions.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 list_exec_by_page has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function list_exec_by_page() {
    include('mysql_access.php');
    if(isset($_GET['remove'])) {
        $sql = "SELECT position_id FROM positions WHERE position=\"{$_GET['remove']}\";";
        $result = $db->query($sql);
Severity: Minor
Found in exec_permissions.php - About 1 hr to fix

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

    function list_page_by_exec() {
        if(isset($_GET['remove'])) {
            remove_permission($_GET['remove'], $_GET['position_id']);
        } elseif(isset($_GET['add'])) {
            add_permission($_GET['add'], $_GET['position_id']);
    Severity: Minor
    Found in exec_permissions.php - About 1 hr to fix

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

              $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$db' which will lead to PHP notices.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

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

          } else {
              echo "<div class='small-12 columns text-center'><h2>Permissions Manager</h2></div>";
              list_pages();
              list_positions();
          }
      Severity: Minor
      Found in exec_permissions.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 add_permission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

          } else {
              echo "$position permission added for $page";
          }
      Severity: Minor
      Found in exec_permissions.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 remove_permission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

          } else {
              echo "$position permission removed for $page";
          }
      Severity: Minor
      Found in exec_permissions.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 unused local variables such as '$db'.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.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 '$db'.
      Open

          $result = $db->query($sql);
      Severity: Minor
      Found in exec_permissions.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

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

      function remove_permission($pageId, $execId) {
          include('mysql_access.php');
          $sql = "SELECT page FROM exec_permissions_pages WHERE entry_id=$pageId;";
          $result = $db->query($sql);
          $row = mysqli_fetch_array($result);
      Severity: Major
      Found in exec_permissions.php and 1 other location - About 4 hrs to fix
      exec_permissions.php on lines 35..52

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

      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 add_permission($pageId, $execId) {
          include('mysql_access.php');
          $sql = "SELECT page FROM exec_permissions_pages WHERE entry_id=$pageId;";
          $result = $db->query($sql);
          $row = mysqli_fetch_array($result);
      Severity: Major
      Found in exec_permissions.php and 1 other location - About 4 hrs to fix
      exec_permissions.php on lines 149..166

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

      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

      A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 23 and the first side effect is on line 2.
      Open

      <?php
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Line exceeds 120 characters; contains 285 characters
      Open

          $sql = "SELECT exec_permissions.page AS page, exec_permissions_pages.entry_id AS page_id FROM exec_permissions_pages INNER JOIN exec_permissions ON exec_permissions.page=exec_permissions_pages.page WHERE exec_permissions.position=\"$position\" ORDER BY exec_permissions.page ASC;";
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Line exceeds 120 characters; contains 151 characters
      Open

              echo "<tr><td>{$row['page']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?page_id={$row['entry_id']}\" class=\"button expand\">Edit</a></td></tr>";
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Line exceeds 120 characters; contains 162 characters
      Open

              echo "<tr><td>{$row['position']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?position_id={$row['position_id']}\" class=\"button expand\">Edit</a></td></tr>";
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Line exceeds 120 characters; contains 214 characters
      Open

          $sql = "SELECT exec_permissions.position AS position FROM exec_permissions_pages INNER JOIN exec_permissions ON exec_permissions.page=exec_permissions_pages.page WHERE exec_permissions_pages.entry_id=$pageId;";
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Line exceeds 120 characters; contains 172 characters
      Open

              echo "<tr><td>{$row['position']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?page_id=$pageId&remove={$row['position']}\" class=\"button expand\">Remove</a></td></tr>";
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Line exceeds 120 characters; contains 186 characters
      Open

              echo "<tr><td>{$row['page']}</td><td><a href=\"{$_SERVER['PHP_SELF']}?position_id={$_GET['position_id']}&remove={$row['page_id']}\" class=\"button expand\">Remove</a></td></tr>";
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Usage of ELSE IF is discouraged; use ELSEIF instead
      Open

          } else if(isset($_GET['position_id'])) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function list_pages() {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after WHILE keyword; 0 found
      Open

          while($row = mysqli_fetch_array($result)) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Space before opening parenthesis of function call prohibited
      Open

      require_once ('session.php');
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

          if(!$result) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after WHILE keyword; 0 found
      Open

          while($row = mysqli_fetch_array($result)) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after WHILE keyword; 0 found
      Open

          while($row = mysqli_fetch_array($result)) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function list_page_by_exec() {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

          if(!$result) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after WHILE keyword; 0 found
      Open

          while($row = mysqli_fetch_array($result)) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after ELSEIF keyword; 0 found
      Open

          } elseif(isset($_GET['add'])) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

          if(isset($_GET['remove'])) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function remove_permission($pageId, $execId) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after ELSEIF keyword; 0 found
      Open

          } elseif(isset($_GET['add'])) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function add_permission($pageId, $execId) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

          if(isset($_GET['page_id'])) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after WHILE keyword; 0 found
      Open

          while($row = mysqli_fetch_array($result)) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function list_positions() {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function show_exec() {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

          if(isset($_GET['remove'])) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

          } else if(isset($_GET['position_id'])) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Opening brace should be on a new line
      Open

      function list_exec_by_page() {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      Expected 1 space after WHILE keyword; 0 found
      Open

          while($row = mysqli_fetch_array($result)) {
      Severity: Minor
      Found in exec_permissions.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status