Showing 109 of 109 total issues
Line indented incorrectly; expected 12 spaces, found 6 Open
Open
if (!$model->{config('uuid.uuid_column')}) {
- Create a ticketCreate a ticket
- Exclude checks
Argument 1 (get_as_float)
is 1
but \microtime()
takes bool
Open
Open
$time = microtime(1) * 10000000 + static::INTERVAL;
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared function \config()
Open
Open
$uuid = $model->getOriginal(config('uuid.uuid_column'));
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \Illuminate\Database\Eloquent\ModelNotFoundException
Open
Open
throw (new ModelNotFoundException)->setModel(get_class($this));
- Create a ticketCreate a ticket
- Exclude checks
Returning type ?string|array{6:string}|array{8:string}
but nameGenerator()
is declared to return string
Open
Open
return ($uuid);
- Create a ticketCreate a ticket
- Exclude checks
Return type of __get()
is undeclared type \TakeawayTown\LaravelUuid\Classes\number
Open
Open
public function __get($var)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \TakeawayTown\LaravelUuid\Providers\UuidServiceProvider::mergeConfigFrom
Open
Open
$this->mergeConfigFrom(
- Create a ticketCreate a ticket
- Exclude checks
Call to method setModel
from undeclared class \Illuminate\Database\Eloquent\ModelNotFoundException
Open
Open
throw (new ModelNotFoundException)->setModel(get_class($this));
- Create a ticketCreate a ticket
- Exclude checks
Returning type int
but __get()
is declared to return \TakeawayTown\LaravelUuid\Classes\number|null|string
Open
Open
return (int) ord($this->bytes[6]) >> 4;
- Create a ticketCreate a ticket
- Exclude checks
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
Open
* @param string $ns Binary namespace is required for version 3 or 5 UUIDs
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared property \TakeawayTown\LaravelUuid\Classes\Uuid->string
Open
Open
$this->string = bin2hex(substr($uuid, 0, 4)) . "-" .
- Create a ticketCreate a ticket
- Exclude checks
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
Open
* @param string $ns Binary namespace is required for version 3 or 5 UUIDs
- Create a ticketCreate a ticket
- Exclude checks
Returning type int
but __get()
is declared to return \TakeawayTown\LaravelUuid\Classes\number|null|string
Open
Open
return (int) 0;
- Create a ticketCreate a ticket
- Exclude checks
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
Open
protected static function makeBinary($str, $len)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Open
return (int) (hexdec($time) - static::INTERVAL) / 10000000;
- Create a ticketCreate a ticket
- Exclude checks
Returning type int
but __get()
is declared to return \TakeawayTown\LaravelUuid\Classes\number|null|string
Open
Open
return (int) 2;
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared function \config_path()
Open
Open
realpath(__DIR__.'/../../config/uuid.php') => config_path('uuid.php'),
- Create a ticketCreate a ticket
- Exclude checks
Static call to undeclared method \TakeawayTown\LaravelUuid\Classes\Uuid,1::saving
Open
Open
static::saving(function ($model) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \TakeawayTown\LaravelUuid\Classes\UnexpectedValueException
(Did you mean class \UnexpectedValueException) Open
Open
throw new UnexpectedValueException('Version ' . $ver . ' is unsupported.');
- Create a ticketCreate a ticket
- Exclude checks
Add a "case default" clause to this "switch" statement. Open
Open
switch ($ver) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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