takeawaytown/laravel-uuid

View on GitHub

Showing 109 of 109 total issues

Line indented incorrectly; expected 12 spaces, found 6
Open

      if (!$model->{config('uuid.uuid_column')}) {
Severity: Minor
Found in src/Traits/Uuid.php by phpcodesniffer

Argument 1 (get_as_float) is 1 but \microtime() takes bool
Open

        $time = microtime(1) * 10000000 + static::INTERVAL;
Severity: Minor
Found in src/Classes/Uuid.php by phan

Call to undeclared function \config()
Open

      $uuid = $model->getOriginal(config('uuid.uuid_column'));
Severity: Critical
Found in src/Traits/Uuid.php by phan

Call to method __construct from undeclared class \Illuminate\Database\Eloquent\ModelNotFoundException
Open

      throw (new ModelNotFoundException)->setModel(get_class($this));
Severity: Critical
Found in src/Traits/Uuid.php by phan

Returning type ?string|array{6:string}|array{8:string} but nameGenerator() is declared to return string
Open

        return ($uuid);
Severity: Minor
Found in src/Classes/Uuid.php by phan

Return type of __get() is undeclared type \TakeawayTown\LaravelUuid\Classes\number
Open

    public function __get($var)
Severity: Minor
Found in src/Classes/Uuid.php by phan

Call to undeclared method \TakeawayTown\LaravelUuid\Providers\UuidServiceProvider::mergeConfigFrom
Open

      $this->mergeConfigFrom(
Severity: Critical
Found in src/Providers/UuidServiceProvider.php by phan

Call to method setModel from undeclared class \Illuminate\Database\Eloquent\ModelNotFoundException
Open

      throw (new ModelNotFoundException)->setModel(get_class($this));
Severity: Critical
Found in src/Traits/Uuid.php by phan

Returning type int but __get() is declared to return \TakeawayTown\LaravelUuid\Classes\number|null|string
Open

                return (int) ord($this->bytes[6]) >> 4;
Severity: Minor
Found in src/Classes/Uuid.php by phan

Saw an @param annotation for ns, but it was not found in the param list of function nameGenerator(int $ver, string $node, $namespace) : string
Open

     * @param  string  $ns   Binary namespace is required for version 3 or 5 UUIDs
Severity: Info
Found in src/Classes/Uuid.php by phan

Reference to undeclared property \TakeawayTown\LaravelUuid\Classes\Uuid->string
Open

        $this->string = bin2hex(substr($uuid, 0, 4)) . "-" .
Severity: Minor
Found in src/Classes/Uuid.php by phan

Saw an @param annotation for ns, but it was not found in the param list of function generate(int $ver = null, string $node = null, mixed $namespace = null) : \TakeawayTown\LaravelUuid\Classes\Uuid
Open

    * @param  string  $ns   Binary namespace is required for version 3 or 5 UUIDs
Severity: Info
Found in src/Classes/Uuid.php by phan

Returning type int but __get() is declared to return \TakeawayTown\LaravelUuid\Classes\number|null|string
Open

                    return (int) 0;
Severity: Minor
Found in src/Classes/Uuid.php by phan

Reduce the number of returns of this function 4, down to the maximum allowed 3.
Open

    protected static function makeBinary($str, $len)
Severity: Major
Found in src/Classes/Uuid.php by sonar-php

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

Returning type int but __get() is declared to return \TakeawayTown\LaravelUuid\Classes\number|null|string
Open

                    return (int) (hexdec($time) - static::INTERVAL) / 10000000;
Severity: Minor
Found in src/Classes/Uuid.php by phan

Returning type int but __get() is declared to return \TakeawayTown\LaravelUuid\Classes\number|null|string
Open

                    return (int) 2;
Severity: Minor
Found in src/Classes/Uuid.php by phan

Call to undeclared function \config_path()
Open

        realpath(__DIR__.'/../../config/uuid.php') => config_path('uuid.php'),
Severity: Critical
Found in src/Providers/UuidServiceProvider.php by phan

Static call to undeclared method \TakeawayTown\LaravelUuid\Classes\Uuid,1::saving
Open

    static::saving(function ($model) {
Severity: Critical
Found in src/Traits/Uuid.php by phan

Call to method __construct from undeclared class \TakeawayTown\LaravelUuid\Classes\UnexpectedValueException (Did you mean class \UnexpectedValueException)
Open

                throw new UnexpectedValueException('Version ' . $ver . ' is unsupported.');
Severity: Critical
Found in src/Classes/Uuid.php by phan

Add a "case default" clause to this "switch" statement.
Open

        switch ($ver) {
Severity: Critical
Found in src/Classes/Uuid.php by sonar-php

The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

Noncompliant Code Example

switch ($param) {  //missing default clause
  case 0:
    do_something();
    break;
  case 1:
    do_something_else();
    break;
}

switch ($param) {
  default: // default clause should be the last one
    error();
    break;
  case 0:
    do_something();
    break;
  case 1:
    do_something_else();
    break;
}

Compliant Solution

switch ($param) {
  case 0:
    do_something();
    break;
  case 1:
    do_something_else();
    break;
  default:
    error();
    break;
}

See

  • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
  • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
  • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
  • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
  • MISRA C:2012, 16.1 - All switch statements shall be well-formed
  • MISRA C:2012, 16.4 - Every switch statement shall have a default label
  • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
  • MITRE, CWE-478 - Missing Default Case in Switch Statement
  • CERT, MSC01-C. - Strive for logical completeness
  • CERT, MSC01-CPP. - Strive for logical completeness
Severity
Category
Status
Source
Language