Showing 88 of 88 total issues
Remove the unused function parameter "$app". Open
Open
$this->app->singleton(Settings::class, function ($app) {
- Read upRead up
- Exclude checks
Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.
Noncompliant Code Example
function doSomething($a, $b) { // "$a" is unused return compute($b); }
Compliant Solution
function doSomething($b) { return compute($b); }
Exceptions
Functions in classes that override a class or implement interfaces are ignored.
class C extends B { function doSomething($a, $b) { // no issue reported on $b compute($a); } }
See
- MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
- MISRA C:2012, 2.7 - There should be no unused parameters in functions
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
- CERT, MSC12-CPP. - Detect and remove code that has no effect
Parameter $table
has undeclared type \Illuminate\Database\Schema\Blueprint
Open
Open
Schema::create(config('settings.table_name'), function (Blueprint $table) {
- Exclude checks
Call to undeclared function \config()
Open
Open
return config('settings.encrypt_known_types');
- Exclude checks
Call to undeclared function \config()
Open
Open
foreach (config('settings.serializers') as $serializable) {
- Exclude checks
Call to undeclared function \config_path()
Open
Open
$this->publishes([$configFile => config_path('settings.php')]);
- Exclude checks
Class extends undeclared class \Illuminate\Database\Migrations\Migration
Open
Open
class CreateSettingsTable extends Migration
- Exclude checks
Call to undeclared function \config()
Open
Open
Schema::dropIfExists(config('settings.table_name'));
- Exclude checks
Class extends undeclared class \Illuminate\Support\ServiceProvider
Open
Open
class SettingsServiceProvider extends ServiceProvider
- Exclude checks
Call to undeclared method \Poisa\Settings\SettingsServiceProvider::publishes
Open
Open
$this->publishes([$configFile => config_path('settings.php')]);
- Exclude checks
Call to undeclared method \Poisa\Settings\Models\Settings::where
Open
Open
$data = $this->getConfiguredModel($connection)
- Exclude checks
Call to undeclared method \Poisa\Settings\Models\Settings::where
Open
Open
$data = $model->where('key', $key)->first();
- Exclude checks
Call to undeclared function \config()
Open
Open
$serializers = config('settings.serializers');
- Exclude checks
Define a constant instead of duplicating this literal "settings.serializers" 3 times. Open
Open
$serializers = config('settings.serializers');
- 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.
Call to method longtext
from undeclared class \Illuminate\Database\Schema\Blueprint
Open
Open
$table->longtext('value')->nullable();
- Exclude checks
Method \Poisa\Settings\Commands\GetCommand::handle
is declared to return mixed
but has no return value Open
Open
public function handle()
- Exclude checks
Call to undeclared method \Poisa\Settings\Commands\SetCommand::option
Open
Open
$database = $this->option('database');
- Exclude checks
Call to undeclared function \encrypt()
Open
Open
$data->value = encrypt($serializable->serialize($value));
- Exclude checks
Reference to undeclared property \Poisa\Settings\SettingsServiceProvider->app
Open
Open
$this->app->singleton(Settings::class, function ($app) {
- Exclude checks
Class uses undeclared trait \Illuminate\Queue\SerializesModels
Open
Open
class SettingUpdated
- Exclude checks
Class extends undeclared class \Illuminate\Support\Facades\Facade
Open
Open
class Settings extends Facade
- Exclude checks