PascalHonegger/M151

View on GitHub

Showing 137 of 137 total issues

Avoid excessively long variable names like $passwordRegularExpression. Keep variable name length under 20.
Open

    private static $passwordRegularExpression = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@!%*?&_-])[A-Za-z\d$@!%*?&_-]{8,}/';
Severity: Minor
Found in Login/RegisterController.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

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

Function applySettings has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function applySettings() {
    var username = $("#Username").val();
    var name = $("#Name").val();
    var surname = $("#Surname").val();
    var mail = $("#Mail").val();
Severity: Minor
Found in EditSettings/EditSettingsScript.js - About 1 hr to fix

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

                    array_push($validImages, $image);
    Severity: Minor
    Found in Location/FileManager.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

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

        function __construct(array $location)
        {
            echo '
            <div id="' . $location['id_location'] . '" class="contentLocation">
                <table style="width:100%" class="table" onclick="openlocation(' . $location['id_location'] . ', \'' . $location['name'] . '\')">
    Severity: Minor
    Found in Discover/DiscoverRowBuilder.php - About 1 hr to fix

      Function createLocation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createLocation() {
          var genericFormData = new FormData($("form")[1]);
      
          $.ajax({
              type: "POST",
      Severity: Minor
      Found in Location/CreateLocationScript.js - About 1 hr to fix

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

            public function updateSettings(string $newUsername, string $newName, string $newSurname, string $newMail, string $newPassword, string $newRepPassword, string $secret, string $authenticatorCode)
        Severity: Major
        Found in EditSettings/EditSettingsController.php - About 1 hr to fix

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

              public function loadLocations(int $from, int $to, string $nameFilter)
          Severity: Minor
          Found in Discover/DiscoverController.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

          Function createLocation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function createLocation(int $idCreator, string $name, string $description, string $position){
                  if (strlen($name) < 50 && strlen($name) > 1 && strlen($description) < 100 && strlen($description) > 1) {
                      $inserted = $this->model->creatLocation($idCreator, $name, $description, $position);
          
                      if($inserted){
          Severity: Minor
          Found in Location/LocationController.php - About 45 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 registerPerson has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function registerPerson(string $username, string $password, string $repeatPassword, string $surname, string $name, string $mail)
          Severity: Minor
          Found in Login/RegisterController.php - About 45 mins to fix

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

                public static function inputValid(string $username, string $password, string $repeatPassword, string $surname, string $name, string $mail)
            Severity: Minor
            Found in Login/RegisterController.php - About 45 mins to fix

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

                  public function update(string $username, string $name, string $surname, string $mail, $password, $secret)
              Severity: Minor
              Found in model/EditSettingsModel.php - About 45 mins to fix

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

                    public function insert(string $username, string $password, string $surname, string $name, string $mail)
                Severity: Minor
                Found in model/RegisterModel.php - About 35 mins to fix

                  Missing class import via use statement (line '28', column '33').
                  Open

                          $this->loginModel = new LoginModel();

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Missing class import via use statement (line '29', column '27').
                  Open

                          $loginModel = new LoginModel();
                  Severity: Minor
                  Found in model/RegisterModel.php by phpmd

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Missing class import via use statement (line '25', column '30').
                  Open

                            $this->model = new LocationModel();
                  Severity: Minor
                  Found in Location/LocationController.php by phpmd

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Missing class import via use statement (line '24', column '22').
                  Open

                          $model = new EventModel();
                  Severity: Minor
                  Found in Event/NewEventController.php by phpmd

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Missing class import via use statement (line '16', column '22').
                  Open

                          $model = new EventModel();
                  Severity: Minor
                  Found in Events/EventsController.php by phpmd

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Missing class import via use statement (line '27', column '28').
                  Open

                          $this->model = new EditSettingsModel();

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Missing class import via use statement (line '34', column '17').
                  Open

                              new DiscoverRowBuilder($location);
                  Severity: Minor
                  Found in Discover/DiscoverController.php by phpmd

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Missing class import via use statement (line '24', column '28').
                  Open

                          $this->model = new LoginModel();
                  Severity: Minor
                  Found in Login/LoginController.php by phpmd

                  MissingImport

                  Since: 2.7.0

                  Importing all external classes in a file through use statements makes them clearly visible.

                  Example

                  function make() {
                      return new \stdClass();
                  }

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

                  Severity
                  Category
                  Status
                  Source
                  Language