Showing 56 of 56 total issues
Line exceeds 120 characters; contains 124 characters Open
return ' 
 Cache: is globally turned off (You should put "enable_cache" => true in config\widgetize.php) ';
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>";
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
$this->html = "<!-- '{".get_class($this->widget)."' Widget Start -->".$this->html."<!-- '".get_class($this->widget)."' Widget End -->";
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 0 Open
'2 - "$params" (data passed to @widget(\'name\', $params) call). '.PHP_EOL.'
- Exclude checks
The variable $_key is not named in camelCase. Open
private function makeCacheKey(array $arg, $widget, string $form): string
{
if (method_exists($widget, 'cacheKey')) {
return $widget->cacheKey($arg);
}
- Read upRead up
- Exclude checks
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 $_key is not named in camelCase. Open
private function makeCacheKey(array $arg, $widget, string $form): string
{
if (method_exists($widget, 'cacheKey')) {
return $widget->cacheKey($arg);
}
- Read upRead up
- Exclude checks
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 $M is not named in camelCase. Open
public function normalize($widget): void
{
if (! property_exists($widget, 'cacheLifeTime')) {
$M = config('widgetize.default_cache_lifetime', 0);
$widget->cacheLifeTime = $this->makeFromSeconds($M * 60);
- Read upRead up
- Exclude checks
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 $_key is not named in camelCase. Open
private function makeCacheKey(array $arg, $widget, string $form): string
{
if (method_exists($widget, 'cacheKey')) {
return $widget->cacheKey($arg);
}
- Read upRead up
- Exclude checks
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 $_key is not named in camelCase. Open
private function makeCacheKey(array $arg, $widget, string $form): string
{
if (method_exists($widget, 'cacheKey')) {
return $widget->cacheKey($arg);
}
- Read upRead up
- Exclude checks
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 $_key is not named in camelCase. Open
private function makeCacheKey(array $arg, $widget, string $form): string
{
if (method_exists($widget, 'cacheKey')) {
return $widget->cacheKey($arg);
}
- Read upRead up
- Exclude checks
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 $M is not named in camelCase. Open
public function normalize($widget): void
{
if (! property_exists($widget, 'cacheLifeTime')) {
$M = config('widgetize.default_cache_lifetime', 0);
$widget->cacheLifeTime = $this->makeFromSeconds($M * 60);
- Read upRead up
- Exclude checks
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 method _registerDebugbar is not named in camelCase. Open
private function _registerDebugbar()
{
if (! $this->app->offsetExists('debugbar')) {
return;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
Rename "$slots" which has the same name as the field declared at line 15. Open
$slots = $this->slots;
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
private function determineDataMethod($widget): array
- Read upRead up
- 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; }
Define a constant instead of duplicating this literal "plain" 3 times. Open
if (! $this->option('plain')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define and throw a dedicated exception instead of using a generic one. Open
throw new ErrorException('There was some error rendering '.get_class($widget).', template file: \''.$widget->template.'\' Error: '.$t->getMessage());
- Read upRead up
- Exclude checks
If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.
Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.
Noncompliant Code Example
throw new Exception(); // Noncompliant
Compliant Solution
throw new InvalidArgumentException(); // or throw new UnexpectedValueException();
See
- MITRE, CWE-397 - Declaration of Throws for Generic Exception
- CERT, ERR07-J. - Do not throw RuntimeException, Exception, or Throwable