poisa/Settings

View on GitHub

Showing 88 of 88 total issues

Remove the unused function parameter "$app".
Open

        $this->app->singleton(Settings::class, function ($app) {
Severity: Major
Found in src/SettingsServiceProvider.php by sonar-php

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

        Schema::create(config('settings.table_name'), function (Blueprint $table) {

Call to undeclared function \config()
Open

        return config('settings.encrypt_known_types');
Severity: Critical
Found in src/Serializers/BaseScalarType.php by phan

Call to undeclared function \config()
Open

        foreach (config('settings.serializers') as $serializable) {
Severity: Critical
Found in src/Serializers/SerializerFactory.php by phan

Call to undeclared function \config_path()
Open

        $this->publishes([$configFile => config_path('settings.php')]);
Severity: Critical
Found in src/SettingsServiceProvider.php by phan

Class extends undeclared class \Illuminate\Database\Migrations\Migration
Open

class CreateSettingsTable extends Migration

Call to undeclared function \config()
Open

        Schema::dropIfExists(config('settings.table_name'));

Class extends undeclared class \Illuminate\Support\ServiceProvider
Open

class SettingsServiceProvider extends ServiceProvider
Severity: Critical
Found in src/SettingsServiceProvider.php by phan

Call to undeclared method \Poisa\Settings\SettingsServiceProvider::publishes
Open

        $this->publishes([$configFile => config_path('settings.php')]);
Severity: Critical
Found in src/SettingsServiceProvider.php by phan

Call to undeclared method \Poisa\Settings\Models\Settings::where
Open

        $data = $this->getConfiguredModel($connection)
Severity: Critical
Found in src/Settings.php by phan

Call to undeclared method \Poisa\Settings\Models\Settings::where
Open

        $data = $model->where('key', $key)->first();
Severity: Critical
Found in src/Settings.php by phan

Call to undeclared function \config()
Open

        $serializers = config('settings.serializers');
Severity: Critical
Found in src/Settings.php by phan

Define a constant instead of duplicating this literal "settings.serializers" 3 times.
Open

        $serializers = config('settings.serializers');
Severity: Critical
Found in src/Settings.php by sonar-php

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

            $table->longtext('value')->nullable();

Method \Poisa\Settings\Commands\GetCommand::handle is declared to return mixed but has no return value
Open

    public function handle()
Severity: Minor
Found in src/Commands/GetCommand.php by phan

Call to undeclared method \Poisa\Settings\Commands\SetCommand::option
Open

            $database = $this->option('database');
Severity: Critical
Found in src/Commands/SetCommand.php by phan

Call to undeclared function \encrypt()
Open

            $data->value = encrypt($serializable->serialize($value));
Severity: Critical
Found in src/Settings.php by phan

Reference to undeclared property \Poisa\Settings\SettingsServiceProvider->app
Open

        $this->app->singleton(Settings::class, function ($app) {
Severity: Minor
Found in src/SettingsServiceProvider.php by phan

Class uses undeclared trait \Illuminate\Queue\SerializesModels
Open

class SettingUpdated
Severity: Critical
Found in src/Events/SettingUpdated.php by phan

Class extends undeclared class \Illuminate\Support\Facades\Facade
Open

class Settings extends Facade
Severity: Critical
Found in src/Facades/Settings.php by phan
Severity
Category
Status
Source
Language